Components / Inputs
Fab
Floating action button: the one main action on a screen, e.g. "Add customer".
import { Fab } from "@stylhero/ui";
Example
Code
import { Fab, Stack, PlusIcon, SearchIcon } from "@stylhero/ui";
function FabExample() {
return (
<Stack direction="row" gap={3} align="center">
<Fab label="Add"><PlusIcon /></Fab>
<Fab label="New build" extended tone="accent"><PlusIcon /></Fab>
<Fab label="Search" size="sm" tone="surface"><SearchIcon /></Fab>
</Stack>
);
}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
label required |
string |
- | Required for the round icon-only version; becomes the aria-label. |
extended |
boolean |
- | Shows the label next to the icon (MUI's variant="extended"). |
fixed |
boolean |
- | Pins it to the bottom-right corner of the screen. |
size |
"sm" | "md" |
"md" |
|
tone |
"primary" | "accent" | "surface" |
"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 |
Accessibility
labelis required: it's the accessible name, and the visible text whenextended.
Generated from src/components/Fab.tsx. Something wrong or missing? Open an issue.