Vitral 0.2
Formulário

Label

Um label nativo com a tipografia dos campos, que verifica para onde aponta e fica esmaecido quando esse controle está desabilitado.

Importação

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

Básico

<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>

Ao lado de um checkbox, e desabilitado

<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>

Nomeando um grupo

<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

Lido de packages/vue/src/components/Label/types.ts, então diz o que o componente aceita de fato.

Props

NomeTipoDescrição
forstringO `id` do controle que este rótulo nomeia.
requiredbooleanMostra uma marca de obrigatório. O próprio controle ainda precisa dizer que é obrigatório (`required`, `aria-required`).
disabledbooleanEsmaece o rótulo. Lido do controle quando omitido.
sizeSize—

Mais pt, dt e unstyled de BaseProps; veja pass-through e modo sem estilo.

Slots

NomeProps do slotDescrição
default——
required—Substitui a marca de obrigatório.