Current section

Files

Jump to
noora docs components textinput.md
Raw

docs/components/textinput.md

<!-- Generated by scripts/generate-web-components.js. Do not edit directly. -->
# TextInput
Collects single-line text with Noora labels, hints, prefixes, and suffixes.
```html
<noora-text-input label="Email" type="email" name="email"></noora-text-input>
```
## Attributes
| Attribute | Type or allowed values | Default | Description |
| --- | --- | --- | --- |
| `type` | `basic`, `email`, `card_number`, `search`, `password` | `"basic"` | Controls the semantic field presentation. |
| `input-type` | `string` | `"text"` | Sets the native input type for basic fields. |
| `label` | `string` | None | Sets the field label. |
| `sublabel` | `string` | None | Sets secondary label text. |
| `hint` | `string` | None | Sets supporting text. |
| `hint-variant` | `default`, `destructive`, `disabled` | `"default"` | Controls hint semantics. |
| `error` | `string` | None | Sets the validation error. |
| `name` | `string` | `""` | Sets the submitted field name. |
| `value` | `string` | `""` | Gets or sets the field value. |
| `placeholder` | `string` | None | Sets placeholder text. |
| `required` | `boolean` | `false` | Marks the field as required. |
| `show-required` | `boolean` | `false` | Shows the required indicator. |
| `min` | `string` | None | Sets the native minimum value. |
| `max` | `string` | None | Sets the native maximum value. |
| `step` | `string` | None | Sets the native step value. |
| `disabled` | `boolean` | `false` | Disables the field. |
## Read-only properties
| Property | Type | Description |
| --- | --- | --- |
| `control` | `HTMLInputElement \| null` | The native input. |
| `form` | `HTMLFormElement \| null` | The associated form. |
## Events
| Event | Type | Description |
| --- | --- | --- |
| `input` | `InputEvent` | Emitted while the input value changes. |
| `change` | `Event` | Emitted after the input value is committed. |
## Slots
| Slot | Description |
| --- | --- |
| `prefix` | A custom prefix for basic fields. |
| `suffix` | A custom suffix. |
## Styling parts
| Part | Description |
| --- | --- |
| `input` | The native input. |
| `wrapper` | The input wrapper. |
The component emits standard input and change events.
## Input types
Use basic, email, card-number, search, and password presentations.
```html
<noora-text-input name="basic" placeholder="Placeholder text..."><noora-icon slot="prefix" name="user"></noora-icon></noora-text-input>
<noora-text-input type="email" name="email" placeholder="hello@tuist.dev"></noora-text-input>
<noora-text-input type="card_number" name="card" placeholder="0000 0000 0000 0000"></noora-text-input>
<noora-text-input type="search" name="search" placeholder="Search..."></noora-text-input>
<noora-text-input type="password" name="password"></noora-text-input>
```
## With hint
Give supporting guidance below the input.
```html
<noora-text-input name="username" placeholder="Username" hint="Use letters, numbers, and underscores"></noora-text-input>
```
## Error
Communicate validation failures.
```html
<noora-text-input name="email" placeholder="hello@tuist.dev" error="Enter a valid email address"></noora-text-input>
```
## Custom suffix
Provide a custom element after the native input.
```html
<noora-text-input name="assignee" placeholder="Assignee"><noora-icon slot="suffix" name="user"></noora-icon></noora-text-input>
```
## Labels
Show required and secondary label content.
```html
<noora-text-input type="email" name="email" label="Email" required show-required></noora-text-input>
<noora-text-input type="password" name="password" label="Password" sublabel="Be safe!"></noora-text-input>
```
## Disabled
Compare empty and filled disabled fields.
```html
<noora-text-input type="email" name="empty-email" label="Email" placeholder="hello@tuist.dev" hint="Use a tuist.dev address" disabled></noora-text-input>
<noora-text-input type="email" name="filled-email" value="hello@tuist.dev" hint="Use a tuist.dev address" disabled></noora-text-input>
```