import { Fab } from "@senvenli/react/action";
import { Text } from "@senvenli/react/display";
import { Stack } from "@senvenli/react/layout";
import { useState } from "react";
export default function Example() {
const [orders, setOrders] = useState(0);
return (
<Stack direction="horizontal" space="space-200">
{/* In an app, leave `placement` out: the button floats above the page's bottom corner. */}
<Fab iconBefore="plus" placement="inline" onPress={() => setOrders(orders + 1)}>New order</Fab>
<Text tone="subtle">Orders started: {orders}</Text>
</Stack>
);
}import { Fab } from "@senvenli/react/action";Examples
A link
With `href` it opens a contact or chat page, in a new tab unless `target` says otherwise.import { Fab } from "@senvenli/react/action";
export default function Example() {
return <Fab iconBefore="message-circle" href="https://example.com/contact" placement="inline">Contact us</Fab>;
}Icon only
`iconOnly`: a round button at every width; `label` stays its accessible name.import { Fab } from "@senvenli/react/action";
export default function Example() {
// Round and icon-only at every width; the label is still its name for screen readers and its tooltip.
return <Fab iconBefore="plus" iconOnly placement="inline" onPress={() => {}}>New order</Fab>;
}Guidelines
When to use it
- One main task must stay reachable while people scroll: contact, new item.
Use something else when
- The action fits in the page header or a toolbar and need not float. Button
- People switch between top destinations rather than start a task. Bottom navigation
Do and avoid
- At most one per screen; never over a dialog or sheet.
Accessibility
Built in
- Keeps its label as the accessible name when collapsed to an icon.
- Links that open a new tab say so.
You provide
- A verb label for the task.
API reference
Fab
| Prop | Type | Default | Description |
|---|---|---|---|
childrenRequired | string | – | The task, as a verb ("Contact us", "New order"), as Button's label; also the name when icon-only. |
iconBeforeRequired | IconName | – | Lucide icon name before the label ("message-circle", "calendar-plus"), as Button's |
onPress | (event: PressEvent) => void | – | |
href | string | – | A link (a chat or contact URL) instead of an action; it opens in a new tab unless |
target | HTMLAttributeAnchorTarget | "_blank" | Where |
placement | "inline" | "fixed" | "fixed" |
|
collapseOnScroll | boolean | true | Collapse to icon-only on phones after the first scroll (default true). |
iconOnly | boolean | false | Icon-only at every width, as Button's |
childrenRequiredstringThe task, as a verb ("Contact us", "New order"), as Button's label; also the name when icon-only.
iconBeforeRequiredIconNameLucide icon name before the label ("message-circle", "calendar-plus"), as Button's
iconBefore.onPress(event: PressEvent) => voidhrefstringA link (a chat or contact URL) instead of an action; it opens in a new tab unless
targetsays otherwise.targetHTMLAttributeAnchorTargetDefault"_blank"Where
hrefopens._blank(default) follows Link's external convention:noopener noreferrerand the new-tab words for screen readers._selfkeeps an in-app link in the page, through the host router.placement"inline" | "fixed"Default"fixed"fixed(default): bottom-end above the safe area.inline: in the flow (previews, docs).collapseOnScrollbooleanDefaulttrueCollapse to icon-only on phones after the first scroll (default true).
iconOnlybooleanDefaultfalseIcon-only at every width, as Button's
iconOnly: a round button;labelstays its accessible name.