Input Floating
newThe label moves out of the way so you can type. Polite. A text input with a label that floats inside it, in all of Input's variants and sizes.
Receipts go here.
Installation
Usage
<script setup lang="ts">
import { InputFloating } from '@/components/ui/input-floating'
const email = ref('')
</script>
<template>
<InputFloating v-model="email" label="Email" type="email" autocomplete="email" />
</template>
The label sits where the text goes and floats up on focus, value or autofill. In outline it tucks into the border, so the field is as tall as a regular Input. In other variants it moves above the text, so the field gets a bit taller.
Date, time, colour and file inputs have their own controls, so their label is always up.
The label is a real <label>, so you don't need a Label. Inside a Field, skip FieldLabel; everything else works as usual.
A placeholder only shows on focus, so it doesn't fight the label.
Everything else works like Input: same attributes, variants, sizes and states.
Variants
Every variant of Input, each with an empty field, a filled one, an invalid one and a date.
outline
Receipts go here.
soft
Receipts go here.
filled
Receipts go here.
ghost
Receipts go here.
subtle
Receipts go here.
API Reference
class is also accepted and lands on the wrapper, so width classes work.
InputFloating
| Prop | Default | Type and description |
|---|---|---|
| label* | — | stringThe label drawn inside the input and tied to it as its |
| id | — | stringOverrides the |
| defaultValue | — | string | numberThe starting value when |
| variant | — | "outline" | "soft" | "filled" | "ghost" | "subtle" | null
|
| size | "md" | InputFloatingSizeHeight. In |
| disabled | — | booleanDisables the input. Also set by a disabled field. |
| required | — | booleanMarks the input required and adds an asterisk to the label. Also set by a required field. |
| modelValue | — | string | numberThe value, bound with |
| Event | Payload and description |
|---|---|
| update:modelValue | [value: string | number | undefined]Fires as the value changes. |
Props
- label*
stringThe label drawn inside the input and tied to it as its<label>. Makes every variant butoutlinetaller.- id
stringOverrides theidtaken from a surrounding field, or the generated one.- defaultValue
string | numberThe starting value whenv-modelis not used.- variant
"outline" | "soft" | "filled" | "ghost" | "subtle" | nulloutlinedraws a border with a gap for the label,softa tinted surface without one,filleda tinted surface with a line underneath,ghostnothing until hovered or focused, andsubtlea tinted surface with a border.- size
"md" InputFloatingSizeHeight. Inoutline, from 28px forxsto 48px forxl, as on Input; in the other variants from 40px to 56px, to fit the label above the text.- disabled
booleanDisables the input. Also set by a disabled field.- required
booleanMarks the input required and adds an asterisk to the label. Also set by a required field.- modelValue
string | numberThe value, bound withv-model.
Emits
- update:modelValue
[value: string | number | undefined]Fires as the value changes.
Data attributes
| data-slot | Attributes | Description |
|---|---|---|
| input-floating | data-variant, data-size, data-float | The wrapper. Receives class. data-size is md when left out. data-float marks input types whose own controls keep the label up. |
| input-floating-input | — | The input. |
| input-floating-label | — | The label. |