Skip to main content

IconButton

BasicActions<co-icon-button>

IconButton is a square button that shows only an icon, with its name in aria-label.

import { IconButton } from 'health-components';

Examples​

Showcase​

Storybook

Variants​

Storybook

Sizes​

Storybook

With Badge​

Storybook

Disabled​

Storybook

Usage​

<IconButton icon="x" label="Close" onClick={onClose} />
<IconButton icon="bell" label="Notifications" badge={4} />

When to use​

  • Close a modal or drawer, open notifications, collapse a panel, expand a table row.
  • Toolbars where the icon is universally known (print, close, search).

When not to use​

  • The action is unusual or risky: use a Button with a text label.
  • More than three icon buttons in a row: use a KebabMenu.

Variants and states​

VariantWhat it is
ghostDefault. Muted icon, grey hover.
secondaryBordered, for standalone toolbar buttons.
primaryFilled, rare: the compose button on mobile.
dangerRed icon for remove-row actions.
sizessm 30px, md 34px, lg 44px (touch).
badgeCount bubble, for example unread notifications.

Accessibility​

  • label is required. It becomes aria-label and the hover title.
  • The badge count is read as "N unread".
  • Use lg (44px) on phone screens to meet the touch target.

Do and don't​

  • Do: label="Close developer panel" on the drawer close button.
  • Don't: A pencil icon alone for "Edit Demographics" in a patient banner: the text matters there.

Props​

PropTypeDefaultDescription
icon *IconName—Icon name (see Icon); required
label *string—Accessible name: becomes aria-label and the hover title; required
variantIconButtonVariant'ghost''ghost' | 'secondary' | 'primary' | 'danger'
sizeIconButtonSize'md''sm' 30px, 'md' 34px, 'lg' 44px (touch)
badgenumber | stringnoneCount bubble, read as "N unread"
disabledbooleanfalseDisables the button

Also accepts native attributes, including defaultChecked, defaultValue, autoFocus, type, name, value, plus className and event handlers on the root element.

Angular, Vue and HTML​

Register the elements once (Angular guide), then use <co-icon-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-icon-button icon="…" label="…" [badge]="badge"></co-icon-button>
KindNameDescription
attributeiconIcon name (see Icon); required
attributelabelAccessible name: becomes aria-label and the hover title; required
attributevariant'ghost' | 'secondary' | 'primary' | 'danger'; default 'ghost'
attributesize'sm' 30px, 'md' 34px, 'lg' 44px (touch); default 'md'
property / JSON attributebadgeCount bubble, read as "N unread"; default none
attributedisabledDisables the button; default false
attributedefault-checked / defaultChecked
property / JSON attributedefault-value / defaultValue
attributeauto-focus / autoFocus
attributetype
attributename
property / JSON attributevalue