Skip to main content

Select

BasicInputs<co-select>

Select picks one value from a short fixed list, such as Provider, Location or Status filters.

import { Select } from 'health-components';

Examples​

Showcase​

Storybook

With Placeholder​

Storybook

Small​

Storybook

Read Only​

Storybook

Usage​

<Select label="Provider" options={["All", ...providers]} value={provider} onChange={e => setProvider(e.target.value)} />

When to use​

  • Up to about 15 known options.

When not to use​

  • Long or searchable lists (patients, codes, payers): Combobox.
  • Two to four options shown at once: SegmentedControl or RadioGroup.

Variants and states​

VariantWhat it is
defaultNative select with a chevron.
sm30px, for table toolbars and rows-per-page.
errorRed border and message.
readOnlyDisabled with lock icon and lock line.

Accessibility​

  • Native select keeps platform keyboard and screen reader behaviour.

Do and don't​

  • Do: "All" as the first option of a filter.
  • Don't: A select with one option.

Props​

PropTypeDefaultDescription
label *string—Visible label; required
options *Array<string | SelectOption>—Array<string | {value, label}>; required
placeholderstringnoneText of a first empty option ("Choose one")
size'sm' | 'md''md''sm' | 'md'
errorstringnoneError message (as TextField)
helperstringnoneMuted hint under the field (as TextField)
requiredbooleanfalseRed asterisk plus aria-required (as TextField)
readOnlybooleanfalseRead-only lock state: the select is disabled and a lock line explains why
lockMessagestring'Your role can view but not edit'Lock line text when readOnly
styleCSSProperties—Inline style of the root

Also accepts native attributes, including defaultChecked, defaultValue, autoFocus, onChange, onInput, disabled, name, value, autoComplete, multiple, plus className and event handlers on the root element.

Angular, Vue and HTML​

Register the elements once (Angular guide), then use <co-select>. Attributes take strings; arrays and objects are set as properties (Angular [prop], Vue :prop) or as JSON attributes. Callbacks are DOM events with the value in event.detail.

Angular template
<co-select label="…" placeholder="…" [options]="options" (co-change)="onChange($event.detail)"></co-select>
KindNameDescription
attributelabelVisible label; required
property / JSON attributeoptionsArray<string | {value, label}>; required
attributeplaceholderText of a first empty option ("Choose one"); default none
attributesize'sm' | 'md'; default 'md'
attributeerrorError message (as TextField); default none
attributehelperMuted hint under the field (as TextField); default none
attributerequiredRed asterisk plus aria-required (as TextField); default false
attributeread-only / readOnlyRead-only lock state: the select is disabled and a lock line explains why; default false
attributelock-message / lockMessageLock line text when readOnly; default 'Your role can view but not edit'
property / JSON attributestyleInline style of the root
attributedefault-checked / defaultChecked
property / JSON attributedefault-value / defaultValue
attributeauto-focus / autoFocus
attributedisabled
attributename
property / JSON attributevalue
attributeauto-complete / autoComplete
attributemultiple
eventco-change (React: onChange)
eventco-input (React: onInput)