Vitral 0.2
Form

FloatLabel

A real label that starts inside the field and lifts out on focus or once there is a value; IftaLabel keeps it inside, above the value.

Import

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

Variants

over (the default), in and 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>

With a select

A select has no placeholder state to read, so `filled` tells the 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

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

Props

NameTypeDescription
variant'over' | 'in' | 'on'- `over` (the default): the label lifts onto the field's border. - `in`: it stays inside, above the value. - `on`: it parks on the border without the field growing.
invalidboolean—
filledbooleanLift the label although the control has no placeholder to read. Native fields are detected from `:placeholder-shown`; a select or a date picker has no such state, so its wrapper is told.

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

Slots

NameSlot propsDescription
default—The control and its `<label>`, in that order.