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
Variants
Sizes
With Badge
Disabled
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
| Variant | What it is |
|---|---|
| ghost | Default. Muted icon, grey hover. |
| secondary | Bordered, for standalone toolbar buttons. |
| primary | Filled, rare: the compose button on mobile. |
| danger | Red icon for remove-row actions. |
| sizes | sm 30px, md 34px, lg 44px (touch). |
| badge | Count bubble, for example unread notifications. |
Accessibility
labelis 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
| Prop | Type | Default | Description |
|---|---|---|---|
icon * | IconName | — | Icon name (see Icon); required |
label * | string | — | Accessible name: becomes aria-label and the hover title; required |
variant | IconButtonVariant | 'ghost' | 'ghost' | 'secondary' | 'primary' | 'danger' |
size | IconButtonSize | 'md' | 'sm' 30px, 'md' 34px, 'lg' 44px (touch) |
badge | number | string | none | Count bubble, read as "N unread" |
disabled | boolean | false | Disables 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>
| Kind | Name | Description |
|---|---|---|
| attribute | icon | Icon name (see Icon); required |
| attribute | label | Accessible name: becomes aria-label and the hover title; required |
| attribute | variant | 'ghost' | 'secondary' | 'primary' | 'danger'; default 'ghost' |
| attribute | size | 'sm' 30px, 'md' 34px, 'lg' 44px (touch); default 'md' |
| property / JSON attribute | badge | Count bubble, read as "N unread"; default none |
| attribute | disabled | Disables the button; default false |
| attribute | default-checked / defaultChecked | |
| property / JSON attribute | default-value / defaultValue | |
| attribute | auto-focus / autoFocus | |
| attribute | type | |
| attribute | name | |
| property / JSON attribute | value |