Alert Avatar AvatarGroup Button ButtonGroup Checkbox CheckboxGroup FilePicker Form FormRow Hamburger Input Modal Option Radio RadioGroup Rating Select Spinner Textarea Toast Tooltip Toggle

Input

Use Input for form inputs including text, password, email, url, and search.


Example

Type in the field to see the value change.

<script>
  import { Input } from '$lib/ui';
  let name = '';
</script>

<Input
  name="name"
  label="Name"
  placeholder="Jane Doe"
  bind:value={name}
/>

<p>Name: {name}</p>

Name:


Label

A label prop let’s you define a simple String to be used as the input label.

<Input label="Name" />

PlaceHolder

A placeholder prop let’s you define a simple String to be used as a simple descriptor for the input value.

<Input placeholder="Jane Doe" />

Disabled

Default is true but can also be assigned a Boolean value like disabled={user.isSpammable}.

<Input label="Name" disabled />

Error

Display error message below the field. Also adds error styles.

<Input label="Email" error="Email is not valid" />
Email is not valid

Note

A note prop let’s you define a note displayed below the field.

<Input note="This is a note" />
This is a note

Input Component Props

Name Type Default Description
nameString name of the input field
placeholderString Input value description
labelStringInputText label appears above the input field
typeStringtextInput field types
disabledBooleanfalseDisables the input field
noteString Text appears below input field
errorString Error message for the input field
classString CSS classes declared in global scope can be applied to the outermost element
...  Additional props will be passed through to the HTML element enabling support for things like on:click, etc

Input CSS Custom Properties

Name Type Default Description
--ui-input-font-sizeNumeric--ui-font-size, 1remFont size for value of field
--ui-input-colorColor--ui-dark, #1e293bText color for value of field
--ui-input-border-widthNumeric--ui-border-width, 1pxBorder width
--ui-input-border-colorColor--ui-border-color, --ui-midtone, #94a3b8Border color
--ui-input-border-radiusNumeric--ui-border-radius, 3pxBorder radius
--ui-input-paddingNumeric--ui-padding, 4px 6pxCSS padding shorthand
--ui-input-outline-widthNumeric--ui-outline-width, 1pxOutline width for :focus and .error
--ui-input-outline-offsetNumeric--ui-outline-offset, noneOutline offset for :focus and .error
--ui-input-focusColor--ui-focus, --ui-midtone, #94a3b8Focus color applied to border and outline
--ui-input-errorColor--ui-error, --ui-error, #b91c1cError color for border, text, error note