Skip to content
SuperCoach

Components · Inputs

Select

Beta

Picks one option from a short list, such as a program goal.

When to use

  • To pick one option from a list of about 5 to 15: a program goal, a currency, a check-in frequency.

When not to use

  • 2 to 4 options that should all be visible: use a Radio group.
  • Long or searchable lists such as the exercise library: use a combobox.
  • To choose several options: use checkboxes.
  • For actions ("Duplicate", "Archive"): use a dropdown menu.

Anatomy

  1. 1. Label
  2. 2. Trigger: shows the current value and a chevron
  3. 3. Listbox (opens from the trigger; try it): options, optional group labels, a check on the selected option

Variants

One style. Group long lists with SelectGroup and SelectLabel, as in the example above, and disable options that exist but can't be chosen yet.

States

Choose the currency for this package.

StateWhat changesToken
Focus-visibleRing around the triggerring-ring/50
OpenListbox in popover with shadow-md, on the dropdown layerbg-popover, z-(--z-dropdown)
Highlighted optionAccent fillbg-accent, text-accent-foreground
DisabledHalf opacityopacity-(--opacity-disabled)
InvalidRed border, error textborder-destructive, text-destructive-text

Usage guidelines

  • Order options in a way coaches expect: by frequency, then alphabetically. Don't sort numbers as text.
  • Use a placeholder only when no default makes sense, and phrase it as an instruction: "Choose a goal".
  • Don't use a select for "Yes / No": use a switch or checkbox.

Content guidelines

  • Options are short nouns, sentence case, no ending punctuation.
  • Keep option text unique within the list, so type-ahead works.

Accessibility

KeyDoes
Enter, Space, Arrow downOpens the list
Arrow up / downMoves through options
Type a letterJumps to the next option starting with it
EnterSelects and closes
EscapeCloses without changing the value
  • The trigger is a combobox linked to its label; the list is a listbox. A screen reader announces "Program goal, combobox, Choose a goal".
  • Focus returns to the trigger on close.

RTL

  • The chevron sits at the end and the check mark at the end of each option, so both move to the left.
  • The list aligns to the trigger's start edge.

Tokens used

Read from components/ui/select.tsx at build time, so this list changes when the component does. Opacity modifiers such as /90 are shadcn hover and focus tints on top of the token.

Semantic color tokens used by this component
TokenUtilitiesSuperCoachCoach
--accentbg-accentbrand-50orange-50
--accent-foregroundtext-accent-foregroundbrand-700orange-700
--borderbg-borderneutral-200neutral-200
--destructiveborder-destructive ring-destructive/20red-600red-600
--inputborder-inputneutral-200neutral-200
--muted-foregroundtext-muted-foregroundneutral-600neutral-600
--popoverbg-popoverwhitewhite
--popover-foregroundtext-popover-foregroundneutral-950neutral-950
--ringborder-ring ring-ring/50brand-600orange-500
  • Layerz-(--z-dropdown)
  • Opacityopacity-(--opacity-disabled)
  • Radiusrounded-md
  • Radiusrounded-sm
  • Shadowshadow-md
  • Shadowshadow-xs
  • Typetext-sm
  • Typetext-xs

Props

<Select>

Also takes every prop of Radix Select.Root

No props of its own.

<SelectGroup>

Also takes every prop of Radix Select.Group

No props of its own.

<SelectTrigger>

Also takes every prop of Radix Select.Trigger

SelectTrigger props
PropTypeDefault
size?"sm" | "default""default"

<SelectContent>

Also takes every prop of Radix Select.Content

No props of its own.

<SelectLabel>

Also takes every prop of Radix Select.Label

No props of its own.

<SelectItem>

Also takes every prop of Radix Select.Item

No props of its own.

Replaces in coach-admin

From the read-only audit of coach-admin: 97 style values, 147 uses.

coach-admin mixes its own select, a dropdown list and antd's Select; all three become this component.

Classes and selectors

  • .select__options5
  • .select__option-icon3
  • .ant-select.ant-select-focused .ant-select-selector2
  • .select__option-label1
  • .ant-select, .ant-select-dropdown1
  • .ant-select-selector1
  • .ant-select:not(.ant-select-customize-input) .ant-select-sel1
  • .ant-select-dropdown1
  • .select__wrapper1

Files

  • src/reusableComponents/formComponents/select/select.scss93
  • src/reusableComponents/formComponents/dropdown-list/dropdown-list.scss38
  • src/reusableComponents/formComponents/dropdown-list/DropdownList.tsx2

The inventory lists the first 12 locations of each value, so file counts are a lower bound.

SCSS variables in these styles

  • $primary-color→ --primary

Radio group, Input, Checkbox.