---
title: UI kit - Actions
summary: The @spacemix/ui action components beside Button - IconButton, ButtonGroup, SegmentedControl, Toggle, CopyButton and Link - with their props and keyboard behaviour.
audience: both
stability: experimental
since: protocol 1
---

# Actions

Buttons and links beyond the plain [`Button`](../ui.md#button): icon-only buttons, groups, segmented choices, toggles, a copy button and styled links. Source: `packages/ui/src/components.tsx`.

Every component takes the native props of its root element, `className` joined last and `ref`. The [conventions](../ui.md#conventions) apply.

**Stability:** experimental, every export on this page: new in this release, and names and props may still be adjusted before they are promised.

## `IconButton`

A square button that holds only an icon. Its `aria-label` is required and doubles as the hover tooltip (`title`) unless you give a `title`. Takes every `<button>` prop.

| Prop | Type | Default | What it does |
|---|---|---|---|
| `aria-label` | `string` | required | What the button does, read by screen readers and shown as the tooltip. |
| `variant` | `ButtonVariant` | `"ghost"` | As on `Button`. |
| `size` | `Size` | `"md"` | 28, 32 or 40 px square. |
| `loading` | `boolean` | `false` | Shows a spinner in place of the icon, disables the button and sets `aria-busy`. |

```tsx
<IconButton aria-label="Delete" variant="ghost" onClick={remove}><Trash2 /></IconButton>
```

`IconButtonProps` is the props type.

## `ButtonGroup`

Buttons that belong together (Previous / Next, Bold / Italic / Underline), joined into one bar or spaced in a row, in a `role="group"` container. Give it an `aria-label` when the buttons don't say what the group is.

| Prop | Type | Default | What it does |
|---|---|---|---|
| `attached` | `boolean` | `true` | Joins the buttons into one bar with shared borders; `false` lays them out with a gap. |
| `orientation` | `"horizontal" \| "vertical"` | `"horizontal"` | A row or a column. A vertical group sets `aria-orientation`. |

`ButtonGroupProps` is the props type.

## `SegmentedControl`

A row of mutually exclusive choices with a sliding selection (view mode, theme, period). It is a `radiogroup`: the arrow keys move and select, Home and End jump to the ends, and only the selected segment is a Tab stop. Label it with `aria-label` or a surrounding [`Field`](forms.md#field).

```ts
interface SegmentedOption<T extends string = string> {
  value: T;
  label: ReactNode;
  icon?: ReactNode;          // a lucide icon before the label
  disabled?: boolean;
  "aria-label"?: string;     // needed when `label` isn't text (an icon-only segment)
}
```

| Prop | Type | Default | What it does |
|---|---|---|---|
| `options` | `SegmentedOption<T>[]` | required | The choices. |
| `value` | `T` | none | The chosen value (controlled). |
| `defaultValue` | `T` | the first enabled option | The starting value when uncontrolled. |
| `onChange` | `(value: T) => void` | none | Called with the chosen value. |
| `size` | `Size` | `"md"` | 24, 28 or 36 px tall. |
| `fullWidth` | `boolean` | none | Stretches over the container, the segments sharing the width. |
| `disabled` | `boolean` | none | Turns every segment off. |

```tsx
<SegmentedControl aria-label="View" options={[{ value: "list", label: "List" }, { value: "board", label: "Board" }]} value={view} onChange={setView} />
```

`SegmentedControlProps` is the props type. For switching panels, use [`Tabs`](navigation.md#tabs-tablist-tab-tabpanel).

## `Toggle`

A button that stays pressed or not (bold, pin, show hidden), with `aria-pressed`. Keep the label the same in both states; the pressed look says which one it is in. An `onClick` that calls `preventDefault()` stops the toggle.

| Prop | Type | Default | What it does |
|---|---|---|---|
| `pressed` | `boolean` | none | Whether it is pressed (controlled). |
| `defaultPressed` | `boolean` | `false` | The starting state when uncontrolled. |
| `onChange` | `(pressed: boolean) => void` | none | Called with the new state, not the event. |
| `size` | `Size` | `"md"` | As on `Button`. |
| `iconOnly` | `boolean` | none | Square, for an icon alone; give it an `aria-label`. |
| `variant` | `"ghost" \| "secondary"` | `"ghost"` | `"ghost"` has no border when off; `"secondary"` keeps one. |

`ToggleProps` is the props type.

## `CopyButton`

A button that copies a string (a link, a key, a snippet) to the clipboard and shows a check for a moment, announced to screen readers. Where the Clipboard API is blocked (some sandboxed frames), it falls back to a hidden text area and `document.execCommand("copy")`. An `onClick` that calls `preventDefault()` stops the copy.

| Prop | Type | Default | What it does |
|---|---|---|---|
| `value` | `string` | required | The text that goes on the clipboard. |
| `label` | `string` | `"Copy"` | The button's label, or its `aria-label` with `iconOnly`. |
| `copiedLabel` | `string` | `"Copied"` | Shown and announced for `timeout` ms after a copy. |
| `iconOnly` | `boolean` | none | Only the icon, as a square button. |
| `variant` | `ButtonVariant` | `"ghost"` with `iconOnly`, else `"secondary"` | As on `Button`. |
| `size` | `Size` | `"md"` | As on `Button`. |
| `timeout` | `number` | `1500` | How long the copied state lasts, in ms. |
| `onCopy` | `(ok: boolean) => void` | none | Called after a copy, with whether it worked. |

```tsx
<CopyButton value={inviteUrl} label="Copy link" />
```

`CopyButtonProps` is the props type.

## `Link`

A styled anchor for links in text, help lines and footers. Takes every `<a>` prop. In an extension frame, a link to another site is opened by the runtime through `host.shell.openUrl`.

| Prop | Type | Default | What it does |
|---|---|---|---|
| `variant` | `"accent" \| "muted"` | `"accent"` | `"accent"` for links in text, `"muted"` for quiet links in footers and meta lines. |
| `external` | `boolean` | none | Opens in a new tab (`target="_blank"`, `rel="noopener noreferrer"`) and shows an external-link icon, with "(opens in a new tab)" for screen readers. |
| `underline` | `"hover" \| "always" \| "none"` | `"hover"` | `"always"` for links inside running text. |

`LinkProps` is the props type. `lucide-react` also has a `Link` icon; import it as `LinkIcon` (see [Names that clash](../ui.md#names-that-clash-with-lucide-react)).
