Build / Atoms
IconButton
A square (or round) button containing only an icon.
import { IconButton } from '@meetcard/deck'Example
<IconButton label="Share card" icon={<ShareIcon />} variant="ghost" />Stories
The label prop is the accessible name — the icon itself is hidden.
Source
const Default = () => <IconButton label="More actions" icon={<MoreIcon />} onClick={fn()} />;Every variant, in order of emphasis. ghost is the default for toolbars.
Source
const Variants = () => <Stack direction="row" gap={8} align="center">
<IconButton label="More actions" icon={<MoreIcon />} onClick={fn()} variant="ghost" />
<IconButton
label="More actions"
icon={<MoreIcon />}
onClick={fn()}
variant="secondary" />
<IconButton label="More actions" icon={<MoreIcon />} onClick={fn()} variant="primary" />
<IconButton
label="More actions"
icon={<MoreIcon />}
onClick={fn()}
variant="destructive" />
</Stack>;Every size, on the same 32/40/48px grid as Button.
Source
const Sizes = () => <Stack direction="row" gap={8} align="center">
<IconButton label="More actions" icon={<MoreIcon />} onClick={fn()} size="sm" />
<IconButton label="More actions" icon={<MoreIcon />} onClick={fn()} size="md" />
<IconButton label="More actions" icon={<MoreIcon />} onClick={fn()} size="lg" />
</Stack>;Round suits avatar overlays and floating actions.
Source
const Round = () => <IconButton
label="More actions"
icon={<MoreIcon />}
onClick={fn()}
round
variant="secondary" />;Disabled. The label still names the action for a screen reader.
Source
const Disabled = () => <IconButton label="More actions" icon={<MoreIcon />} onClick={fn()} disabled />;Props
| Prop | Type | Default | Description |
|---|---|---|---|
iconrequired | ReactNode | — | The icon itself. Rendered aria-hidden — label is the name. |
labelrequired | string | — | Accessible name, required. An icon alone announces as "button" to a screen reader, so Deck makes the label impossible to forget. |
round | boolean | false | Render as a circle. Good for avatars, overflow menus, and toolbars. |
size | 'sm' | 'md' | 'lg' | 'md' | — |
type | — | 'button' | — |
variant | 'primary' | 'secondary' | 'ghost' | 'destructive' | 'ghost' | — |
Also accepts everything from Omit, so id, data-* and event handlers pass straight through.