Button
A button for triggering actions, with options for icons, intent, variant, size, and busy or pressed states.
Installation
import { Button } from "@o/pipeline/experimental/components/button";
Default
Icons
Don’t pass icons as children. Pass them to the button through these props:
iconStart(or theiconalias)iconEnd
For a button that holds only an icon, use IconButton.
IconButton
A button with one icon and nothing else. It’s a circle by default, or a square with shape="square", and its required label becomes its aria-label. It takes the same size, variant and intent as Button.
import { IconButton } from "@o/pipeline/experimental/components/button";
<IconButton variant="ghost" icon={<IconClose />} label="Close" />;
A square takes the size’s corner radius.
<IconButton variant="ghost" shape="square" icon={<IconHome />} label="Home" />
An icon-only Button is flagged by the @o/pipeline/prefer-icon-button ESLint rule.
intent
Change the button’s color scheme to signal the nature of the action.
none(default): for neutral actions without a strong emphasissuccess: for actions that are positive or confirmatory in naturedanger: for destructive or potentially negative actions
Combine with the variant prop to adjust the button’s appearance.
variant
Changes the aesthetics of the button to blend accordingly with the context of its usage.
variant="solid"
- size="sm"
- size="md"
- size="sm"
- stretchsize="sm"
- stretchsize="md"
- stretchsize="sm"
- size="sm"
- size="md"
- size="sm"
- stretchsize="sm"
- stretchsize="md"
- stretchsize="sm"
- size="sm"
- size="md"
- size="sm"
- stretchsize="sm"
- stretchsize="md"
- stretchsize="sm"
variant="ghost"
- size="sm"
- size="md"
- size="sm"
- stretchsize="sm"
- stretchsize="md"
- stretchsize="sm"
- size="sm"
- size="md"
- size="sm"
- stretchsize="sm"
- stretchsize="md"
- stretchsize="sm"
- size="sm"
- size="md"
- size="sm"
- stretchsize="sm"
- stretchsize="md"
- stretchsize="sm"
variant="subtle"
A quiet, filled control for dense rows of chips and toggles, such as message reactions. It rests as a faint fill with a hairline edge; everything else, its text and icon colors and its hover and pressed states, matches ghost.
- size="sm"
- size="md"
- size="sm"
- stretchsize="sm"
- stretchsize="md"
- stretchsize="sm"
- size="sm"
- size="md"
- size="sm"
- stretchsize="sm"
- stretchsize="md"
- stretchsize="sm"
- size="sm"
- size="md"
- size="sm"
- stretchsize="sm"
- stretchsize="md"
- stretchsize="sm"
choice
Used for actions that display a value you choose, such as a Choice.
Note
Currently, the choice prop only supports intent="none".
When a value isn’t set, also supply a placeholder attribute.
- size="sm"
- size="md"
- size="sm"
- stretchsize="sm"
- stretchsize="md"
- stretchsize="sm"
- size="sm"
- size="md"
- size="sm"
- stretchsize="sm"
- stretchsize="md"
- stretchsize="sm"
shape
Sets the button’s geometry along two independent axes: corner rounding and width.
Defaults to "circle" for icon-only buttons (a single icon/iconEnd/collapsible, no other content) and "rectangle" otherwise. An icon-only "rectangle" is as wide as it is tall, with the size’s corner radius; IconButton calls it "square".
"circle" locks width to height, so its content must fit a square box. It’s intended for a single icon. Adding text to one keeps the 1:1 lock and truncates rather than growing. For an elongated fully-rounded button, use "pill". The width pin also wins over stretch: a stretched "circle" stays 1:1, while a stretched "rectangle"/"pill" fills its container.
size
disabled
Prevent user interaction
Note
For elements that don’t support the disabled attribute, such as <a> elements, we mimic disabled behavior by disabling pointer events completely.
pending
Indicate a busy or loading state, blocking interaction and replacing the content with a spinner.
pressed
Indicate an active or pressed state, such as a Menu trigger when its menu is open.
A pressed ghost or subtle button with intent="none" tints more strongly than its hover, in both themes.
Note
For flexibility, this isn’t applied automatically when combined with collapsible and an open state.
stretch
Fill the button to the width of its container
shrink
Allows the button to shrink smaller than its content if necessary to avoid overflow (true by default)
collapsible
Indicate to the user that the button toggles another element’s visibility with a visual cue (e.g. a caret that rotates when open).
Accepts either true (alias for { weight: "bold", transition: "right-down" }) or a config object:
weight:"bold"(default) or"fill": a line chevron or a filled triangle.transition:"right-down"(default),"down-up", or"right-up"(for content that opens above the control), the rotation the caret animates through when toggled between closed andopen.
This can be combined with pressed where relevant.
- size="sm"
- size="md"
- size="sm"
- stretchsize="sm"
- stretchsize="md"
- stretchsize="sm"
- size="sm"
- size="md"
- size="sm"
- stretchsize="sm"
- stretchsize="md"
- stretchsize="sm"
- size="sm"
- size="md"
- size="sm"
- stretchsize="sm"
- stretchsize="md"
- stretchsize="sm"
- size="sm"
- size="md"
- size="sm"
- stretchsize="sm"
- stretchsize="md"
- stretchsize="sm"
render
Customize the underlying element to your needs
e.g. a link:
bleed
Allow the button to extend beyond its normal bounds via negative margins.
bleed works on circle buttons: the offset is the glyph frame inset, (height - glyph-frame) / 2 (the same distance an icon-only button bleeds), rather than the text-button padding a circle doesn’t have. A bled circle button’s content therefore lines up flush with its surroundings.
- size="sm"
- size="md"
- size="sm"
- stretchsize="sm"
- stretchsize="md"
- stretchsize="sm"
- size="sm"
- size="md"
- size="sm"
- stretchsize="sm"
- stretchsize="md"
- stretchsize="sm"
- size="sm"
- size="md"
- size="sm"
- stretchsize="sm"
- stretchsize="md"
- stretchsize="sm"
- size="sm"
- size="md"
- size="sm"
- stretchsize="sm"
- stretchsize="md"
- stretchsize="sm"
- size="sm"
- size="md"
- size="sm"
- stretchsize="sm"
- stretchsize="md"
- stretchsize="sm"
- size="sm"
- size="md"
- size="sm"
- stretchsize="sm"
- stretchsize="md"
- stretchsize="sm"
- size="sm"
- size="md"
- size="sm"
- stretchsize="sm"
- stretchsize="md"
- stretchsize="sm"
- size="sm"
- size="md"
- size="sm"
- stretchsize="sm"
- stretchsize="md"
- stretchsize="sm"
skeleton
skeleton shows the button as a placeholder of its own size and shape while what it acts on is loading, and makes it inert. Inside a loading SkeletonGroup it is on by default; see Skeleton.