Skip to content

Forms

Select

tsx
"use client";
import { Field, Select } from "@cherry-design-system/react";

export function Country() {
  return (
    <Field label="Country">
      <Select name="country" placeholder="Select a country">
        <option value="al">Albania</option>
        <option value="de">Germany</option>
        <option value="it">Italy</option>
      </Select>
    </Field>
  );
}

A native <select> for picking one option from a short, fixed list. Where the browser supports appearance: base-select the picker is styled and animated too; elsewhere the OS picker opens. Use Combobox when the list is long and needs filtering.

Examples

Controlled

tsx
"use client";
import { useState } from "react";
import { Field, Select } from "@cherry-design-system/react";

export function Sort() {
  const [sort, setSort] = useState("newest");
  return (
    <Field label="Sort by">
      <Select size="sm" value={sort} onChange={(e) => setSort(e.target.value)}>
        <option value="newest">Newest</option>
        <option value="oldest">Oldest</option>
        <option value="name">Name</option>
      </Select>
    </Field>
  );
}

Option groups

tsx
"use client";
import { Field, Select } from "@cherry-design-system/react";

export function Timezone() {
  return (
    <Field label="Time zone" required>
      <Select name="tz" placeholder="Select a time zone">
        <optgroup label="Europe">
          <option value="Europe/Tirane">Tirana</option>
          <option value="Europe/Berlin">Berlin</option>
        </optgroup>
        <optgroup label="America">
          <option value="America/New_York">New York</option>
        </optgroup>
      </Select>
    </Field>
  );
}

Error

tsx
"use client";
import { Field, Select } from "@cherry-design-system/react";

export function Role() {
  return (
    <Field label="Role" error="Choose a role.">
      <Select placeholder="Select a role">
        <option value="admin">Admin</option>
        <option value="member">Member</option>
      </Select>
    </Field>
  );
}

Properties

size"sm" | "md" | "lg"

Control size. Defaults to "md".

invalidboolean

Error state; set automatically inside a <Field error>.

placeholderstring

Text shown while no option is chosen (an empty, unselectable option).

wrapperClassNamestring

Class for the outer wrapper (className goes to the <select>).

childrenReactNode

<option> and <optgroup> elements.

The ref and all native <select> attributes go to the <select>.

Styling

Root class cherry-select with data-size (sm, md, lg) and states data-invalid, data-disabled, data-placeholder, :open. Parts: cherry-select__control, cherry-select__chevron.

Reads the field tokens (--cherry-bg-canvas, --cherry-border-default, --cherry-border-focus, --cherry-ring) and, for the styled picker, --cherry-bg-elevated, --cherry-elevation-lg and --cherry-ghost-hover.

Accessibility

Native <select>: full keyboard and screen reader support. Label it like Input, with Field or aria-label.