Vitral 0.2
Form

Label

A native label with the fields' typography, that checks what it points at and dims when that control is disabled.

Import

main.ts
import { Label } from '@vitral/vue';

Basic

<script setup lang="ts">import { InputText, Label, StackPanel } from '@vitral/vue';import { ref } from 'vue'; const name = ref('');</script> <template>    <StackPanel spacing="0.375rem" style="min-width: 16rem">        <Label for="label-name" required>Full name</Label>        <InputText id="label-name" v-model="name" required aria-required="true" />    </StackPanel></template>

Beside a checkbox, and disabled

<script setup lang="ts">import { Checkbox, InputText, Label, StackPanel } from '@vitral/vue';import { ref } from 'vue'; const agree = ref(false);</script> <template>    <StackPanel orientation="horizontal" spacing="0.75rem" align="start" wrap>        <div style="display: flex; align-items: center; gap: 0.5rem">            <Checkbox id="label-agree" v-model="agree" binary />            <Label for="label-agree">I agree to the terms</Label>        </div>        <StackPanel spacing="0.375rem" style="min-width: 16rem">            <Label for="label-off">Disabled field</Label>            <InputText id="label-off" disabled />        </StackPanel>    </StackPanel></template>

Naming a group

<script setup lang="ts">import { Label, Rating, StackPanel } from '@vitral/vue';import { ref } from 'vue'; const stars = ref<number | null>(null);</script> <template>    <StackPanel spacing="0.375rem" style="min-width: 16rem">        <Label id="label-rating" size="large">How was it?</Label>        <Rating v-model="stars" aria-labelledby="label-rating" />    </StackPanel></template>

API

Read from packages/vue/src/components/Label/types.ts, so it says what the component actually accepts.

Props

NameTypeDescription
forstringThe `id` of the control this label names.
requiredbooleanShows a required mark. The control itself must still say it is required (`required`, `aria-required`).
disabledbooleanDims the label. Read from the control when it is left out.
sizeSize—

Plus pt, dt and unstyled from BaseProps, see pass-through and unstyled mode.

Slots

NameSlot propsDescription
default——
required—Replaces the required mark.