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.
See it as an AI agent does.See this component the way an AI agent does.
Installation
npx shadcn@latest add @keyframery/native-selectThis adds components/keyframery/native-select.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 { NativeSelect, NativeSelectOption } from "@/components/keyframery/native-select"
export default function Usage() {
return (
<NativeSelect aria-label="Status" defaultValue="todo">
<NativeSelectOption value="todo">To do</NativeSelectOption>
<NativeSelectOption value="doing">In progress</NativeSelectOption>
<NativeSelectOption value="done">Done</NativeSelectOption>
</NativeSelect>
)
}Examples
Basic
The browser's own picker, in a Keyframery field. Each new choice rises into the field and the chevron dips.
Groups and sizes
NativeSelectOptGroup labels a set of options. size="sm" makes a 32px field for toolbars and tables.
Controlled and invalid
Pass value and onValueChange to own the choice, and invalid to mark it wrong. A change from code moves like a pick.
Motion
| Move | What you see |
|---|---|
| Direction | The chosen label rises in from below while the old one leaves upward. |
| Pop | The chevron dips once on every change. |
| Press | The field gives a little under the pointer and springs back. |
| Spring | The focus ring starts out wide and closes onto the field on a spring. |
Timing and springiness follow the motion style you set. To change how fast this native select moves, pass speed:
<NativeSelect speed="fast">
…
</NativeSelect>"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 |
|---|---|---|
--native-select-face | Field surface | bg-background |
--native-select-ink | Selected value | text-foreground |
--native-select-muted | Placeholder and arrow | text-muted-foreground |
--native-select-radius | Field corners | rounded-[10px] |
--native-select-font | Value size | text-[13px] |
--native-select-height | Field height | h-9 |
--native-select-inset-start | Start padding | ps-3 |
API reference
Every part takes className and children, along with the props of the element it renders. The parts are rendered by UI SDK, so they also take render, to draw your own element, and a function of their state for className and style.
NativeSelect
Renders a <select>, and takes its props too.
Prop
Type
NativeSelectOption
Renders a <option>, and takes its props too.
Prop
Type
NativeSelectRoot
Renders a <div>, and takes its props too.
Prop
Type
Other parts
These take the props of the element they render, and nothing else:
NativeSelectOptGroup: a<optgroup>NativeSelectControl: a<select>NativeSelectIcon: a<span>NativeSelectValue: a<span>
Keyboard
| Key | What it does |
|---|---|
| Tab | Moves focus to the select. |
| Space | Opens the browser's picker. |
| ↓ ↑ | Changes the option, or moves through the open picker. |
| A–Z | Jumps to an option starting with that letter. |
| Escape | Closes the picker. |
Accessibility
Roles, keyboard and focus are declared on the component's UI SDK primitive, and state is announced through the matching ARIA attributes. More in Accessibility.
Built on UI SDK's core
UI SDK doesn't ship a native select, so this one is defined with its core: one definePrimitive in components/keyframery/core/native-select-core.ts, with no React in it. UI SDK's adapters can render that same definition in Vue, Svelte, Solid and web components. To keep your own styling and take only the motion, import from @/components/keyframery/primitives/native-select.
Questions
How does the animated Native Select for UI SDK move?
Direction: The chosen label rises in from below while the old one leaves upward. Pop: The chevron dips once on every change. Press: The field gives a little under the pointer and springs back. Spring: The focus ring starts out wide and closes onto the field on a spring.
Do I need Motion or Framer Motion for the animated Native Select?
No. Every move is plain CSS, so there is nothing to install besides the component and UI SDK.
UI SDK has no native select. How is this one built on UI SDK?
Its behaviour is one definition written with UI SDK's core (definePrimitive), in components/keyframery/core/native-select-core.ts. Its parts are rendered by UI SDK's adapter, so they take render, state-based class names and data-slot, like every UI SDK component.
What happens to the Native Select when someone turns on reduced motion?
Nothing moves. State changes happen at once, or with a short fade.