input
The label and error are wired up automatically — for/id and aria-describedby are set from name. You don't need to manage ids yourself.
Enter a valid email address
Results update as you type
input({ name: 'email', label: 'Email address', type: 'email', placeholder: 'you@example.com' })
input({ name: 'email', label: 'Email address', error: 'Enter a valid email address', value: state.email })
input({ name: 'search', label: 'Search', placeholder: 'Filter by name…', hint: 'Results update as you type' })| Prop | Type | Default | |
|---|---|---|---|
name | string | — | Also used as id base: field-{name} |
label | string | — | |
type | string | text | Any valid HTML input type |
placeholder | string | — | |
value | string | — | Pre-filled value — escaped automatically |
error | string | — | Triggers aria-invalid and role="alert" |
hint | string | — | Helper text below the input |
required | boolean | false | Adds required, aria-required, and a visual asterisk |
disabled | boolean | false | |
id | string | — | Override the generated id |
attrs | object | {} | Extra attributes on the <input> element |