Skip to main content

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​

Storybook

Live Preview​

Storybook

Custom Swatches​

Storybook

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​

VariantWhat it is
currentPractice setting tag.
no permissionApply 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​

PropTypeDefaultDescription
stylesStyleChooserOption[]the five CareOS themesArray<{id, name, who, swatch?, current?}>
valuestringundefinedPreviewed style id (controlled)
defaultValuestring'classic'Initially previewed style id (uncontrolled)
onChange(id: string) => voidnoneCalled with the style id when Preview is chosen
canApplybooleanfalseEnables "Apply to practice" (admins only)
onApply(id: string) => voidnoneCalled with the style id when "Apply to practice" is chosen
labelstring"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>
KindNameDescription
property / JSON attributestylesArray<{id, name, who, swatch?, current?}>; default the five CareOS themes
attributevaluePreviewed style id (controlled); default undefined
attributedefault-value / defaultValueInitially previewed style id (uncontrolled); default 'classic'
attributecan-apply / canApplyEnables "Apply to practice" (admins only); default false
attributelabelAccessible name of the radio group; default "App style"
attributedefault-checked / defaultChecked
attributeauto-focus / autoFocus
eventco-changeCalled with the style id when Preview is chosen; default none (React: onChange)
eventco-applyCalled with the style id when "Apply to practice" is chosen; default none (React: onApply)