Components / Inputs
IconButton
Square button holding one Lucide icon. Pass href to render a link: internal links go through your router's link (LinkProvider), http(s):// links open in a new tab.
import { IconButton } from "@stylhero/ui";
Example
Code
import { IconButton, Stack, PlusIcon, SearchIcon, StarIcon } from "@stylhero/ui";
function IconButtonExample() {
return (
<Stack direction="row" gap={2}>
<IconButton label="Add"><PlusIcon /></IconButton>
<IconButton label="Search" variant="secondary"><SearchIcon /></IconButton>
<IconButton label="Favorite" variant="primary"><StarIcon /></IconButton>
</Stack>
);
}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
label required |
string |
- | Required: what the button does, read by screen readers ("Delete customer"). |
href |
string |
- | |
size |
"sm" | "md" | "lg" |
"md" |
"lg" is 44px, the minimum comfortable tap target on phones. |
variant |
"ghost" | "secondary" | "primary" |
"ghost" |
Also takes every <button> attribute (id, style, data-*, aria-*, event handlers…), passed to that element. Takes a ref.
Keyboard
| Key | Does |
|---|---|
| Enter / Space | Activates it |
Accessibility
labelis required and becomes the accessible name (aria-label), since the button has no visible text.
Generated from src/components/IconButton.tsx. Something wrong or missing? Open an issue.