# @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)

Latest version **1.2.5** (published 2026-10-22) · ISC license · 0 weekly downloads

## Install

```sh
npm install @equinor/fusion-wc-textinput
pnpm add @equinor/fusion-wc-textinput
yarn add @equinor/fusion-wc-textinput
bun add @equinor/fusion-wc-textinput
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.2.5 |
| Published | 2026-10-22 |
| First published | 2021-06-16 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 5 |
| Unpacked size | 456.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 13 |
| Maintainers | _odin_, nogglings, eikeland |

## Links

- npm: https://www.npmjs.com/package/@equinor/fusion-wc-textinput
- Repository: https://github.com/equinor/fusion-web-components
- Homepage: https://github.com/equinor/fusion-web-components#readme
- Issues: https://github.com/equinor/fusion-web-components/issues
- npm.io page: https://npm.io/package/@equinor/fusion-wc-textinput

## Dependencies (5)

- [lit](https://npm.io/package/lit.md) 3.3.3
- [@equinor/fusion-wc-core](https://npm.io/package/@equinor/fusion-wc-core.md) ^2.0.3
- [@equinor/fusion-wc-icon](https://npm.io/package/@equinor/fusion-wc-icon.md) ^2.4.4
- [@material/mwc-textfield](https://npm.io/package/@material/mwc-textfield.md) ^0.27.0
- [@equinor/fusion-web-theme](https://npm.io/package/@equinor/fusion-web-theme.md) ^0.1.12

## Recent versions

- 1.2.5 (latest) — 2026-10-22
- 0.5.20-next.1 (next) — 2023-09-20
- 1.2.4 — 2026-08-12
- 1.2.3 — 2026-05-11
- 1.2.2 — 2026-05-05
- 1.2.1 — 2026-04-28
- 1.2.0 — 2026-04-20
- 1.1.4 — 2025-02-26
- 1.1.3 — 2025-02-19
- 1.1.2 — 2024-08-23
- 1.1.1 — 2024-03-15
- 1.1.0 — 2023-11-24
- 1.0.3 — 2023-10-31
- 1.0.2 — 2023-10-17
- 1.0.1 — 2023-09-28
- … 39 more at https://npm.io/package/@equinor/fusion-wc-textinput/versions

## README

<!--prettier-ignore-start-->
# `<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)

[Storybook](https://equinor.github.io/fusion-web-components/?path=/docs/input-textinput)

[Material Web Component](https://github.com/material-components/material-components-web-components/tree/master/packages/textfield)

## Installation
```sh
npm install @equinor/fusion-wc-textinput
```

## Example Usage

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

### Properties/Attributes

Name                      | Type                            | Description
------------------------- | -----------------------------   | -----------
`value`                   | `string`                        | The input control's value.
`type`                    | `TextInputType*`                | A string specifying the type of control to render.
`variant`                 | `TextInputVariant**`            | Input style variant to render.
`label`                   | `string`                        | Sets floating label value.
`placeholder`             | `string`                        | Sets disappearing input placeholder.
`prefix`                  | `string`                        | Prefix text to display before the input.
`suffix`                  | `string`                        | Suffix text to display after the input.
`icon`                    | `IconName***`                   | Leading icon to display in input. See [`fwc-icon`](https://github.com/equinor/fusion-web-components/tree/main/packages/icon).
`iconTrailing`            | `IconName***`                   | Trailing icon to display in input. See [`fwc-icon`](https://github.com/equinor/fusion-web-components/tree/main/packages/icon).
`disabled`                | `boolean`                       | Whether or not the input should be disabled.
`charCounter`             | `boolean | TextInputCharCounter****`| **Note: requries `maxLength` to be set.** Display character counter with max length.
`helper`                  | `string`                        | Helper text to display below the input. Display default only when focused.
`helperPersistent`        | `boolean`                       | Always show the helper text despite focus.
`required`                | `boolean`                       | Displays error state if value is empty and input is blurred.
`maxLength`               | `number`                        | Maximum length to accept input.
`validationMessage`       | `string`                        | Message to show in the error color when the textinput is invalid. (Helper text will not be visible)
`pattern`                 | `string`                        | [`HTMLInputElement.prototype.pattern`](https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5/Constraint_validation#Validation-related_attributes) (empty string will unset attribute)
`min`                     | `number`\|`string`              | [`HTMLInputElement.prototype.min`](https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5/Constraint_validation#Validation-related_attributes) (empty string will unset attribute)
`max`                     | `number`\|`string`              | [`HTMLInputElement.prototype.max`](https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5/Constraint_validation#Validation-related_attributes) (empty string will unset attribute)
`size`                    | `number`\|`null`                | [`HTMLInputElement.prototype.size`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefsize) (null will unset attribute)
`step`                    | `number`\|`null`                | [`HTMLInputElement.prototype.step`](https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5/Constraint_validation#Validation-related_attributes) (null will unset attribute)
`autoValidate`            | `boolean`                       | Reports validity on value change rather than only on blur.
`validity`                | `ValidityState` (readonly)      | The [`ValidityState`](https://developer.mozilla.org/en-US/docs/Web/API/ValidityState) of the textinput.
`willValidate`            | `boolean` (readonly)            | [`HTMLInputElement.prototype.willValidate`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement#Properties)
`validityTransform`       | `ValidityTransform*****`\|`null`  | Callback called before each validation check. See the [validation section](#Validation) for more details.
`validateOnInitialRender` | `boolean`                       | Runs validation check on initial render.
`name`                    | `string`                        | Sets the `name` attribute on the internal input.\*\*\*

\*  `TextInputType` is exported by `fwc-textinput`.
```ts
type TextInputType = 'text'|'search'|'tel'|'url'|'email'|'password'|
    'date'|'month'|'week'|'time'|'datetime-local'|'number'|'color';
```

\*\*  `TextInputVariant` is exported by `fwc-textinput`.
```ts
export type TextInputVariant = 'filled' | 'outlined';
```

\*\*\* `IconName` is exported by `fwc-icon`.
```ts
type IconName = keyof typeof edsIcons | string;
```

\*\*\*\* `TextInputCharCounter` is exported by `fwc-textinput`.
```ts
type TextInputCharCounter = 'external' | 'internal';
```

\*\*\*\*\* `ValidityTransform` is exported by `fwc-textinput`.
```ts
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](https://github.com/material-components/material-components-web-components/issues/289).

### Methods

| Name     | Description
| -------- | -------------
| `checkValidity() => boolean`   | Returns `true` if the textinput passes validity checks. Returns `false` and fires an [`invalid`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/invalid_event) event on the textinput otherwise. <br>**NOTE:** When accessing any property or function that checks validity at textinput initial boot up, you may have to await `<fwc-textinput>.updateComplete`.
| `reportValidity() => boolean`   | Runs `checkValidity()` method, and if it returns false, then it reports to the user that the input is invalid.
| `setCustomValidity(message:string) => void`   | Sets 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](https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/HTML5/Constraint_validation).
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`.
<!--prettier-ignore-end-->

---
_Source: https://npm.io/package/@equinor/fusion-wc-textinput · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
