Floating Label
The label sits inside the field, then shrinks and floats up when you start typing.
:placeholder-shown + CSS transformWhen to use it
For Material-style forms where space is tight.
Common mistake
Don’t shrink it until it’s unreadable.
Accessibility
The label must stay visible after typing, never disappear.
Name in code
| HTML/CSS | :placeholder-shown + CSS transform |
|---|---|
| React | <TextField label> — MUI |
| Jetpack Compose | OutlinedTextField(label = { }) |
| SwiftUI | Custom (ZStack + animation) |
Ready prompt for your coding agent
Add a Floating Label to this screen.
What it is: The label sits inside the field, then shrinks and floats up when you start typing.
Implement with: :placeholder-shown + CSS transform (HTML/CSS).
Accessibility: The label must stay visible after typing, never disappear.
When to use it: For Material-style forms where space is tight.
Avoid: Don’t shrink it until it’s unreadable.
Reuse the project's existing design tokens, spacing and component conventions.
Or compose a whole page from this element and others →
Prompts are in English for the most precise results with coding agents.