Appearance
Appearance
import Input from "~/components/ui/Input.vue"Inputs are areas in which users can enter a single-line text or a number. Several presets are available.
{
icon?: string;
placeholder?: string;
password?: true;
search?: true;
numeric?: true;
label?: string;
autofocus?: boolean;
reset?: () => void;
} & (ColorProps | DefaultProps | PastelProps)
& VariantProps
& RaisedProps
& WidthPropsLink a user's input to form data by referencing the data in a v-model of type string | number.
const value = ref("Preset Value");<Input v-model="value" placeholder="Your favorite animal" />NOTE
To convey the intent of the input field, add either a text label or a custom, screenreader-friendly label template. Read more on form field labelling
Define the autocomplete and type attributes to add semantic clarity and accessibility for machine assistants. A rich taxonomy exists.
NOTE
Make sure that when the user starts typing, the page does not radically change. This is about predictability. Warn users if a context change is unavoidable. 3.2.2
Add a Bootstrap icon to an input to make its purpose more visually clear.
<Input v-model="value" icon="bi-search" />You can either define a text-only label with the label prop, or place a custom template into the #label slot:
<Input v-model="user">
<template #label>
User name
</template>
</Input>If you just have a string, we have a convenience prop, so instead you can write:
<Input v-model="user" label="How do you want to be called?" />You can add a template on the right-hand side of the input to guide the user's input.
<Input v-model="value" placeholder="🐈">
<template #input-right>
Paste your cat!
</template>
</Input>See Button for a detailed overview of available props.
<Input search v-model="search" /><Spacer :size="64" />
<Layout form stack>
<Input v-model="user" label="User name" autocomplete="username" />
<Input password v-model="password" label="Password" />
<Layout flex>
<Button primary> Submit </Button>
<Button @click="()=>{user='';password=''}"> Clear </Button>
</Layout>
</Layout>TIP
We use the spacer to simulate the baseline alignment on page layouts (64px between sections)
<Input
v-model="value"
:reset="() => { value = 'Original value' }">
</Input>If you add attributes that are no props, they will be added to the resulting <input> element:
<Input v-model="password" required
field-id="password-field"
/>Using this component
password or autocomplete="username". 1.3.5<Input
v-model="username"
label="User name"
autocomplete="username"
/>
<Input
v-model="password"
label="Password"
password
/>