Button
import * as Button from '@dxos/react-ui/Button';A button is a control the user presses to act. Button has parts for a toggle, a group and a button that opens a menu.
import * as import Button
Button from '@dxos/react-ui/Button';import * as import Layout
Layout from '@dxos/react-ui/Layout';
export const const Buttons: () => React.JSX.Element
Buttons = () => ( <import Layout
Layout.const Flex: React.ForwardRefExoticComponent<Omit<Layout.FlexProps & { asChild?: boolean;}, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>
One-axis layout box: the primitive that replaces hand-written flex … wrapper divs.
gap is restricted to the named steps of the theme spacing ramp (see
Gap
), which is the
point of the prop — an off-ramp gap-2/gap-3 literal in a container is the drift it prevents.
Anything the props don't cover (padding, sizing, overflow, colour) goes through classNames; the
component deliberately grows no padding or colour props, since components own their own spacing.
There is no implicit align. Row-centering is the common case, but defaulting it would silently
restyle any consumer relying on the CSS stretch initial value.
Use asChild to project the layout onto a semantic element (<header>, <ul>, <a>).
Flex gap?: Layout.Gap | undefined
gap='sm' wrap?: boolean | undefined
wrap> <import Button
Button.const Root: React.ForwardRefExoticComponent<Omit<Button.RootProps, "className"> & { classNames?: ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLButtonElement>>export Root
Root variant?: Button.Variant | undefined
variant='primary'>Save</import Button
Button.const Root: React.ForwardRefExoticComponent<Omit<Button.RootProps, "className"> & { classNames?: ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLButtonElement>>export Root
Root> <import Button
Button.const Root: React.ForwardRefExoticComponent<Omit<Button.RootProps, "className"> & { classNames?: ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLButtonElement>>export Root
Root>Cancel</import Button
Button.const Root: React.ForwardRefExoticComponent<Omit<Button.RootProps, "className"> & { classNames?: ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLButtonElement>>export Root
Root> <import Button
Button.const Root: React.ForwardRefExoticComponent<Omit<Button.RootProps, "className"> & { classNames?: ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLButtonElement>>export Root
Root variant?: Button.Variant | undefined
variant='ghost' icon?: string | undefined
Leading icon.
icon='ph--plus--regular' label?: string | undefined
Visible text; children take precedence.
Required: names the button (aria-label) and shows in a Tooltip.
label='Add' /> <import Button
Button.const Root: React.ForwardRefExoticComponent<Omit<Button.RootProps, "className"> & { classNames?: ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLButtonElement>>export Root
Root variant?: Button.Variant | undefined
variant='destructive' icon?: string | undefined
Leading icon.
icon='ph--trash--regular' label?: string | undefined
Visible text; children take precedence.
Required: names the button (aria-label) and shows in a Tooltip.
label='Delete' iconOnly?: boolean | undefined
A control-sized square inset in a block-sized cell (follow-up 19), showing only the icon.
iconOnly /> <import Button
Button.const Toggle: React.ForwardRefExoticComponent<Omit<Button.ToggleProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLButtonElement>>export Toggle
A Button with a pressed state from the zag toggle machine (aria-pressed); icon, label and iconOnly are Button's.
Toggle icon?: string | undefined
Leading icon.
icon='ph--star--regular' activeIcon?: string | undefined
Icon shown while pressed, in place of icon (e.g. a filled star for a pinned item).
activeIcon='ph--star--fill' label?: string | undefined
Visible text; children take precedence.
Required: names the button (aria-label) and shows in a Tooltip.
label='Favorite' iconOnly?: boolean | undefined
A control-sized square inset in a block-sized cell (follow-up 19), showing only the icon.
iconOnly /> </import Layout
Layout.const Flex: React.ForwardRefExoticComponent<Omit<Layout.FlexProps & { asChild?: boolean;}, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>
One-axis layout box: the primitive that replaces hand-written flex … wrapper divs.
gap is restricted to the named steps of the theme spacing ramp (see
Gap
), which is the
point of the prop — an off-ramp gap-2/gap-3 literal in a container is the drift it prevents.
Anything the props don't cover (padding, sizing, overflow, colour) goes through classNames; the
component deliberately grows no padding or colour props, since components own their own spacing.
There is no implicit align. Row-centering is the common case, but defaulting it would silently
restyle any consumer relying on the CSS stretch initial value.
Use asChild to project the layout onto a semantic element (<header>, <ul>, <a>).
Flex>);
Button.Root
Section titled “Button.Root”Button.Root renders a button. It takes the props of a <button>, plus:
| Prop | Type | Effect |
|---|---|---|
variant |
'default' | 'primary' | 'ghost' | 'outline' | 'destructive' | 'valence' |
Sets the fill. Use primary for the one main action of a view |
valence |
'info' | 'success' | 'warning' | 'error' | 'neutral' |
Sets the status color, with variant='valence' |
hue |
Button.Hue |
Colors the button with a palette hue |
icon |
string |
Shows a leading icon, by name |
iconEnd |
string |
Shows a trailing icon, by name |
label |
string |
Sets the text, or with iconOnly the accessible name and tooltip |
iconOnly |
boolean |
Shows only the icon |
showTooltip |
boolean |
Shows the label as a tooltip, with iconOnly. true by default |
tooltipSide |
'top' | 'right' | 'bottom' | 'left' |
Sets where that tooltip opens |
caretDown |
boolean |
Adds a trailing caret, for a button that opens a menu |
spin |
boolean |
Spins the icon, for a busy state |
compact |
boolean |
Reduces the padding |
align |
'center' | 'start' |
Sets where the content sits in a wide button |
size |
Size |
Overrides the inherited size |
A button with icon and label needs no children. For any other content, pass children instead.
Button.Toggle
Section titled “Button.Toggle”Button.Toggle is a button that stays pressed. It takes the props of Button.Root, plus pressed, defaultPressed
and onPressedChange. Use activeIcon to show a different icon while the button is pressed.
Button.Group
Section titled “Button.Group”Button.Group puts buttons in a row with shared spacing.
justifyis'start','end'or'between'.fillshares the width equally, so a lone button stretches across the group.compactremoves the gap. Usecompactto pack a run of icon-only buttons.
Button.Menu
Section titled “Button.Menu”Button.Menu is a button that opens a menu of items. Use it when composing a full Menu
is more than you need.