# @salmonui/buttons/button API reference

> 23 exported symbols of @salmonui/buttons/button: 4 functions, 8 interfaces and 11 types.

Canonical: https://salmonui.dev/docs/reference/buttons/button

```ts
import { … } from '@salmonui/buttons/button';
```

## Functions

### Button

Kind: function

Page: https://salmonui.dev/docs/reference/buttons/button/Button

```ts
function Button(props: ButtonProps): ReactElement;
```

Button (APG Button, native `<button>`). `type` defaults to `"button"`.
Styling hooks: `.salmon-button` with `data-variant`, `data-tone`,
`data-size`, `data-icon-only`, `data-loading`, `data-progress`,
`data-floating`.

### ButtonGroup

Kind: function

Page: https://salmonui.dev/docs/reference/buttons/button/ButtonGroup

```ts
function ButtonGroup({ children, orientation, attached, variant, tone, size, disabled, className, ...rest }: ButtonGroupProps): ReactElement;
```

A visual group of buttons: `role="group"`, named by `aria-label` or
`aria-labelledby`. It adds no keyboard model: every button
stays a tab stop. `.salmon-button-group` with
`data-orientation` and `data-attached`.

### ToggleButton

Kind: function

Page: https://salmonui.dev/docs/reference/buttons/button/ToggleButton

```ts
function ToggleButton(props: ToggleButtonProps): ReactElement;
```

Toggle button (APG Button, toggle variant): `aria-pressed`, `data-pressed`.
Inside a `ToggleButtonGroup` it is an item of that group: a radio
(`role="radio"`, `aria-checked`) in single mode, a toggle button
(`aria-pressed`) in multiple mode, with a roving tabindex.

### ToggleButtonGroup

Kind: function

Page: https://salmonui.dev/docs/reference/buttons/button/ToggleButtonGroup

```ts
function ToggleButtonGroup(props: ToggleButtonGroupProps): ReactElement;
```

A selection group of `ToggleButton`s with one tab stop (roving tabindex;
arrow keys, Home / End, mirrored in RTL). `.salmon-toggle-button-group`
with `data-selection-mode`, `data-orientation`, `data-attached`.

## Interfaces

### ButtonBaseProps

Kind: interface

Page: https://salmonui.dev/docs/reference/buttons/button/ButtonBaseProps

```ts
interface ButtonBaseProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'color'> {
    children?: ReactNode;
    variant?: ButtonVariant | undefined;
    tone?: ButtonTone | undefined;
    size?: ButtonSize | undefined;
    iconStart?: ReactNode;
    iconEnd?: ReactNode;
    iconOnly?: boolean | undefined;
    loading?: boolean | undefined;
    loadingLabel?: string | undefined;
    spinner?: ReactNode;
    progress?: number | undefined;
    progressLabel?: ((value: number) => string) | undefined;
    floating?: boolean | ButtonFloatingPosition | undefined;
    floatingScope?: 'viewport' | 'parent' | undefined;
    repeat?: boolean | ButtonRepeatOptions | undefined;
    onRepeat?: ((event: ButtonRepeatEvent) => void) | undefined;
    render?: ((props: ButtonRenderProps) => ReactElement) | undefined;
    ref?: Ref<HTMLButtonElement> | undefined;
}
```

