Skip to content

UI: Button

View as Markdown

Button and IconButton, in the four variants of the desktop. Import the token file once (@pithyx/ui/tokens.css) and wrap the app in UiProvider; see @pithyx/ui.

Generated from the TSDoc comments of @pithyx/ui 1.0.0-rc.9 at build time; the text below the headings is the comment in the source.

The props of Button: React Aria’s button props plus the look.

  • Omit<AriaButtonProps, "className" | "children">
optional variant?: ButtonVariant;

How much the button stands out; secondary when left out.

optional size?: "md" | "sm";

sm for dense rows and toolbars; md when left out.

optional className?: string;

Extra class names, added after the button’s own.

optional children?: ReactNode;

The label, an icon or both.


The props of IconButton.

optional variant?: ButtonVariant;

How much the button stands out; secondary when left out.

ButtonProps.variant

optional size?: "md" | "sm";

sm for dense rows and toolbars; md when left out.

Omit.size;
optional className?: string;

Extra class names, added after the button’s own.

ButtonProps.className

optional children?: ReactNode;

The label, an icon or both.

ButtonProps.children

label: string;

Accessible name, also shown as tooltip.

optional tooltip?: boolean;

Hides the tooltip where the label is already visible nearby.

type ButtonVariant = 'primary' | 'secondary' | 'quiet' | 'danger';

How much a button stands out: primary for the main action, danger for a destructive one.

function Button(props): Element;

A button in the desktop’s look. Use onPress instead of onClick, so keyboard, touch and screen readers act alike, and isPending for an action that runs.

Parameter Type Description
props ButtonProps React Aria’s button props plus variant and size.

Element

The button element.

<Button variant="primary" onPress={save}>
Save
</Button>

function IconButton(props): Element;

A button that shows only an icon; its label is announced and shown as a tooltip. quiet when no variant is set.

Parameter Type Description
props IconButtonProps The props of Button plus label and tooltip.

Element

The button, wrapped in a tooltip trigger unless tooltip is false.

<IconButton label="Delete" onPress={remove}>
<IconTrash size={18} />
</IconButton>