WlFieldGroup

Joins a field, an action or an add-on with a shared edge.
Components / Containers v1.4.0

Basic example

Attach WlField’s ID to the input. The prefix stays separate from the value and each control stays in the normal Tab order.

https://
Full example
<form class="wl-stack" data-space="sm" @submit.prevent="submitted = query.trim()">
  <WlField v-slot="{ id, labelId }" label="Site address">
    <WlFieldGroup>
      <template #prefix>https://</template>
      <WlInput :id="id" v-model="query" :aria-labelledby="labelId" />
      <WlButton type="submit">{{ "Save" }}</WlButton>
    </WlFieldGroup>
  </WlField>
  <output v-if="submitted" aria-label="Saved">https://{{ submitted }}</output>
</form>

Units and an attached action

Add a unit after the field or place a clear action beside the input. WlField connects the visible label to the input.

h
Enter at least one hour.

Studio North

Full example
<script setup lang="ts">
import { WlButton, WlField, WlFieldGroup, WlIcon, WlInput } from "legato-ui";
import { computed, ref } from "vue";

const hours = ref("4");
const filter = ref("North");
const customers = ["Studio North", "Paper Plane", "Monday Works"];
const matches = computed(() => customers.filter((name) =>
  name.toLowerCase().includes(filter.value.trim().toLowerCase())));
</script>

<template>
  <div class="wl-stack" data-space="lg">
    <WlField
      v-slot="{ id, ariaDescribedby }"
      label="Response time in hours"
      hint="Enter at least one hour."
    >
      <WlFieldGroup>
        <WlInput
          :id="id"
          v-model="hours"
          type="number"
          min="1"
          :aria-describedby="ariaDescribedby"
        />
        <template #suffix>{{ "h" }}</template>
      </WlFieldGroup>
    </WlField>
    <WlField v-slot="{ id }" label="Filter by customer">
      <WlFieldGroup>
        <template #prefix><WlIcon name="search" /></template>
        <WlInput :id="id" v-model="filter" />
        <WlButton variant="secondary" @click="filter = ''">
          {{ "Clear" }}
        </WlButton>
      </WlFieldGroup>
    </WlField>
    <p class="wl-text-small wl-text-muted" role="status">
      {{ matches.join(", ") || "No matching customers" }}
    </p>
  </div>
</template>