WlInput
Size and density
Full example
<div class="wl-stack" data-space="md">
<WlInput
v-model="value"
aria-label="Material title"
placeholder="Title"
:pt="{ input: { 'data-example': 'material-title' } }"
><template #prefix><WlIcon name="file" /></template></WlInput>
</div>States
Full example
<div class="wl-stack" data-space="md">
<WlInput
v-model="value"
aria-label="Material title"
placeholder="Title"
:pt="{ input: { 'data-example': 'material-title' } }"
><template #prefix><WlIcon name="file" /></template></WlInput>
</div>Content
Full example
<div class="wl-stack" data-space="md">
<WlInput
v-model="value"
aria-label="Material title"
placeholder="Title"
:pt="{ input: { 'data-example': 'material-title' } }"
><template #prefix><WlIcon name="file" /></template></WlInput>
</div>Sizes, slots and validation
Compare sizes and density, prefix/suffix, an associated error, disabled and clearing text.
Sizes and density
Slots and states
Title: Team plan. Cost: 1200.
Full example
<script setup lang="ts">
import { WlButton, WlField, WlIcon, WlInput } from "legato-ui";
import { ref } from "vue";
const title = ref("Team plan");
const amount = ref("1200");
const login = ref("");
</script>
<template>
<div class="wl-stack" data-space="xl" data-input-example="WlInput">
<section class="wl-stack" data-space="md">
<h3 class="wl-text-subheading">{{ "Sizes and density" }}</h3>
<div class="wl-grid" data-space="lg">
<WlField
v-for="size in ['sm', 'md', 'lg'] as const"
:id="`docs-input-${size}`"
:key="size"
v-slot="{ id }"
:label="`${'Title, '}${size}`"
>
<WlInput :id="id" v-model="title" :size="size" />
</WlField>
<WlField id="docs-input-compact" v-slot="{ id }" label="Compact field">
<WlInput :id="id" v-model="title" density="compact" />
</WlField>
</div>
</section>
<section class="wl-stack" data-space="md">
<h3 class="wl-text-subheading">{{ "Slots and states" }}</h3>
<div class="wl-grid" data-space="lg">
<WlField
id="docs-input-cost"
v-slot="{ id, ariaDescribedby }"
label="Cost"
hint="The icon and unit of measurement supplement the label."
>
<WlInput
:id="id"
v-model="amount"
inputmode="decimal"
:aria-describedby="ariaDescribedby"
>
<template #prefix><WlIcon name="file" :size="16" /></template>
<template #suffix><span class="wl-text-small">₽</span></template>
</WlInput>
</WlField>
<WlField
id="docs-input-login"
v-slot="{ id, ariaDescribedby, invalid, required }"
label="Username"
:error="login.trim() ? undefined : 'Enter a username.'"
required
>
<WlInput
:id="id"
v-model="login"
:invalid="invalid"
:required="required"
:aria-describedby="ariaDescribedby"
placeholder="For example, dmitry"
/>
</WlField>
<WlField id="docs-input-disabled" v-slot="{ id }" label="Unavailable field">
<WlInput :id="id" model-value="The title is set by an administrator" disabled />
</WlField>
</div>
<WlButton size="sm" @click="title = ''; amount = ''; login = ''">{{ "Clear fields" }}</WlButton>
<p class="wl-text-small" role="status">{{ "Title:" }} {{
title || "not set"
}}{{ ". Cost:" }} {{ amount || "not set" }}.</p>
</section>
</div>
</template>Props
Types, accepted values and literal defaults come from the public manifest. Inherited settings name their source; “Not set” means no default is declared.
v-model: stringField text (default "").
| Prop | Type / values | Default | Purpose |
|---|---|---|---|
size | WlSizeSm | "md" | Field size. |
density | WlDensity | "default" | Compact mode reduces field height. |
invalid | boolean | false | Error state. |
disabled | boolean | false | Disables the field. |
placeholder | string | Not set | Placeholder. |
type | string | "text" | Input element type attribute. |
pt | WlPt< | Not set | Attributes of internal Legato UI elements. |
clearable | boolean | Not set | Show a clear action for the current value. |
loading | boolean | Not set | Indicate pending work supplied by the application. |
showCount | boolean | Not set | Display the text length counter and connect it to the control description. |
Events
| Event | Payload | When emitted |
|---|---|---|
update:modelValue | string | Emitted when the component requests a model change; the payload is the next value. |
Slots
| Slot | Type / values | Content |
|---|---|---|
prefix | — | Content inside the field on the left. |
suffix | — | Content inside the field on the right. |
Pass-through: pt
Sections WlInput are listed below. Attributes merge in this order: createWlPt() WlConfig.ptpt instance. Class and style merge; the last supplied value takes priority for other attributes.
| Section | DOM | Purpose |
|---|---|---|
root | input | The root section in WlConfig.pt.input configuration. |
loadingIcon | span.wl-input-wrap__spinner | Decorative loading indicator. |
clearButton | button.wl-input-wrap__btn | Button that clears the current value. |
counter | span.wl-input-counter | Character count associated with the input. |
Sections refer to the component DOM. Dotted names identify a configuration group and its section; composite parts use their own pt groups. Global and local attributes merge, with class and style added together.
Keyboard and accessibility
- Set id and a visible label, or aria-label. A placeholder supports the label but does not replace it.
- The model is a string. Native type, name, required, readonly and aria-describedby pass to the input element.
- Associate error text through aria-describedby and pass invalid; WlField provides both in its scoped slot.
- Hide decorative prefix/suffix content from assistive technology; an independent action needs a labelled button.
Keyboard and application responsibilities
Provide a meaningful accessible name and connect labels, hints and errors to the focusable element. Check the behavior with your own data and a screen reader.
WAI-ARIA Authoring PracticesChanges are emitted through v-model. After selection, cancellation and reset, labels and states must remain clear.
In your application, check keyboard controls, zoom and focus visibility. State labels and required information must be readable in every theme.