SwipeUI

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-select
Variant
Preset
Material
Scheme
Feel
Real free component with a browser animation bridge. Native motion, haptics and materials need a device.

When 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.ts and 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 install so versions match your SDK.

Usage

app/places.tsx
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

PropTypeDefaultDescription
labelstring—

The spoken name ("Sort by"); the pill shows the chosen label.

optionsreadonly MorphSelectOption<T>[]—

The options, in order. Group them with group and groups.

groups?readonly SelectionGroup[]—

Group headings, in order.

value?T | null—

The chosen value (controlled); null means nothing is chosen.

defaultValue?T | nullnull

The value it starts with (uncontrolled).

onValueChange?((value: T | null) => void)—

Reports a pick.

placeholder?string'Choose'

Shown in the pill with nothing chosen.

align?"end" | "start"'start'

Which edge of the pill the panel grows from: start (the reading direction's start) or end.

maxTriggerWidth?number240

The pill's widest size before its label truncates, in points.

panelWidth?number280

The open panel's width, in points; it's never narrower than the pill.

maxPanelHeight?number360

The open panel's tallest height before its list scrolls, in points.

search?"always" | "auto" | "never"'auto'

A search field at the top of the panel: auto above 8 options, always or never.

pressDragRelease?booleantrue

★ Hold the pill, drag over the rows (a tick each) and release to pick.

holdDelay?number350

How long the finger rests before the panel opens, in milliseconds (content timing).

swipeToClose?booleantrue

★ Swipe the open panel's handle down to close it without picking.

typeahead?booleantrue

On the web, letters on the pill pick the next match.

size?"lg" | "md" | "sm"'md'

The pill's height: sm 36pt, md 44pt, lg 52pt.

shape?"pill" | "preset"'pill'

pill (a capsule) or preset (the preset's control corners).

disabled?booleanfalse

No opening or picking.

messages?(Partial<SelectionMessages> & { placeholder?: string; })SELECTION_MESSAGES (English)

Built-in strings, for translation.

haptics?boolean | SelectionHapticstrue

Haptics: a switch, or per part (select for picks and drag ticks).

motion?MotionOverridethe app's feel

Morph, highlight and label motion (overlay, select, morph roles).

className?string—

Classes on the pill.

style?StyleProp<ViewStyle>—

Pill style.

testID?string—

The pill's identifier; the panel appends -panel, rows -option-<value>, the search -search.

Composition and behavior

  • Tap the pill: one frame springs from the pill to the panel, growing from the align edge (start follows 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 are SelectionOptions from selection-core.

Morph select settings

PropDoesDefault
labelThe spoken name ("Sort by")required
options / groupsOptions and group headingsnone
value / defaultValueThe chosen valuenull
placeholderThe pill with nothing chosenChoose
alignGrow from the pill's start or endstart
maxTriggerWidthThe pill's widest size (pt)240
panelWidth / maxPanelHeightThe panel's width and tallest height (pt)280, 360
searchauto (above 8), always or neverauto
pressDragRelease / holdDelay★ Hold, drag and release (ms to hold)true, 350
swipeToClose★ Swipe the handle down to closetrue
typeaheadLetters pick on the webtrue
size / shapesm/md/lg; pill or presetmd, pill
disabledNo openingfalse
hapticsAll, or { select }on
messagesSearch and list stringsEnglish

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, morph and press motion roles, so it follows your app's feel. Pass motion to 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 onSupported
Expo SDK 57Yes
Expo SDK 58Yes
React Native CLI (with Expo modules)Yes
Expo GoYes
iOSYes
AndroidYes

This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.

Related items