Morph select
A trigger surface that morphs smoothly into an option list or a multi-input card.
import { MorphSelect } from '@uthereal/ui/morph-select'Morph select playground
Overview
MorphSelect is one continuous surface. Its compact trigger expands into an option list or a structured multi-input card without shifting surrounding layout. While open, the card continuously morphs its width and height when search filters options, collapsible sections toggle, conditional fields appear, or custom child inputs change size.
Use MorphSelect for single-value property pickers, compact filter popovers, and multi-field configuration cards. Use Multiselect when users need inline removable chips and free-text autocomplete directly inside a form field. Use Radio when all choices should remain visible on the page.
Usage
'use client'
import { MorphSelect } from '@uthereal/ui/morph-select'
export function RegionPicker() {
return (
<MorphSelect
label="Region"
defaultValue="eu-west"
items={[
{ value: 'us-east', label: 'US East', meta: '12 ms', icon: 'globe' },
{ value: 'eu-west', label: 'EU West', meta: '28 ms', icon: 'globe' },
{ value: 'ap-south', label: 'AP South', meta: '94 ms', icon: 'globe' },
]}
onValueChange={(value) => console.log(value)}
/>
)
}Pass items for Option List mode, sections for a serializable Multi-Input Card, or children / renderCard for arbitrary React inputs. In Option List mode, onValueChange reports the selected value and option object. In Card mode, onValuesChange and onApply report the field value map.
Examples
Option list with groups and search
Pass flat or grouped items. When searchable is "auto", a search bar replaces the trigger lid automatically above eight options. Choosing an option lifts its label out of the list into the trigger while the trigger springs to its new width.
Structured multi-input card
Pass sections to host multiple input kinds inside one morphing card. Fields and sections accept a when predicate so toggling a switch or picking an option reveals new inputs and morphs the card smoothly. Set commitMode="apply" to stage edits until the user clicks Apply.
Composable React children
Place any React inputs inside MorphSelect via children or renderCard. A microtask-batched ResizeObserver measures content changes and morphs the card dimensions automatically. Nested overlays such as date pickers or popovers inherit LayerContext, so interacting with them never closes the card.
'use client'
import { useState } from 'react'
import { MorphSelect } from '@uthereal/ui/morph-select'
export function CustomFilterCard() {
const [query, setQuery] = useState('')
const [urgentOnly, setUrgentOnly] = useState(false)
return (
<MorphSelect
label="Filters"
icon="filter"
cardTitle="Filter issues"
summary={urgentOnly ? 'Urgent only' : query || 'All issues'}
>
{({ close }) => (
<div style={{ display: 'grid', gap: 10 }}>
<input
type="text"
value={query}
placeholder="Search keyword"
onChange={(event) => setQuery(event.target.value)}
/>
<label style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
<input
type="checkbox"
checked={urgentOnly}
onChange={(event) => setUrgentOnly(event.target.checked)}
/>
Urgent only
</label>
<button type="button" onClick={() => close(true)}>
Done
</button>
</div>
)}
</MorphSelect>
)
}Polymorphic modes
| Mode | Activated by | Role & focus model | Best for |
|---|---|---|---|
| Option list | items | combobox trigger with listbox and aria-activedescendant | Compact single-value pickers with groups, icons, meta, and type-ahead |
| Structured card | sections | dialog card; focuses first focusable field on open | AI-generated or schema-driven multi-input filter and booking cards |
| Composable children | children or renderCard | dialog card wrapped in LayerContext | Hosting arbitrary @uthereal/ui inputs and custom interactive layouts |
Supported structured field kinds
| Kind | Value type | Key options |
|---|---|---|
choice | string | null | options, display ("list" | "pills"), searchable |
multi-choice | string[] | options, display ("list" | "pills"), maxSelected |
toggle | boolean | label, description, defaultValue |
text | string | placeholder, multiline, maxLength |
number | number | null | min, max, step, unit |
range | number | [number, number] | min, max, step, unit (tuple enables dual thumbs) |
date | string (ISO YYYY-MM-DD) | min, max, localized trigger summary |
tags | string[] | placeholder, maxTags, Enter/comma to add, Backspace to remove |
color | string (hex) | swatches, defaultValue |
divider | none | Visual separator with optional when predicate |
API reference
These serializable arguments and defaults come directly from the component schema.
| Argument | Type / default | Description |
|---|---|---|
label | stringDefault: "Select" | Visible label and accessible name. Name the information asked for, in sentence case. |
hideLabel | booleanDefault: false | Hide the label visually when the context already names the field. It is still announced. |
description | string— | Supporting text below the field, announced with it. Use it for format hints and constraints. |
error | string— | Validation message from your application. Setting it marks the field invalid; the message is linked to the field and announced politely. |
required | booleanDefault: false | Marks the field as required for assistive technology and shows an indicator. Your application validates the value. |
disabled | booleanDefault: false | Unavailable and removed from the tab order. A disabled field is not submitted with a form. |
name | string— | Native form field name, submitted with the value in a form. |
items | MorphSelectItem[]— | Flat or grouped options for Option List mode (matches Arc morph-select). Unique values, optional icons, meta, descriptions, and search keywords. |
sections | MorphCardSection[]— | Structured multi-input sections for Card mode. Supports choice, multi-choice, toggle, text, number, range, date, tags, color, and divider fields with optional conditional visibility (`when`). |
defaultValue | string | nullDefault: null | Initial selected option value in Option List mode. Use value and onValueChange for controlled state. |
defaultValues | Record<string, MorphFieldValue>— | Initial field-value overrides keyed by field id in Multi-Input Card mode. |
placeholder | stringDefault: "Select" | Example text while the field is empty. Never a substitute for the label. |
summary | string— | Explicit closed-trigger summary text. Useful when rendering custom React children. |
summaryTemplate | string— | Template interpolating committed card values into the closed trigger, e.g. "{guests} guests · {region}". |
showActiveCount | boolean— | Show a rolling badge pill on the trigger counting fields that differ from defaults (defaults true in Card mode). |
icon | plus | minus | x | check | pencil | trash-2 | copy | download | upload | share-2 | external-link | link | refresh-cw | rotate-ccw | search | filter | settings | ellipsis | ellipsis-vertical | eye | eye-off | lock | log-out | send | square | paperclip | mic | star | chevron-down | chevron-up | chevron-left | chevron-right | chevrons-up-down | arrow-left | arrow-right | arrow-up | arrow-down | menu | panel-left | maximize-2 | minimize-2 | file | file-text | folder | image | table | book-open | globe | calendar | code | message-square | sparkles | bot | user | brain | wrench | terminal | thumbs-up | thumbs-down | list-checks | info | circle-check | triangle-alert | circle-x | circle-help | clock | circle | circle-dashed | bell | loader-circle | mail | phone | chevrons-down-up | pipette | hash | bookmark | headphones | video | presentation | archive | circle-alert | sun | moon | monitor | command | folder-open | play | pause | file-image | file-play | file-archive | message-circle | check-check | circle-dot | smile-plus | corner-down-right | rotate-cw | file-code-corner | copy-plus | pin | git-pull-request | git-merge | git-pull-request-closed | file-diff | sun-moon | user-round | credit-card | calendar-days | signal-high | camera | image-plus | heart | bell-off— | Optional curated leading icon displayed on the closed trigger. |
cardTitle | string— | Header title that crossfades into the morphing lid when open in Card mode. |
cardSubtitle | string— | Optional secondary copy shown beside cardTitle inside the open lid. |
commitMode | live | applyDefault: "live" | live updates values immediately; apply stages edits inside the card and renders a Reset / Cancel / Apply footer. |
searchable | boolean | 'auto'Default: "auto" | Show search in the open lid in Option List mode; "auto" enables search above 8 options. |
searchPlaceholder | string— | Placeholder inside the open search input. |
panelWidth | number | 'auto'Default: "auto" | Expanded surface width in px, or "auto" (272px in Option mode; content-fitted in Card mode). Never narrower than the trigger. |
maxHeight | integerDefault: 320 | Maximum scrollable body height in px before internal vertical scrolling starts. |
align | start | center | endDefault: "start" | Horizontal edge of the trigger that stays stationary while the surface morphs. |
side | auto | bottom | topDefault: "auto" | Preferred vertical expansion side; auto flips upward when space below is limited. |
portal | booleanDefault: false | Render the expanded surface in a ThemedPortal to escape overflow-hidden ancestors. |
applyAction | string— | Host action reported when Apply commits card edits. |
resetAction | string— | Host action reported when Reset restores card defaults. |
labels | MorphSelectLabelsDefault: {"apply":"Apply","cancel":"Cancel","reset":"Reset","search":"Search {label}","clearSearch":"Clear search","close":"Close {label}","noMatches":"No matches for \"{query}\"","resultsCount":"{count} options","singleResult":"1 option","activeCount":"{count} active","applied":"Changes applied","resetDone":"Filters reset"} | Accessible and UI labels for buttons, search, and announcements. |
variant | outline | soft | ghostDefault: "outline" | Field surface: outline for forms, soft on busy surfaces, ghost for inline editing without a border. |
size | sm | md | lgDefault: "md" | Field height and text size: 32, 36, or 46 pixels. Matches the button and dropdown trigger of the same size. |
locale | string— | BCP 47 locale for formatting summary numbers and dates; inherits UtherealProvider when omitted. |
recipe | studio | softDefault: "studio" | Visual treatment; both recipes keep identical morph physics. |
theme | MorphSelectTheme— | Color mode, accent, and design tokens including closedRadius and openRadius. |
motion | none | subtle | expressiveDefault: "subtle" | Morph, highlight, and label animation preset. System reduced motion takes precedence. |
motionOptions | MorphSelectMotionOptions— | Override morph, resize, glide, and fly transitions (durations in milliseconds). |
dir | ltr | rtl— | Reading direction; mirrors alignment and RTL geometry. Inherited when omitted. |
React integration
| Prop | Purpose |
|---|---|
value, onValueChange(value, option) | Control the chosen option in Option List mode. |
values, onValuesChange(values) | Control the field value map in Structured Card mode. |
onApply(values), onReset() | Receive Apply commits and Reset actions in Card mode. |
open, onOpenChange(open) | Control whether the morphing surface is expanded. |
onAction(action) | Handle applyAction and resetAction in your application. |
children, renderCard(ctx) | Render custom inputs inside the morphing card. |
renderTrigger(ctx) | Replace the closed trigger content while keeping morph sizing. |
renderHeader(ctx), renderFooter(ctx) | Replace the open card header or footer in Card mode. |
renderIcon(name, ctx) | Render a custom icon for trigger, option, or section slots. |
portalContainer | Explicit portal target when portal is enabled. |
ref, preset, tokens, className, style | Standard Uthereal root element and theming hooks. |
Keyboard & accessibility
| Key | Option list mode | Multi-input card mode |
|---|---|---|
Enter, Space | Open list, or commit the active option | Open card (when focused on trigger) |
ArrowDown, ArrowUp | Move highlight by one option (Alt+ArrowUp commits) | ArrowDown on trigger opens card |
PageDown, PageUp | Move highlight by 8 options | Native control navigation |
Home, End | Jump to first or last enabled option | Native control navigation |
| Printable characters | Open and filter (when searchable) or type-ahead jump | Native input entry |
Tab, Shift+Tab | Close list and move focus to the next control | Move sequentially across nested inputs |
Cmd+Enter, Ctrl+Enter | Ignored | Apply staged changes when commitMode="apply" |
Escape | Close list and restore focus to trigger | Close active nested layer first, then discard draft and restore focus |
A pre-mounted polite role="status" region announces option selections, search match counts, apply confirmations, and resets. Setting error links the message with aria-describedby and renders it as role="alert". Nested overlays opened inside the card receive a dedicated unclipped portal host via LayerContext, preventing premature outside-click dismissal. All spacing and alignment use logical CSS properties for right-to-left layouts, and @media (forced-colors: active) preserves borders and active selection contrast.
Motion and theming
Opening expands the trigger surface on a physical morph spring with slight bounce (morph). Live content resizes while open and closing folds use zero-bounce smooth springs (resize) so narrowing never overshoots or truncates labels. In Option List mode, the option highlight glides on pointer hover and snaps immediately on keyboard navigation, while the chosen label flies from its list row into the trigger slot.
Setting motion="none" makes all geometry and text updates immediate. Under prefers-reduced-motion: reduce, geometry snaps immediately with no blur or label flight while keeping a 120ms opacity crossfade.
theme accepts color mode, accent, global core/control/popupList/selectionControl tokens, plus closedRadius (defaults to a full pill) and openRadius (defaults to 22px).
Composition
In an agent composition, MorphSelect can act as a leaf (using items or sections) or as a container holding up to 24 allowed input and layout children. Selected state binds to fields.<id>.value (Option List mode) and fields.<id>.values (Card mode).
{
"type": "MorphSelect",
"props": {
"label": "Deployment filters",
"icon": "filter",
"cardTitle": "Filter deployments",
"commitMode": "apply",
"summaryTemplate": "{env} · {window}",
"sections": [
{
"id": "scope",
"title": "Scope",
"fields": [
{
"kind": "choice",
"id": "env",
"label": "Environment",
"display": "pills",
"defaultValue": "prod",
"options": [
{ "value": "prod", "label": "Production" },
{ "value": "staging", "label": "Staging" },
{ "value": "preview", "label": "Preview" }
]
},
{
"kind": "toggle",
"id": "onlyFailed",
"label": "Only failed runs",
"defaultValue": false
},
{
"kind": "range",
"id": "retries",
"label": "Minimum retries",
"min": 1,
"max": 10,
"defaultValue": 2,
"when": { "field": "onlyFailed", "equals": true }
}
]
}
]
},
"children": []
}