Vitral 0.2
Formulário

FloatLabel

Um label de verdade que começa dentro do campo e sai dele com o foco ou quando há valor; o IftaLabel o mantém dentro, acima do valor.

Importação

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

Variantes

over (o padrão), in e on.

<script setup lang="ts">import { FloatLabel, InputText } from '@vitral/vue';import { ref } from 'vue'; const over = ref('');const inside = ref('');const on = ref('Ada');</script> <template>    <FloatLabel>        <InputText id="fl-over" v-model="over" placeholder=" " />        <label for="fl-over">Over</label>    </FloatLabel>    <FloatLabel variant="in">        <InputText id="fl-in" v-model="inside" placeholder=" " />        <label for="fl-in">In</label>    </FloatLabel>    <FloatLabel variant="on">        <InputText id="fl-on" v-model="on" placeholder=" " />        <label for="fl-on">On</label>    </FloatLabel></template>

Com um select

Um select não tem estado de placeholder para ser lido, então `filled` avisa o wrapper.

<script setup lang="ts">import { FloatLabel, Select } from '@vitral/vue';import { ref } from 'vue'; const city = ref<string | null>(null);const cities = ['Lisbon', 'Porto', 'São Paulo', 'Rio de Janeiro'];</script> <template>    <FloatLabel :filled="city != null" style="min-width: 14rem">        <Select v-model="city" :options="cities" id="fl-city" fluid />        <label for="fl-city">City</label>    </FloatLabel></template>

IftaLabel

<script setup lang="ts">import { IftaLabel, InputText } from '@vitral/vue';import { ref } from 'vue'; const email = ref('');const wrong = ref('not-an-email');</script> <template>    <IftaLabel>        <InputText id="ifta-email" v-model="email" placeholder="you@example.com" />        <label for="ifta-email">Email</label>    </IftaLabel>    <IftaLabel invalid>        <InputText id="ifta-wrong" v-model="wrong" invalid />        <label for="ifta-wrong">Email</label>    </IftaLabel></template>

API

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

Props

NomeTipoDescrição
variant'over' | 'in' | 'on'- `over` (o padrão): o rótulo sobe para a borda do campo. - `in`: ele fica dentro, acima do valor. - `on`: ele pousa na borda sem o campo crescer.
invalidboolean—
filledbooleanSobe o rótulo mesmo que o controle não tenha placeholder para ler. Campos nativos são detectados por `:placeholder-shown`; um select ou um seletor de data não têm esse estado, então o wrapper é avisado.

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

Slots

NomeProps do slotDescrição
default—O controle e o seu `<label>`, nessa ordem.