Components / Core
Button
Button, or a link that looks like one when you pass href.
import { Button } from "@stylhero/ui";
Example
Code
import { Button, Stack } from "@stylhero/ui";
function ButtonExample() {
return (
<Stack direction="row" gap={2} wrap align="center">
<Button>Save</Button>
<Button variant="secondary">Cancel</Button>
<Button variant="ghost">Skip</Button>
<Button variant="danger">Delete</Button>
<Button loading>Saving</Button>
<Button href="#props" variant="secondary" size="sm">Read the props</Button>
</Stack>
);
}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
fullWidth |
boolean |
- | |
href |
string |
- | Renders a link styled as a button, through your router's link (see LinkProvider).
http(s):// links open in a new tab. Links can't be disabled or loading:
render a Button without href for that. |
loading |
boolean |
- | Shows a spinner and disables the button while keeping its width. |
size |
"sm" | "md" | "lg" |
"md" |
|
variant |
"primary" | "secondary" | "ghost" | "danger" |
"primary" |
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 (a native <button>); with href, Enter follows the link |
Accessibility
loadingsetsaria-busyand disables the button, keeping its width.- With
hrefit's a real link, so screen readers announce it as a link.
Generated from src/components/Button.tsx. Something wrong or missing? Open an issue.