@equinor/fusion-wc-textinput

中文文档
1.2.5发布于 2026/10/22ISCTypeScriptCommonJS构建来源已验证近 30 天下载 5618
# `` [![Published on npm](https://img.shields.io/npm/v/@equinor/fusion-wc-textinput.svg)](https://www.npmjs.com/package/@equinor/fusion-wc-textinput)
原始使用文档
文档目录5 节
  1. Installation
  2. Example Usage
  3. Properties/Attributes
  4. Methods
  5. Validation

<fusion-wc-textinput> Published on npm

Storybook

Material Web Component

Installation

npm install @equinor/fusion-wc-textinput

Example Usage

<fwc-textinput label='My Label' icon="settings"></fwc-textinput>

Properties/Attributes

NameTypeDescription
valuestringThe input control's value.
typeTextInputType*A string specifying the type of control to render.
variantTextInputVariant**Input style variant to render.
labelstringSets floating label value.
placeholderstringSets disappearing input placeholder.
prefixstringPrefix text to display before the input.
suffixstringSuffix text to display after the input.
iconIconName***Leading icon to display in input. See fwc-icon.
iconTrailingIconName***Trailing icon to display in input. See fwc-icon.
disabledbooleanWhether or not the input should be disabled.
charCounter`booleanTextInputCharCounter****`
helperstringHelper text to display below the input. Display default only when focused.
helperPersistentbooleanAlways show the helper text despite focus.
requiredbooleanDisplays error state if value is empty and input is blurred.
maxLengthnumberMaximum length to accept input.
validationMessagestringMessage to show in the error color when the textinput is invalid. (Helper text will not be visible)
patternstringHTMLInputElement.prototype.pattern (empty string will unset attribute)
minnumber|stringHTMLInputElement.prototype.min (empty string will unset attribute)
maxnumber|stringHTMLInputElement.prototype.max (empty string will unset attribute)
sizenumber|nullHTMLInputElement.prototype.size (null will unset attribute)
stepnumber|nullHTMLInputElement.prototype.step (null will unset attribute)
autoValidatebooleanReports validity on value change rather than only on blur.
validityValidityState (readonly)The ValidityState of the textinput.
willValidateboolean (readonly)HTMLInputElement.prototype.willValidate
validityTransformValidityTransform*****|nullCallback called before each validation check. See the validation section for more details.
validateOnInitialRenderbooleanRuns validation check on initial render.
namestringSets the name attribute on the internal input.***

* TextInputType is exported by fwc-textinput.

type TextInputType = 'text'|'search'|'tel'|'url'|'email'|'password'|
    'date'|'month'|'week'|'time'|'datetime-local'|'number'|'color';

** TextInputVariant is exported by fwc-textinput.

export type TextInputVariant = 'filled' | 'outlined';

*** IconName is exported by fwc-icon.

type IconName = keyof typeof edsIcons | string;

**** TextInputCharCounter is exported by fwc-textinput.

type TextInputCharCounter = 'external' | 'internal';

***** ValidityTransform is exported by fwc-textinput.

type ValidityTransform = (value: string, nativeValidity: ValidityState) => Partial<ValidityState>

****** The name property should only be used for browser autofill as webcomponent form participation does not currently consider the name attribute. See #289.

Methods

NameDescription
checkValidity() => booleanReturns true if the textinput passes validity checks. Returns false and fires an invalid event on the textinput otherwise.
NOTE: When accessing any property or function that checks validity at textinput initial boot up, you may have to await <fwc-textinput>.updateComplete.
reportValidity() => booleanRuns checkValidity() method, and if it returns false, then it reports to the user that the input is invalid.
setCustomValidity(message:string) => voidSets a custom validity message (also overwrites validationMessage). If this message is not the empty string, then the element is suffering from a custom validity error and does not validate.
layout() => Promise<void>Re-calculate layout. If a textinput is styled with display:none before it is first rendered, and it has a label that is floating, then you must call layout() the first time you remove display:none, or else the notch surrounding the label will not render correctly.

Validation

<fwc-textinput> follows the basic <input> constraint validation model. It exposes:

  • required
  • maxLength
  • pattern
  • min
  • max
  • step
  • validity
  • willValidate
  • checkValidity()
  • reportValidity()
  • setCustomValidity(message)

Additionally, it implements more features such as:

  • validationMessage
  • validateOnInitialRender
  • and validityTransform

By default, <fwc-textinput> will report validation on blur.

版本与发布记录

@equinor/fusion-wc-textinput 共发布 54 个版本,首次发布于 2021/06/16;过去 12 个月发布了 6 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.2.5latest2026/10/2222 天前
1.2.42026/08/123 个月前
1.2.32026/05/116 个月前
1.2.22026/05/056 个月前
1.2.12026/04/286 个月前
1.2.02026/04/206 个月前

其他发布通道:next → 0.5.20-next.1。

关于 @equinor/fusion-wc-textinput 的常见问题

@equinor/fusion-wc-textinput 是什么?

# `` [![Published on npm](https://img.shields.io/npm/v/@equinor/fusion-wc-textinput.svg)](https://www.npmjs.com/package/@equinor/fusion-wc-textinput)

如何安装 @equinor/fusion-wc-textinput?

在项目目录运行 npm install @equinor/fusion-wc-textinput,或使用 pnpm add / yarn add / bun add。

@equinor/fusion-wc-textinput 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@equinor/fusion-wc-textinput 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@equinor/fusion-wc-textinput 可以商用吗?

@equinor/fusion-wc-textinput 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@equinor/fusion-wc-textinput 的下载量有多少?

根据 npm 官方下载统计,@equinor/fusion-wc-textinput 在 2026/10/14 – 2026/11/12 这 30 天内被下载 5,618 次,日均约 187 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@equinor/fusion-wc-textinput 还在维护吗?

最新版本 1.2.5 发布于 2026/10/22(22 天前);至今共发布 54 个版本,其中过去 12 个月发布了 6 个;首次发布于 2021/06/16。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。