Skip to main content

SplitButton

BasicActions<co-split-button>

SplitButton pairs a main action with a menu of related ones, such as Submit Claim with Submit and Print.

import { SplitButton } from 'health-components';

Examples​

Showcase​

Storybook

Secondary​

Storybook

Small​

Storybook

Disabled​

Storybook

Usage​

<SplitButton label="Submit Claim" onClick={submit}
items={[{ label: "Submit and Print CMS-1500", onSelect: submitPrint }, { label: "Save as Draft", onSelect: saveDraft }]} />

When to use​

  • One action is clearly the default and two to five variations exist: Submit Claim, Submit and Print, Save as Draft.

When not to use​

  • The options are equally likely: use separate buttons.
  • The menu holds unrelated actions: use a KebabMenu.

Variants and states​

VariantWhat it is
primaryMain action filled.
secondaryOutlined, for less important groups such as Export.
openMenu shown; closes on Escape or outside click.

Accessibility​

  • The arrow is its own button with aria-haspopup="menu" and aria-expanded.
  • Escape closes the menu.

Do and don't​

  • Do: "Submit Claim" with "Submit and Print CMS-1500" and "Save as Draft" in the menu.
  • Don't: Hiding "Void Claim" in a split menu under "Submit Claim".

Props​

PropTypeDefaultDescription
label *string—Main action label ("Submit Claim"); required
onClick(event: MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => voidnoneRuns the main action
items *MenuItem[]—Related actions in the menu: Array<{label, hint?, icon?, danger?, disabled?, onSelect?}>; required
variant'primary' | 'secondary''primary''primary' | 'secondary'
size'sm' | 'md''md''sm' | 'md'
menuLabelstring"More options"aria-label of the arrow button
defaultOpenbooleanfalseOpen on first render (uncontrolled)
openbooleanundefined (uncontrolled)Controlled open state of the menu
onOpenChange(open: boolean) => void—Called when the menu opens or closes
onItemSelect(item: MenuActionItem, index: number) => voidnoneCalled with the chosen item and its index, after the item's own onSelect (one handler for every item)
disabledbooleanfalseDisables both halves
alignMenuAlign'right''right' | 'left': menu alignment
classNamestring—Class on the wrapper

Every component also accepts className.

Angular, Vue and HTML​

Register the elements once (Angular guide), then use <co-split-button>. 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-split-button label="…" variant="…" [items]="items" (co-click)="onClick($event.detail)"></co-split-button>
KindNameDescription
attributelabelMain action label ("Submit Claim"); required
property / JSON attributeitemsRelated actions in the menu: Array<{label, hint?, icon?, danger?, disabled?, onSelect?}>; required
attributevariant'primary' | 'secondary'; default 'primary'
attributesize'sm' | 'md'; default 'md'
attributemenu-label / menuLabelaria-label of the arrow button; default "More options"
attributedefault-open / defaultOpenOpen on first render (uncontrolled); default false
attributeopenControlled open state of the menu; default undefined (uncontrolled)
attributedisabledDisables both halves; default false
attributealign'right' | 'left': menu alignment; default 'right'
attributeclass-name / classNameClass on the wrapper
eventco-clickRuns the main action; default none (React: onClick)
eventco-open-changeCalled when the menu opens or closes (React: onOpenChange)
eventco-item-selectCalled with the chosen item and its index, after the item's own onSelect (one handler for every item); default none (React: onItemSelect)