SpaceMIX v0.1.0 (latest)

UI kit - Pickers

experimentalfor bothsince protocol 1

The @spacemix/ui dropdown and date controls - Select, MultiSelect, Combobox, TimePicker, Calendar, DatePicker and DateRangePicker - with their option types, props and keyboard behaviour.

Controls that pick from a list or a calendar in a floating layer, styled like the app's fields. Source: packages/ui/src/popovers.tsx. They sit in a Field like any other control: they take its id, description, error, required (as aria-required, since the field is a button) and disabled. Their lists are layers of the dismiss stack and render through a portal, so a scroll area doesn't clip them; a list opened from a dialog sits above it.

Every component takes the native props of its field element (a <button>, or the <input> for Combobox), className joined last and ref. A width class in className replaces the default full width. The conventions apply.

Stability: experimental, every export on this page: new in this release, and names and props may still be adjusted before they are promised.

Options

interface SelectOption {
  value: string;
  label: string;          // also what typeahead and filtering match
  description?: string;   // a second, quieter line
  icon?: ReactNode;       // a lucide icon, sized to 16 px
  disabled?: boolean;
}

interface SelectOptionGroup { label: string; options: SelectOption[] }

type SelectOptions = (SelectOption | SelectOptionGroup)[];  // flat or in groups, mixed is fine

SelectOption, SelectOptionGroup and SelectOptions are what Select, MultiSelect and Combobox take.

Select

A dropdown for picking one value from a list: options with icons and descriptions, groups, disabled options, a placeholder, sizes and an invalid state. The keyboard follows the WAI-ARIA select-only combobox: the arrows open the list and move, typing jumps to an option, Enter picks, Escape closes. Focus stays on the field, which points at the active option.

Prop Type Default What it does
options SelectOptions required The options.
value string | null none The chosen value (controlled); null for none.
defaultValue string | null null The starting value when uncontrolled.
onChange (value: string | null) => void none Called with the picked value. Typed like value, so a useState<string | null> setter fits; picking never gives null.
placeholder string "Select…" Shown while nothing is chosen.
invalid boolean none A danger border and aria-invalid.
size Size "md" The height of Input at the same size.
icon ReactNode none A leading icon in the field.
name string none With a name, a hidden input carries the value in a form.
required boolean none Marks it required.
open, defaultOpen, onOpenChange boolean, boolean, (open: boolean) => void defaultOpen false The list's open state.
empty ReactNode "No options" Shown when there are no options.
<Field label="Status">
  <Select options={[{ value: "open", label: "Open" }, { value: "done", label: "Done" }]} value={status} onChange={setStatus} />
</Field>

SelectProps is the props type.

MultiSelect

A dropdown for picking several values: checkbox options that stay open while the person picks, the chosen ones as tags in the field. The same options, groups, sizes and keyboard as Select; Enter and Space toggle. Takes Select's props except value, defaultValue, onChange and icon.

Prop Type Default What it does
value string[] none The chosen values (controlled).
defaultValue string[] [] The starting values when uncontrolled.
onChange (value: string[]) => void none Called with the chosen values.
maxShown number 2 How many chosen labels show in the field before "+N".

MultiSelectProps is the props type.

TimePicker

A time of day from a list at a fixed step, labelled the way the locale writes times. The value is "HH:mm", 24-hour. A Select underneath, so typing "9" jumps to 9:00. Takes Select's props except options and icon; placeholder defaults to "Pick a time".

Prop Type Default What it does
step number 15 Minutes between choices.
min string "00:00" The earliest choice, "HH:mm".
max string "23:59" The latest choice, "HH:mm".
locale string the browser's For the labels.
hour12 boolean the locale's habit 12-hour labels.

TimePickerProps is the props type.

Combobox

A text field with a list of matching options: type to filter, the arrows move, Enter picks, and optionally create what was typed. To search a server as the person types, control inputValue (or use onInputChange), pass filter={false} and set loading while results are on their way. Leaving the field puts the chosen option's label back. Takes the <input>'s props except value, defaultValue, onChange and size; placeholder defaults to "Search…". className goes on the field around the input, ref to the input.

