Input
A single-line text input of any type.
Forms
Added in v0.76.3
Updated
Default
{ui input, name: 'name', placeholder: 'Ada Lovelace' /}
{ui input} is a native input drawn from the theme tokens. type is any input type, text by default, and value and placeholder set what it shows. Put it in a field to give it a label, a hint and an error: both use the same name, which is the id the label points at.
invalid: true sets aria-invalid and turns the border red, so pass it with the field's error. required and disabled set those attributes, and attrs adds any other, such as autocomplete.
Types and states
<div class="flex flex-col gap-4">
{ui field, name: 'email', label: 'Email'}
{ui input, name: 'email', type: 'email', required: true /}
{/ui}
{ui field, name: 'password', label: 'Password'}
{ui input, name: 'password', type: 'password' /}
{/ui}
{ui field, name: 'locked', label: 'Locked'}
{ui input, name: 'locked', value: 'Read only for now', disabled: true /}
{/ui}
</div>
A file input styles its button to match the other controls, and a range is the native slider in the primary colour. Set min, max, step or accept through attrs.
File and range
<div class="flex flex-col gap-6">
{ui field, name: 'avatar', label: 'Avatar'}
{ui input, name: 'avatar', type: 'file', attrs: ['accept' => 'image/*'] /}
{/ui}
{ui field, name: 'volume', label: 'Volume'}
{ui input,
name: 'volume',
type: 'range',
value: '6',
attrs: ['min' => 0, 'max' => 10],
/}
{/ui}
</div>