Button
Raised, outline, ghost and danger buttons with icons, a loading state and asChild for links.
Example
import { Button } from "@porcelana/ui";
import { AlarmIcon, TrashIcon } from "@porcelana/icons";
export default function Example() {
return (
<div style={{ display: "flex", flexWrap: "wrap", gap: 12 }}>
<Button>Save</Button>
<Button variant="soft" startIcon={<AlarmIcon size={18} />}>
Snooze
</Button>
<Button variant="outline">Outline</Button>
<Button variant="ghost">Ghost</Button>
<Button variant="danger" startIcon={<TrashIcon size={18} />}>
Delete
</Button>
<Button loading>Saving</Button>
<Button asChild variant="outline">
<a href="#props">Link styled as a button</a>
</Button>
</div>
);
}Import
import { Button } from "@porcelana/ui";
import "@porcelana/ui/styles.css"; // once, at your app rootProps
Generated from the TypeScript types. Standard HTML attributes are passed through and not listed.
Button
| Prop | Type | Default | Description |
|---|---|---|---|
aria-label | string | – | Defines a string value that labels the current element. @see aria-labelledby. |
asChild | boolean | false | Render the child element (e.g. a link) with button styling. |
block | boolean | null | – | Stretch to the full width. |
disabled | boolean | – | Prevents interaction and dims the control. |
endIcon | ReactNode | – | Icon after the label. |
id | string | – | Element id. Generated automatically when omitted. |
loading | boolean | false | Shows a spinner, sets aria-busy and blocks clicks while keeping focus. |
size | "sm" | "md" | "lg" | null | – | Size. Every size keeps at least a 44px touch target. |
startIcon | ReactNode | – | Icon before the label. |
type | "button" | "submit" | "reset" | – | Button type (defaults to "button"). |
variant | "primary" | "soft" | "outline" | "ghost" | "danger" | null | – | Visual style. |
Accessibility
- Renders a real <button type="button"> unless you pass type or asChild.
- loading sets aria-busy and aria-disabled but keeps the button focusable, so screen-reader users don't lose their place.
- Use asChild with an <a> for navigation, so the element keeps link semantics.
Mobile
- Minimum height is 44px at every size, including sm.
- Presses scale down slightly for touch feedback, without a 300ms tap delay.