StyleChooser
BasicLayout
<co-style-chooser>StyleChooser picks the practice style (Classic, Clinical Sidebar, Focus Rail, Command Bar) with Preview and Apply to practice.
import { StyleChooser } from 'health-components';
Examples
No Permission
Live Preview
Custom Swatches
Usage
<StyleChooser canApply={isAdmin} value={previewed} onChange={setPreviewed} onApply={savePracticeStyle} />
<StyleChooser canApply={isAdmin} styles={STYLES} defaultValue="classic" />
When to use
- Settings, Appearance.
When not to use
- Per-user theme switches elsewhere.
Variants and states
| Variant | What it is |
|---|---|
| current | Practice setting tag. |
| no permission | Apply disabled; Preview still works. |
Accessibility
- Preview buttons carry radio semantics.
Do and don't
- Do: Say who each style suits.
- Don't: Apply without a preview.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
styles | StyleChooserOption[] | the five CareOS themes | Array<{id, name, who, swatch?, current?}> |
value | string | undefined | Previewed style id (controlled) |
defaultValue | string | 'classic' | Initially previewed style id (uncontrolled) |
onChange | (id: string) => void | none | Called with the style id when Preview is chosen |
canApply | boolean | false | Enables "Apply to practice" (admins only) |
onApply | (id: string) => void | none | Called with the style id when "Apply to practice" is chosen |
label | string | "App style" | Accessible name of the radio group |
Also accepts native attributes, including defaultChecked, autoFocus, plus className and event handlers on the root element.
Angular, Vue and HTML
Register the elements once (Angular guide), then use <co-style-chooser>. 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-style-chooser value="…" default-value="…" [styles]="styles" (co-change)="onChange($event.detail)"></co-style-chooser>
| Kind | Name | Description |
|---|---|---|
| property / JSON attribute | styles | Array<{id, name, who, swatch?, current?}>; default the five CareOS themes |
| attribute | value | Previewed style id (controlled); default undefined |
| attribute | default-value / defaultValue | Initially previewed style id (uncontrolled); default 'classic' |
| attribute | can-apply / canApply | Enables "Apply to practice" (admins only); default false |
| attribute | label | Accessible name of the radio group; default "App style" |
| attribute | default-checked / defaultChecked | |
| attribute | auto-focus / autoFocus | |
| event | co-change | Called with the style id when Preview is chosen; default none (React: onChange) |
| event | co-apply | Called with the style id when "Apply to practice" is chosen; default none (React: onApply) |