Label
A label whose colour follows its control's focus and errors, with a small marker that pops in.
See it as an AI agent does.See this component the way an AI agent does.
Installation
npx shadcn@latest add @keyframery/labelThis adds components/keyframery/label.tsx and its primitive to your project, and installs UI SDK. The motion tokens are added to your global CSS the first time you install a component.
Usage
import { Input } from "@/components/keyframery/input"
import { Label, LabelMarker } from "@/components/keyframery/label"
export default function Usage() {
return (
<>
<Label htmlFor="name">
Name <LabelMarker>Required</LabelMarker>
</Label>
<Input id="name" required />
</>
)
}Examples
Required and optional
LabelMarker adds a quiet note after the text.
Motion
| Move | What you see |
|---|---|
| Fade | The label's colour follows its control: quiet, full ink when focused, red when invalid. |
| Pop | A Required or Optional marker pops in. |
Timing and springiness follow the motion style you set. To change how fast this label moves, pass speed:
<Label speed="fast">
…
</Label>"fast" is 0.6×, "slow" 1.4×, and a number sets the multiplier. With reduced motion turned on, nothing moves: changes happen at once or with a short fade.
Theming
Set these CSS variables on the component or a parent. Leave them unset to follow the light and dark theme. The open Customize panel below the preview lets you try these settings.
| Variable | What it changes | Default |
|---|---|---|
--label-ink | Resting label text | --muted-foreground |
--label-focus | Focused label and marker text | --foreground |
--label-invalid | Invalid label and marker text | --destructive |
--label-marker | Marker surface | --muted |
--label-marker-ink | Resting marker text | --muted-foreground |
--label-font | Label text size | 13px |
--label-gap | Label to marker gap | 0.375rem |
--label-marker-radius | Marker corners | 9999px |
API reference
Every part takes className and children. Parts from UI SDK also take render, to draw your own element, and a function of their state for className and style. Props not listed here are in the UI SDK label reference.
Label
Renders a <div>, and takes its props too.
Prop
Type
Other parts
These take the props of the element they render, and nothing else:
LabelMarker: a<span>
Accessibility
Keyboard, focus and screen-reader behaviour come from UI SDK and are not changed. More in Accessibility.
Swap the import
Already using UI SDK's label with your own styles? Keep your markup and change one line. The primitive adds motion and nothing else.
// Before
import { … } from "@ui-sdk/react/label"
// After: same parts, same props, now animated
import { … } from "@/components/keyframery/primitives/label"Questions
How does the animated Label for UI SDK move?
Fade: The label's colour follows its control: quiet, full ink when focused, red when invalid. Pop: A Required or Optional marker pops in.
Do I need Motion or Framer Motion for the animated Label?
No. Every move is plain CSS, so there is nothing to install besides the component and UI SDK.
Can I keep my own styling and only take the motion?
Yes. Import from @/components/keyframery/primitives/label instead. It has the same parts and props as @ui-sdk/react/label and adds motion only.
What happens to the Label when someone turns on reduced motion?
Nothing moves. State changes happen at once, or with a short fade.
More in Forms
All componentsInput Group
Icons, text, buttons and a count around an input or textarea, in one field: the focus ring closes in on the whole group, the count rolls as you type and a send button pops in with the first character.
Native Select
The browser's own select in a Keyframery field: each new choice rises in out of a blur as the old one leaves upward, and the chevron dips.