# IconButton

An icon-only button with a required label, shown as a hint on hover and focus.

- **Use it for**: A frequent action where the icon is universally understood and space is tight, such as close or copy.
- **Not for**: Primary or unfamiliar actions; a visible label is clearer. Try [Button](https://unseenui.com/components/button/).

## Good to know

- The hint opens on hover and on keyboard focus, not when focus arrives from a click or a script.

## Installation

```bash
npm install @stackunseen/ui
```

## Usage

```tsx
import { IconButton } from '@stackunseen/ui';
import '@stackunseen/ui/styles.css';

<IconButton variant="ghost" icon="retry" label="Refresh records" onClick={refreshRecords} />
```

## All props

| Prop | Type | Description |
| --- | --- | --- |
| `asChild` | `boolean` | Render the single child element instead of a button, passing it the button's presentation. |
| `href` | `string` | Renders a link with Button's presentation, for calls to action that navigate. |
| `icon` (required) | `IconName \| IconComponent` | A built-in icon name, or your own icon component (such as one from |
| `label` (required) | `string` |  |
| `rel` | `string` | With href. |
| `target` | `string` | With href. |
| `variant` | `"link" \| "primary" \| "secondary" \| "outline" \| "ghost" \| "danger"` |  |

## Keyboard

Tab reveals the label hint. Enter or Space activates the button; Escape dismisses the hint. A toggle should expose aria-pressed.

## Works with

[ToggleGroup](https://unseenui.com/components/toggle-group/), [Chip](https://unseenui.com/components/chip/), [CopyButton](https://unseenui.com/components/copy-button/), [AppearanceToggle](https://unseenui.com/components/appearance-toggle/), [Button](https://unseenui.com/components/button/)

Page: https://unseenui.com/components/icon-button/
