Icon button
A square button that shows only an icon. It needs a label for screen readers, and comes in solid, soft, outline and ghost styles.
// Plain markup
import { IconButton } from "@shavin/ui";Variants (tone=brand)
Component Source
import { IconButton } from "@shavin/ui";
import { Plus } from "lucide-react";
<IconButton variant="solid" aria-label="Add"><Plus className="h-full w-full" /></IconButton>
<IconButton variant="soft" aria-label="Add"><Plus className="h-full w-full" /></IconButton>
<IconButton variant="outline" aria-label="Add"><Plus className="h-full w-full" /></IconButton>
<IconButton variant="ghost" aria-label="Add"><Plus className="h-full w-full" /></IconButton>Tone=danger
Component Source
import { IconButton } from "@shavin/ui";
import { Trash2 } from "lucide-react";
<IconButton variant="solid" tone="danger" aria-label="Delete"><Trash2 className="h-full w-full" /></IconButton>
<IconButton variant="soft" tone="danger" aria-label="Delete"><Trash2 className="h-full w-full" /></IconButton>
<IconButton variant="outline" tone="danger" aria-label="Delete"><Trash2 className="h-full w-full" /></IconButton>
<IconButton variant="ghost" tone="danger" aria-label="Delete"><Trash2 className="h-full w-full" /></IconButton>Sizes
Component Source
import { IconButton } from "@shavin/ui";
import { Plus } from "lucide-react";
<IconButton size="sm" variant="soft" aria-label="Add"><Plus className="h-full w-full" /></IconButton>
<IconButton size="md" variant="soft" aria-label="Add"><Plus className="h-full w-full" /></IconButton>
<IconButton size="lg" variant="soft" aria-label="Add"><Plus className="h-full w-full" /></IconButton>Disabled
Component Source
import { IconButton } from "@shavin/ui";
import { Plus, Trash2 } from "lucide-react";
<IconButton disabled aria-label="Add"><Plus className="h-full w-full" /></IconButton>
<IconButton variant="ghost" disabled aria-label="Delete" tone="danger"><Trash2 className="h-full w-full" /></IconButton>Loading and disabled with a reason
Same as Button: loading swaps the icon for a spinner; disabledReason stays focusable and explains itself in a Tooltip.
Only owners can delete projects
Component Source
<IconButton aria-label="Add" loading><Plus className="h-full w-full" /></IconButton>
<IconButton variant="ghost" tone="danger" aria-label="Delete" disabledReason="Only owners can delete projects"><Trash2 className="h-full w-full" /></IconButton>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| loading | boolean | — | Mandatory ARIA accessible label string for screen reader name computation. */ "aria-label": string; children: ReactNode; /** Pending state: a Spinner replaces the icon, `aria-busy`, clicks ignored, stays focusable, progress cursor. |
| loadingLabel | string | — | Optional text announced (polite) when `loading` starts. |
| disabledReason | string | — | Why the action is unavailable. Renders `aria-disabled` (focusable) with the reason in a Tooltip on hover, focus and tap, and as the accessible description. Takes precedence over `disabled`. |
| variant | "solid" | "soft" | "outline" | "ghost" | "solid" | — |
| tone | "brand" | "danger" | "brand" | — |
| size | "sm" | "md" | "lg" | "md" | — |