Use Input for form inputs including text, password, email, url, and search.
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:
A label
prop let’s you define a simple String to be used as the input label.
<Input label="Name" />
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" />
Default is true but can also be assigned a Boolean value like disabled={user.isSpammable}
.
<Input label="Name" disabled />
Display error message below the field. Also adds error styles.
<Input label="Email" error="Email is not valid" />
A note
prop let’s you define a note displayed below the field.
<Input note="This is a note" />
Name | Type | Default | Description |
---|---|---|---|
name | String | name of the input field | |
placeholder | String | Input value description | |
label | String | Input | Text label appears above the input field |
type | String | text | Input field types |
disabled | Boolean | false | Disables the input field |
note | String | Text appears below input field | |
error | String | Error message for the input field | |
class | String | 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 |
Name | Type | Default | Description |
---|---|---|---|
--ui-input-font-size | Numeric | --ui-font-size , 1rem | Font size for value of field |
--ui-input-color | Color | --ui-dark , #1e293b | Text color for value of field |
--ui-input-border-width | Numeric | --ui-border-width , 1px | Border width |
--ui-input-border-color | Color | --ui-border-color , --ui-midtone , #94a3b8 | Border color |
--ui-input-border-radius | Numeric | --ui-border-radius , 3px | Border radius |
--ui-input-padding | Numeric | --ui-padding , 4px 6px | CSS padding shorthand |
--ui-input-outline-width | Numeric | --ui-outline-width , 1px | Outline width for :focus and .error |
--ui-input-outline-offset | Numeric | --ui-outline-offset , none | Outline offset for :focus and .error |
--ui-input-focus | Color | --ui-focus , --ui-midtone , #94a3b8 | Focus color applied to border and outline |
--ui-input-error | Color | --ui-error , --ui-error , #b91c1c | Error color for border, text, error note |