$ rezi
Widgets

Select

A focusable dropdown selection widget for choosing one value from a list of options.

A focusable dropdown selection widget for choosing one value from a list of options.

Usage

import { ui } from "@rezi-ui/core";

ui.select({
  id: "theme",
  value: state.theme,
  options: [
    { value: "dark", label: "Dark" },
    { value: "light", label: "Light" },
  ],
  onChange: (value) => app.update((s) => ({ ...s, theme: value })),
  placeholder: "Choose a theme…",
});

Props

PropTypeDefaultDescription
idstringrequiredUnique identifier for focus and event routing
valuestringrequiredCurrently selected value
options{ value: string; label: string }[]requiredAvailable options
onChange(value: string) => void-Called when selection changes
disabledbooleanfalseDisable focus and interaction
placeholderstring-Text shown when no matching option label is found
keystring-Reconciliation key

Behavior

  • Focusable when enabled.
  • Mouse click focuses the select widget.
  • Navigate options with ArrowUp/ArrowDown.
  • Confirm selection with Enter.
  • Tab / Shift+Tab moves focus to the next/previous widget.

Examples

1) With a field wrapper

import { ui } from "@rezi-ui/core";

ui.field({
  label: "Theme",
  children: ui.select({
    id: "theme",
    value: state.theme,
    options: [
      { value: "dark", label: "Dark" },
      { value: "light", label: "Light" },
    ],
    onChange: (v) => app.update((s) => ({ ...s, theme: v })),
  }),
});

2) Disabled state

import { ui } from "@rezi-ui/core";

ui.select({
  id: "country",
  value: "us",
  options: [{ value: "us", label: "United States" }],
  disabled: true,
});

On this page