Actions
FAB
The floating action button: a 56px ink button at the bottom right of a phone screen that starts the action people take most, "Add".
In kanso-ui as Fab
Web and native
Web
Native
Fab in kanso-ui 0.59.0, for React.
import { Fab } from '@kanso-labs/kanso-ui'A floating action button: a screen's primary action, raised over its content.
It follows the Material Design FAB page and, given a label, the extended FAB page. It rests on the level 3 shadow and lifts to level 4 under a hovering pointer. The spec gives no disabled FAB; a disabled one takes the usual disabled opacities and drops its shadow.
What you provide
children: the icon, drawn1emsquare incurrentColor, so it takes the size's icon size.aria-labelwhen there is nolabel: an icon alone has no name. With alabel, the label is its name.- Its place on the screen, typically the bottom trailing corner: the FAB does not position itself, and
className,styleandrefland on the button.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
aria-label | string | — | What the FAB does, in words. A FAB without a `label` is an icon alone, which has no name of its own, so give it this; with a `label` the label is its name. |
children | ReactNode | — | The FAB's icon, drawn at Kanso's 24px. |
className | ClassNameOrFunction<ButtonState> | — | A function may compute the class from the FAB's render state. |
disableRipple | boolean | false | Disables the press ripple, and draws the flat pressed layer in its place. The hover and focus layers are unaffected. |
href | string | — | Where the FAB leads. Given one, it is rendered as a link — an `<a>`, announced as the link it is — with the same styles and ripple. |
label | ReactNode | — | A label after the icon, which makes this the extended FAB: as tall as the size, as wide as what it holds. Kept to one line, it ends in an ellipsis when the FAB's container is narrower than it, and shows its full text in a tooltip on hover. |
rel | string | — | The link's `rel`, when `href` is set. |
size | 'lg' | 'md' | 'xl' | 'md' | Kanso's one size, `md`, 56px. `lg` and `xl` are deprecated and draw it too. Deprecated sizes. Kanso's FAB is the 56px one, md: lg (80px) and xl (96px) are deprecated in Kanso, though kanso-ui still accepts them. |
style | StyleOrFunction<ButtonState> | — | A function may compute the style from the FAB's render state. |
target | string | — | The link's `target`, when `href` is set. |
tone | 'accent' | 'ink' | 'primary' | 'secondary' | 'tertiary' | 'ink' | The colour the FAB is drawn in: `ink`, Kanso's FAB, or `accent`, the product's colour, for a screen whose one highlighted action it is. `primary` is deprecated and draws `accent`; `secondary` and `tertiary` are deprecated and draw `ink`. |
variant | 'filled' | 'tonal' | 'filled' | `filled` draws the tone itself, Kanso's FAB; `tonal` draws its quieter pair, `container` for ink and `accent-soft` for accent. |
Also takes the props of Omit<ButtonDOMProps, 'aria-label' | 'isPending'>.
Example
import { Fab } from '@kanso-labs/kanso-ui'
<Fab aria-label="Label" onPress={create}>
<PlusIcon />
</Fab>
<Fab label="Label" size="lg" tone="secondary">
<PlusIcon />
</Fab>The design’s classes
k-fab, k-fab--icon, k-fab--accent; on the web, k-btn k-btn--ink k-btn--md inside k-appbar.
Maps to Fab in kanso-ui and react-native-kanso-ui.