Members (18):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `children` | `children?: ReactNode;` | optional |  |
| `variant` | `variant?: ButtonVariant \| undefined;` | optional | Visual weight. Default `'solid'` (or the group's). |
| `tone` | `tone?: ButtonTone \| undefined;` | optional | Color role. Default `'neutral'`; `'primary'` for a `floating` button (or the group's). |
| `size` | `size?: ButtonSize \| undefined;` | optional | Metric set. Default `'md'` (or the group's). |
| `iconStart` | `iconStart?: ReactNode;` | optional | Decorative icon before the label (inline-start; follows `dir`). |
| `iconEnd` | `iconEnd?: ReactNode;` | optional | Decorative icon after the label (inline-end; follows `dir`). |
| `iconOnly` | `iconOnly?: boolean \| undefined;` | optional | Square metrics for a button that shows only an icon; requires `aria-label` or `aria-labelledby`. |
| `loading` | `loading?: boolean \| undefined;` | optional | Shows a spinner, sets `aria-busy` and `aria-disabled` (focus is kept) and ignores activation. |
| `loadingLabel` | `loadingLabel?: string \| undefined;` | optional | Visually hidden text appended to the name while `loading`. Default `"Loading"`. |
| `spinner` | `spinner?: ReactNode;` | optional | Replaces the built-in spinner graphic. |
| `progress` | `progress?: number \| undefined;` | optional | Progress fill from inline-start, 0 to 100. No spinner unless `loading`. |
| `progressLabel` | `progressLabel?: ((value: number) => string) \| undefined;` | optional | Visually hidden progress text appended to the name. Default `` `${value}%` ``. |
| `floating` | `floating?: boolean \| ButtonFloatingPosition \| undefined;` | optional | Floating action button: circular, elevated, positioned by CSS. |
| `floatingScope` | `floatingScope?: 'viewport' \| 'parent' \| undefined;` | optional | `'viewport'` (default, `position: fixed`) or `'parent'` (`position: absolute` in the nearest positioned ancestor). |
| `repeat` | `repeat?: boolean \| ButtonRepeatOptions \| undefined;` | optional | Press-and-hold repeat. |
| `onRepeat` | `onRepeat?: ((event: ButtonRepeatEvent) => void) \| undefined;` | optional | Each repeat while held; the first activation is the native `onClick`. |
| `render` | `render?: ((props: ButtonRenderProps) => ReactElement) \| undefined;` | optional | Renders another element (a link, a router link) with the computed props. |
| `ref` | `ref?: Ref<HTMLButtonElement> \| undefined;` | optional | The `<button>` (or the element `render` returns). |

### ButtonGroupProps

Kind: interface

Page: https://salmonui.dev/docs/reference/buttons/button/ButtonGroupProps

```ts
interface ButtonGroupProps extends HTMLAttributes<HTMLDivElement> {
    children?: ReactNode;
    orientation?: 'horizontal' | 'vertical' | undefined;
    attached?: boolean | undefined;
    variant?: ButtonVariant | undefined;
    tone?: ButtonTone | undefined;
    size?: ButtonSize | undefined;
    disabled?: boolean | undefined;
    ref?: Ref<HTMLDivElement> | undefined;
}
```

Members (8):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `children` | `children?: ReactNode;` | optional |  |
| `orientation` | `orientation?: 'horizontal' \| 'vertical' \| undefined;` | optional | Layout direction. Default `'horizontal'`. |
| `attached` | `attached?: boolean \| undefined;` | optional | Joined borders and shared corners. Default `true`; `false` spaces the buttons. |
| `variant` | `variant?: ButtonVariant \| undefined;` | optional | Default `variant` of the buttons inside; a button's own prop wins. |
| `tone` | `tone?: ButtonTone \| undefined;` | optional | Default `tone` of the buttons inside; a button's own prop wins. |
| `size` | `size?: ButtonSize \| undefined;` | optional | Default `size` of the buttons inside; a button's own prop wins. |
| `disabled` | `disabled?: boolean \| undefined;` | optional | Disables every button inside; a button's own `disabled` wins. |
| `ref` | `ref?: Ref<HTMLDivElement> \| undefined;` | optional |  |

### ButtonRepeatEvent

Kind: interface

Page: https://salmonui.dev/docs/reference/buttons/button/ButtonRepeatEvent

```ts
interface ButtonRepeatEvent {
    readonly count: number;
    readonly source: ChangeSource;
}
```

Event of `onRepeat`: `count` starts at 1 for each hold.

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `count` | `readonly count: number;` |  |  |
| `source` | `readonly source: ChangeSource;` |  |  |

### ButtonRepeatOptions

Kind: interface

Page: https://salmonui.dev/docs/reference/buttons/button/ButtonRepeatOptions

```ts
interface ButtonRepeatOptions {
    delay?: number;
    interval?: number;
}
```

`repeat` option of `Button`.

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `delay` | `delay?: number;` | optional | Hold time before the first repeat, in ms. Default 400. |
| `interval` | `interval?: number;` | optional | Time between repeats, in ms (pointer and keyboard). Default 100. |

### ToggleButtonBaseProps

Kind: interface

Page: https://salmonui.dev/docs/reference/buttons/button/ToggleButtonBaseProps

```ts
interface ToggleButtonBaseProps extends Omit<ButtonBaseProps, 'value' | 'name'> {
    pressed?: boolean | undefined;
    defaultPressed?: boolean | undefined;
    onPressedChange?: ((pressed: boolean, event: ToggleChangeEvent) => void) | undefined;
    value?: string | undefined;
    name?: string | undefined;
}
```

Members (23):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `pressed` | `pressed?: boolean \| undefined;` | optional | Controlled pressed state. Ignored inside a `ToggleButtonGroup`. |
| `defaultPressed` | `defaultPressed?: boolean \| undefined;` | optional | Initial pressed state when uncontrolled; restored on form reset. Default `false`. |
| `onPressedChange` | `onPressedChange?: ((pressed: boolean, event: ToggleChangeEvent) => void) \| undefined;` | optional | Proposed pressed state; called for controlled and uncontrolled buttons. |
| `value` | `value?: string \| undefined;` | optional | The item's value inside a `ToggleButtonGroup` (required there), and the submitted value of a standalone button with `name` (default `"on"`). |
| `name` | `name?: string \| undefined;` | optional | Standalone form field name: a hidden input carries `value` while pressed. |
| `children` | `children?: ReactNode;` | optional, inherited |  |
| `variant` | `variant?: ButtonVariant;` | optional, inherited | Visual weight. Default `'solid'` (or the group's). |
| `tone` | `tone?: ButtonTone;` | optional, inherited | Color role. Default `'neutral'`; `'primary'` for a `floating` button (or the group's). |
| `size` | `size?: ButtonSize;` | optional, inherited | Metric set. Default `'md'` (or the group's). |
| `iconStart` | `iconStart?: ReactNode;` | optional, inherited | Decorative icon before the label (inline-start; follows `dir`). |
| `iconEnd` | `iconEnd?: ReactNode;` | optional, inherited | Decorative icon after the label (inline-end; follows `dir`). |
| `iconOnly` | `iconOnly?: boolean;` | optional, inherited | Square metrics for a button that shows only an icon; requires `aria-label` or `aria-labelledby`. |
| `loading` | `loading?: boolean;` | optional, inherited | Shows a spinner, sets `aria-busy` and `aria-disabled` (focus is kept) and ignores activation. |
| `loadingLabel` | `loadingLabel?: string;` | optional, inherited | Visually hidden text appended to the name while `loading`. Default `"Loading"`. |
| `spinner` | `spinner?: ReactNode;` | optional, inherited | Replaces the built-in spinner graphic. |
| `progress` | `progress?: number;` | optional, inherited | Progress fill from inline-start, 0 to 100. No spinner unless `loading`. |
| `progressLabel` | `progressLabel?: ((value: number) => string);` | optional, inherited | Visually hidden progress text appended to the name. Default `` `${value}%` ``. |
| `floating` | `floating?: boolean \| ButtonFloatingPosition;` | optional, inherited | Floating action button: circular, elevated, positioned by CSS. |
| `floatingScope` | `floatingScope?: "parent" \| "viewport";` | optional, inherited | `'viewport'` (default, `position: fixed`) or `'parent'` (`position: absolute` in the nearest positioned ancestor). |
| `repeat` | `repeat?: boolean \| ButtonRepeatOptions;` | optional, inherited | Press-and-hold repeat. |
| `onRepeat` | `onRepeat?: ((event: ButtonRepeatEvent) => void);` | optional, inherited | Each repeat while held; the first activation is the native `onClick`. |
| `render` | `render?: ((props: ButtonRenderProps) => ReactElement<unknown, string \| JSXElementConstructor<any>>);` | optional, inherited | Renders another element (a link, a router link) with the computed props. |
| `ref` | `ref?: Ref<HTMLButtonElement>;` | optional, inherited | The `<button>` (or the element `render` returns). |

### ToggleButtonGroupBaseProps

Kind: interface

Page: https://salmonui.dev/docs/reference/buttons/button/ToggleButtonGroupBaseProps

```ts
interface ToggleButtonGroupBaseProps extends Omit<HTMLAttributes<HTMLDivElement>, 'defaultValue' | 'onChange'> {
    children?: ReactNode;
    orientation?: 'horizontal' | 'vertical' | undefined;
    attached?: boolean | undefined;
    variant?: ButtonVariant | undefined;
    tone?: ButtonTone | undefined;
    size?: ButtonSize | undefined;
    disabled?: boolean | undefined;
    disallowEmpty?: boolean | undefined;
    name?: string | undefined;
    ref?: Ref<HTMLDivElement> | undefined;
}
```

Members (10):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `children` | `children?: ReactNode;` | optional | `ToggleButton` items, each with a `value`. |
| `orientation` | `orientation?: 'horizontal' \| 'vertical' \| undefined;` | optional | Layout and arrow-key axis. Default `'horizontal'`. |
| `attached` | `attached?: boolean \| undefined;` | optional | Joined borders. Default `true`, `false` for `variant="chip"`. |
| `variant` | `variant?: ButtonVariant \| undefined;` | optional | Default `variant` of the items; `'chip'` gives choice and filter chips. |
| `tone` | `tone?: ButtonTone \| undefined;` | optional | Default `tone` of the items. |
| `size` | `size?: ButtonSize \| undefined;` | optional | Default `size` of the items. |
| `disabled` | `disabled?: boolean \| undefined;` | optional | Disables every item; nothing is submitted while disabled. |
| `disallowEmpty` | `disallowEmpty?: boolean \| undefined;` | optional | Keeps one value selected (single) or at least one (multiple). Default `false`. |
| `name` | `name?: string \| undefined;` | optional | Form field name: one hidden input per selected value. |
| `ref` | `ref?: Ref<HTMLDivElement> \| undefined;` | optional |  |

### ToggleButtonGroupMultipleProps

Kind: interface

Page: https://salmonui.dev/docs/reference/buttons/button/ToggleButtonGroupMultipleProps

```ts
interface ToggleButtonGroupMultipleProps extends ToggleButtonGroupBaseProps {
    selectionMode: 'multiple';
    value?: readonly string[] | undefined;
    defaultValue?: readonly string[] | undefined;
    onValueChange?: ((value: readonly string[], event: ToggleChangeEvent) => void) | undefined;
}
```

Members (14):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `selectionMode` | `selectionMode: 'multiple';` |  | A group of toggle buttons: `role="group"`, items `aria-pressed`; arrow keys move focus. |
| `value` | `value?: readonly string[] \| undefined;` | optional |  |
| `defaultValue` | `defaultValue?: readonly string[] \| undefined;` | optional |  |
| `onValueChange` | `onValueChange?: ((value: readonly string[], event: ToggleChangeEvent) => void) \| undefined;` | optional |  |
| `children` | `children?: ReactNode;` | optional, inherited | `ToggleButton` items, each with a `value`. |
| `orientation` | `orientation?: "horizontal" \| "vertical";` | optional, inherited | Layout and arrow-key axis. Default `'horizontal'`. |
| `attached` | `attached?: boolean;` | optional, inherited | Joined borders. Default `true`, `false` for `variant="chip"`. |
| `variant` | `variant?: ButtonVariant;` | optional, inherited | Default `variant` of the items; `'chip'` gives choice and filter chips. |
| `tone` | `tone?: ButtonTone;` | optional, inherited | Default `tone` of the items. |
| `size` | `size?: ButtonSize;` | optional, inherited | Default `size` of the items. |
| `disabled` | `disabled?: boolean;` | optional, inherited | Disables every item; nothing is submitted while disabled. |
| `disallowEmpty` | `disallowEmpty?: boolean;` | optional, inherited | Keeps one value selected (single) or at least one (multiple). Default `false`. |
| `name` | `name?: string;` | optional, inherited | Form field name: one hidden input per selected value. |
| `ref` | `ref?: Ref<HTMLDivElement>;` | optional, inherited |  |

### ToggleButtonGroupSingleProps

Kind: interface

Page: https://salmonui.dev/docs/reference/buttons/button/ToggleButtonGroupSingleProps

```ts
interface ToggleButtonGroupSingleProps extends ToggleButtonGroupBaseProps {
    selectionMode?: 'single' | undefined;
    value?: string | null | undefined;
    defaultValue?: string | null | undefined;
    onValueChange?: ((value: string | null, event: ToggleChangeEvent) => void) | undefined;
}
```

Members (14):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `selectionMode` | `selectionMode?: 'single' \| undefined;` | optional | APG Radio Group: `role="radiogroup"`, items `role="radio"`; arrow keys move and select. |
| `value` | `value?: string \| null \| undefined;` | optional |  |
| `defaultValue` | `defaultValue?: string \| null \| undefined;` | optional |  |
| `onValueChange` | `onValueChange?: ((value: string \| null, event: ToggleChangeEvent) => void) \| undefined;` | optional |  |
| `children` | `children?: ReactNode;` | optional, inherited | `ToggleButton` items, each with a `value`. |
| `orientation` | `orientation?: "horizontal" \| "vertical";` | optional, inherited | Layout and arrow-key axis. Default `'horizontal'`. |
| `attached` | `attached?: boolean;` | optional, inherited | Joined borders. Default `true`, `false` for `variant="chip"`. |
| `variant` | `variant?: ButtonVariant;` | optional, inherited | Default `variant` of the items; `'chip'` gives choice and filter chips. |
| `tone` | `tone?: ButtonTone;` | optional, inherited | Default `tone` of the items. |
| `size` | `size?: ButtonSize;` | optional, inherited | Default `size` of the items. |
| `disabled` | `disabled?: boolean;` | optional, inherited | Disables every item; nothing is submitted while disabled. |
| `disallowEmpty` | `disallowEmpty?: boolean;` | optional, inherited | Keeps one value selected (single) or at least one (multiple). Default `false`. |
| `name` | `name?: string;` | optional, inherited | Form field name: one hidden input per selected value. |
| `ref` | `ref?: Ref<HTMLDivElement>;` | optional, inherited |  |

## Types

### ButtonAccessibleName

Kind: type

Page: https://salmonui.dev/docs/reference/buttons/button/ButtonAccessibleName

```ts
type ButtonAccessibleName = {
    'aria-label': string;
} | {
    'aria-labelledby': string;
};
```

An icon-only button needs an accessible name.

### ButtonChangeSource

Kind: type

Page: https://salmonui.dev/docs/reference/buttons/button/ButtonChangeSource

```ts
type ChangeSource = 'pointer' | 'keyboard' | 'touch' | 'api';
```

Where a change came from.

### ButtonFloatingPosition

Kind: type

Page: https://salmonui.dev/docs/reference/buttons/button/ButtonFloatingPosition

```ts
type ButtonFloatingPosition = 'topStart' | 'topCenter' | 'topEnd' | 'middleStart' | 'middleCenter' | 'middleEnd' | 'bottomStart' | 'bottomCenter' | 'bottomEnd';
```

Where a `floating` button sits; logical, mirrored in RTL. `true` means `'bottomEnd'`.

### ButtonProps

Kind: type

Page: https://salmonui.dev/docs/reference/buttons/button/ButtonProps

```ts
type ButtonProps = ButtonBaseProps & ({
    iconOnly?: false | undefined;
} | ({
    iconOnly: true;
} & ButtonAccessibleName));
```

### ButtonRenderProps

Kind: type

Page: https://salmonui.dev/docs/reference/buttons/button/ButtonRenderProps

```ts
type ButtonRenderProps = HTMLAttributes<HTMLElement> & {
    ref?: Ref<never> | undefined;
    [dataAttribute: `data-${string}`]: string | number | undefined;
};
```

Props `render` receives: class names,
`data-*` hooks, ARIA attributes, handlers, `ref` and `children`. Spread
all of them onto the returned element. `ref` is typed to spread onto any
element; it receives the rendered element.

Members (1):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `ref` | `ref?: Ref<never>;` | optional, inherited |  |

### ButtonSize

Kind: type

Page: https://salmonui.dev/docs/reference/buttons/button/ButtonSize

```ts
type ButtonSize = 'sm' | 'md' | 'lg';
```

One of three fixed metric sets; not a density token.

### ButtonTone

Kind: type

Page: https://salmonui.dev/docs/reference/buttons/button/ButtonTone

```ts
type ButtonTone = 'neutral' | 'primary' | 'success' | 'warning' | 'danger' | 'info';
```

Color role of a button.

### ButtonVariant

Kind: type

Page: https://salmonui.dev/docs/reference/buttons/button/ButtonVariant

```ts
type ButtonVariant = 'solid' | 'outline' | 'ghost' | 'link' | 'chip';
```

Visual weight; `chip` is the compact pill of choice and filter chips.

### ToggleButtonGroupProps

Kind: type

Page: https://salmonui.dev/docs/reference/buttons/button/ToggleButtonGroupProps

```ts
type ToggleButtonGroupProps = ToggleButtonGroupSingleProps | ToggleButtonGroupMultipleProps;
```

### ToggleButtonProps

Kind: type

Page: https://salmonui.dev/docs/reference/buttons/button/ToggleButtonProps

```ts
type ToggleButtonProps = ToggleButtonBaseProps & ({
    iconOnly?: false | undefined;
} | ({
    iconOnly: true;
} & ButtonAccessibleName));
```

### ToggleChangeEvent

Kind: type

Page: https://salmonui.dev/docs/reference/buttons/button/ToggleChangeEvent

```ts
type ToggleChangeEvent = ChangeEvent<'toggle' | 'reset'>;
```

Event of `onPressedChange` and `onValueChange`: `reason` is `'toggle'` or `'reset'` (form reset).

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `source` | `source: ChangeSource;` | inherited |  |
| `reason` | `reason: "reset" \| "toggle";` | inherited |  |
