UI: Button
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.
Interfaces
Section titled “Interfaces”ButtonProps
Section titled “ButtonProps”The props of Button: React Aria’s button props plus the look.
Extends
Section titled “Extends”Omit<AriaButtonProps,"className"|"children">
Properties
Section titled “Properties”variant?
Section titled “variant?”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.
className?
Section titled “className?”optional className?: string;Extra class names, added after the button’s own.
children?
Section titled “children?”optional children?: ReactNode;The label, an icon or both.
IconButtonProps
Section titled “IconButtonProps”The props of IconButton.
Extends
Section titled “Extends”Omit<ButtonProps,"aria-label">
Properties
Section titled “Properties”variant?
Section titled “variant?”optional variant?: ButtonVariant;How much the button stands out; secondary when left out.
Inherited from
Section titled “Inherited from”optional size?: "md" | "sm";sm for dense rows and toolbars; md when left out.
Inherited from
Section titled “Inherited from”Omit.size;className?
Section titled “className?”optional className?: string;Extra class names, added after the button’s own.
Inherited from
Section titled “Inherited from”children?
Section titled “children?”optional children?: ReactNode;The label, an icon or both.
Inherited from
Section titled “Inherited from”label: string;Accessible name, also shown as tooltip.
tooltip?
Section titled “tooltip?”optional tooltip?: boolean;Hides the tooltip where the label is already visible nearby.
Type Aliases
Section titled “Type Aliases”ButtonVariant
Section titled “ButtonVariant”type ButtonVariant = 'primary' | 'secondary' | 'quiet' | 'danger';How much a button stands out: primary for the main action, danger for a destructive one.
Functions
Section titled “Functions”Button()
Section titled “Button()”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.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
props |
ButtonProps |
React Aria’s button props plus variant and size. |
Returns
Section titled “Returns”Element
The button element.
Example
Section titled “Example”<Button variant="primary" onPress={save}> Save</Button>IconButton()
Section titled “IconButton()”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.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
props |
IconButtonProps |
The props of Button plus label and tooltip. |
Returns
Section titled “Returns”Element
The button, wrapped in a tooltip trigger unless tooltip is false.
Example
Section titled “Example”<IconButton label="Delete" onPress={remove}> <IconTrash size={18} /></IconButton>