Morph select
A pill that grows into its own option list and folds back, with a gliding highlight, a label that flies back into the pill, automatic search, ★ hold-drag-release and ★ swipe down to close.
npx @swipeui/cli add morph-selectWhen to use it
- A compact choice in a toolbar or header, such as Sort by or a view filter, where a full field is too heavy.
- A choice inside a sentence ("Show me this week").
- Grouped options with details, such as time zones, that open over the content instead of pushing it down.
When not to use it
- Form fields with a label and messages. Use Dropdown.
- Typing to search a long list as the main task. Use Combobox.
- Two to five options that should stay visible. Use Segmented control.
Installation
Run this from your app's root. If SwipeUI isn't set up yet, run npx @swipeui/cli init first; it sets up Uniwind, the theme tokens and the cn helper.
npx @swipeui/cli add morph-select- Adds
components/swipeui/ui/morph-select.tsx,components/swipeui/ui/use-morph-select.tsand 15 shared helpers. - Installs react-native-gesture-handler, react-native-reanimated, react-native-worklets, uniwind, clsx, tailwind-merge, expo-haptics, class-variance-authority, react-native-svg, react-native-safe-area-context. In Expo apps it uses
npx expo installso versions match your SDK.
Usage
import { MorphSelect } from '@/components/swipeui/ui/morph-select';
<MorphSelect
label="Sort by"
options={[
{ value: 'recent', label: 'Most recent' },
{ value: 'popular', label: 'Most popular' },
]}
align="end"
/>;The panel floats in the overlay layer, so put OverlayProvider near the app root.
Examples
Grouped time zones with offsets. Above eight options a search field appears:
<MorphSelect label="Time zone" options={zones} groups={regions} panelWidth={300} />Inside a sentence, the pill fits its words:
<Text>Show me</Text>
<MorphSelect label="Period" options={ranges} defaultValue="week" size="sm" />API reference
MorphSelectProps
| Prop | Type | Default | Description |
|---|---|---|---|
label | | — | The spoken name ("Sort by"); the pill shows the chosen label. |
options | | — | The options, in order. Group them with |
groups? | | — | Group headings, in order. |
value? | | — | The chosen value (controlled); |
defaultValue? | | | The value it starts with (uncontrolled). |
onValueChange? | | — | Reports a pick. |
placeholder? | | | Shown in the pill with nothing chosen. |
align? | | | Which edge of the pill the panel grows from: |
maxTriggerWidth? | | | The pill's widest size before its label truncates, in points. |
panelWidth? | | | The open panel's width, in points; it's never narrower than the pill. |
maxPanelHeight? | | | The open panel's tallest height before its list scrolls, in points. |
search? | | | A search field at the top of the panel: |
pressDragRelease? | | | ★ Hold the pill, drag over the rows (a tick each) and release to pick. |
holdDelay? | | | How long the finger rests before the panel opens, in milliseconds (content timing). |
swipeToClose? | | | ★ Swipe the open panel's handle down to close it without picking. |
typeahead? | | | On the web, letters on the pill pick the next match. |
size? | | | The pill's height: |
shape? | | |
|
disabled? | | | No opening or picking. |
messages? | | | Built-in strings, for translation. |
haptics? | | | Haptics: a switch, or per part ( |
motion? | | | Morph, highlight and label motion (overlay, select, morph roles). |
className? | | — | Classes on the pill. |
style? | | — | Pill style. |
testID? | | — | The pill's identifier; the panel appends |
Composition and behavior
- Tap the pill: one frame springs from the pill to the panel, growing from the
alignedge (startfollows the reading direction). The rows fade in and the highlight sits on the chosen row. - Tap a row: the panel folds back into the pill, which fits the new label, and the label flies up from its row.
- ★ Hold the pill, drag over the rows (a tick each) and release to pick. Lifting away after dragging cancels; lifting before reaching a row leaves the panel open.
- ★ Swipe the panel's handle down to close without picking. A tap outside or Escape closes it too.
- On the web, arrows open the panel; letters on the closed pill pick the next match.
- Dropdown's
variant="morph"renders Morph select. Options areSelectionOptions from selection-core.
Morph select settings
| Prop | Does | Default |
|---|---|---|
| label | The spoken name ("Sort by") | required |
| options / groups | Options and group headings | none |
| value / defaultValue | The chosen value | null |
| placeholder | The pill with nothing chosen | Choose |
| align | Grow from the pill's start or end | start |
| maxTriggerWidth | The pill's widest size (pt) | 240 |
| panelWidth / maxPanelHeight | The panel's width and tallest height (pt) | 280, 360 |
| search | auto (above 8), always or never | auto |
| pressDragRelease / holdDelay | ★ Hold, drag and release (ms to hold) | true, 350 |
| swipeToClose | ★ Swipe the handle down to close | true |
| typeahead | Letters pick on the web | true |
| size / shape | sm/md/lg; pill or preset | md, pill |
| disabled | No opening | false |
| haptics | All, or { select } | on |
| messages | Search and list strings | English |
Behavior and gestures
- Tap the pill: it grows into its panel from its `align` edge, the rows fade in and the highlight sits on the chosen row.
- Tap a row to pick it: the panel folds back into the pill, which fits the new label, and the label flies up from its row (or rolls by direction for keyboard picks).
- ★ Hold the pill (350 ms), drag over the rows with a tick each and release to pick. Lifting away after dragging cancels; lifting without reaching a row leaves the panel open (`pressDragRelease`).
- ★ Swipe the panel's handle down to close without picking (`swipeToClose`); a tap outside or Escape closes too.
- Above 8 options a search field appears at the top (`search`).
- On the web, arrows open the panel; in it, arrows, Home/End and Enter work and letters jump. Letters on the closed pill pick the next match (`typeahead`).
Accessibility
- The pill is a button named "Label: value" that reports expanded; rows are radios with checked state, and a disabled row speaks its reason.
- Picks made without opening the panel are announced. Focus returns to the pill when the panel closes on the web.
- Every gesture has a tap path.
Motion
- Uses the
overlay,select,toggle,morphandpressmotion roles, so it follows your app's feel. Passmotionto tune this one instance. - One frame springs from the pill to the panel on the overlay role while the pill's face fades out and the rows fade in; the highlight glides on the select role; checks draw on the toggle role; the label flies or rolls on the morph role.
- While held open the panel appears at once, so the rows sit still under the finger.
- Reduce Motion: the frame fades instead of springing, the label fades in and the highlight jumps.
Performance
- The panel mounts only while open, in the overlay layer at a fixed order; its height is measured from a copy laid out off-screen.
Notes for AI
- Options are `SelectionOption`s (icon, detail, group, keywords, disabledReason). Needs `OverlayProvider` at the app root.
- Dropdown's `variant="morph"` renders Morph select.
Compatibility
| Runs on | Supported |
|---|---|
| Expo SDK 57 | Yes |
| Expo SDK 58 | Yes |
| React Native CLI (with Expo modules) | Yes |
| Expo Go | Yes |
| iOS | Yes |
| Android | Yes |
This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.