Prop Type Default What it does
options SelectOptions required The options.
value string | null none The chosen value (controlled); null for none.
defaultValue string | null null The starting value when uncontrolled.
onChange (value: string | null) => void none Called with the chosen value, or null when cleared.
inputValue string none The text in the field (controlled).
defaultInputValue string none The starting text when uncontrolled.
onInputChange (text: string) => void none Called with the text as it is typed.
filter ((option: SelectOption, text: string) => boolean) | false every word appears in the label or description Which options match the text. false shows options as given (they are already the server's results).
loading boolean none Shows a loading row.
empty ReactNode "No results" Shown when nothing matches.
onCreate (text: string) => void none Offers to create the typed text when no option has exactly that label.
createLabel (text: string) => string (t) => `Create “${t}”` The create row's label.
invalid boolean none A danger border and aria-invalid.
size Size "md" As on Input.
clearable boolean true A ✕ that clears the text and the value.
open, defaultOpen, onOpenChange boolean, boolean, (open: boolean) => void defaultOpen false The list's open state.

ComboboxProps is the props type.

Calendar, DateRange

interface DateRange { start: Date | null; end: Date | null }  // end is null until the second day is picked

type CalendarProps = CalendarBaseProps &
  ( | { mode?: "single"; value?: Date | null; defaultValue?: Date | null; onChange?: (date: Date) => void }
    | { mode: "range"; value?: DateRange; defaultValue?: DateRange; onChange?: (range: DateRange) => void } );

A month grid for picking a day or a range of days, inline on the page. The keyboard follows the WAI-ARIA date grid: the arrows move a day or a week, Home and End go to the week's ends, Page Up and Page Down change month (with Shift, year), Enter picks.

Prop Type Default What it does
mode "single" | "range" "single" One day, or a DateRange. Sets the type of value, defaultValue and onChange.
value, defaultValue, onChange by mode none The chosen day or range. In single mode onChange only ever gets a picked day: a Calendar can't clear its value (DatePicker's Clear does that).
month Date none The month shown, any day in it (controlled).
defaultMonth Date none The starting month when uncontrolled.
onMonthChange (month: Date) => void none Called when the month changes.
min Date none The earliest pickable day.
max Date none The latest pickable day.
isDateDisabled (date: Date) => boolean none Days that can't be picked (weekends, booked days).
weekStartsOn 0 | 1 | 2 | 3 | 4 | 5 | 6 1 (Monday) 0 is Sunday.
locale string the browser's For month and day names.
autoFocus boolean none Focuses the selected (or today's) day on mount.

lucide-react also has a Calendar icon; import it as CalendarIcon.

DatePicker

A date field: a button that shows the chosen day and opens a Calendar in a popover, with Today and Clear. Picking a day closes it and focus goes back to the field.

Prop Type Default What it does
value Date | null none The chosen day (controlled).
defaultValue Date | null null The starting day when uncontrolled.
onChange (date: Date | null) => void none Called with the day, or null when cleared.
format (date: Date) => string the locale's medium date ("Oct 28, 2026") How the field writes the date.
placeholder string "Pick a date" Shown while empty.
min, max, isDateDisabled, weekStartsOn, locale as on Calendar as on Calendar Passed to the calendar; locale also writes the field's text.
invalid boolean none A danger border and aria-invalid.
size Size "md" As on Input.
clearable boolean true A Clear button under the calendar while there is a value.
name string none With a name, a hidden input carries the value in a form as yyyy-mm-dd.
open, defaultOpen, onOpenChange boolean, boolean, (open: boolean) => void defaultOpen false The popover's open state.

DatePickerProps is the props type.

DateRangePicker

A field for a span of days: it opens a Calendar in range mode, previews the span under the pointer, and closes once the second day is picked. It takes the same props as DatePicker except:

Prop Type Default What it does
value DateRange none The chosen range (controlled).
defaultValue DateRange { start: null, end: null } The starting range when uncontrolled.
onChange (range: DateRange) => void none Called with the range.
format (range: { start: Date; end: Date }) => string the locale's ("Oct 3 – 9, 2026") How the field writes the range.
placeholder string "Pick dates" Shown while empty.
name string none Two hidden inputs, name and name + End, as yyyy-mm-dd.

DateRangePickerProps is the props type.

This page as markdown · All pages as one file