WlInput

Text field with prefix/suffix slots.
Components / Inputs v0.1.0

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

₽
The icon and unit of measurement supplement the label.
Enter a username.

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>