# Icon button

Source: https://ecosphere.dev/docs/actions/icon-button (Ecosphere 1.5). Install `vue-ecosphere` for Vue 3 or `react-ecosphere` for React 18.2+/19: same components, props, markup and stylesheet.

Icon-only buttons: default, small, outlined, with an unread dot, and a star toggle.

`import { EcoIconButton } from "vue-ecosphere"`

## Default, small and outlined

Every icon-only button needs an aria-label, so label is required. The tooltip is extra, never a replacement for it.

Vue (vue-ecosphere):

```vue
<EcoIconButton label="Notifications" icon="notification-3-line" tip="Notifications" dot />
<EcoIconButton label="Filter requests" icon="filter-3-line" tip="Filter" size="sm" />
<EcoIconButton label="Save record" icon="bookmark-line" tip="Save record" outlined />
```

React (react-ecosphere):

```tsx
<EcoIconButton label="Notifications" icon="notification-3-line" tip="Notifications" dot />
<EcoIconButton label="Filter requests" icon="filter-3-line" tip="Filter" size="sm" />
<EcoIconButton label="Save record" icon="bookmark-line" tip="Save record" outlined />
```

## Star on / off

A toggled-on icon takes the filled glyph (ri-star-fill against ri-star-line); is-on carries the colour change only.

Vue (vue-ecosphere):

```vue
<EcoIconButton
  v-model:pressed="starred"
  star
  size="sm"
  label="Add star"
  label-pressed="Remove star"
  :tip="starred ? 'Starred' : 'Star'"
/>
```

React (react-ecosphere):

```tsx
const [starred, setStarred] = useState(false);

<EcoIconButton
  pressed={starred}
  onPressedChange={setStarred}
  star
  size="sm"
  label="Add star"
  labelPressed="Remove star"
  tip={starred ? "Starred" : "Star"}
/>
```

## Loading

The glyph becomes the spinner while the action runs; the button keeps its label and focus and ignores clicks.

Vue (vue-ecosphere):

```vue
<EcoIconButton label="Refresh requests" icon="refresh-line" tip="Refresh" :loading="refreshing" @click="refresh" />
<EcoIconButton label="Sync calendar" icon="loop-right-line" size="sm" outlined loading />
```

React (react-ecosphere):

```tsx
<EcoIconButton label="Refresh requests" icon="refresh-line" tip="Refresh" loading={refreshing} onClick={refresh} />
<EcoIconButton label="Sync calendar" icon="loop-right-line" size="sm" outlined loading />
```

## API

Vue (vue-ecosphere):

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `label` | `string` | — | Required. The accessible name (aria-label); the button has no visible text. |
| `icon` | `string` | — | RemixIcon name. Defaults to star-line for a star toggle. |
| `iconPressed` | `string` | — | Glyph while pressed — the filled variant (star-fill). |
| `labelPressed` | `string` | — | aria-label while pressed, e.g. “Remove star”. |
| `v-model:pressed` | `boolean` | — | Bind it to make a toggle (aria-pressed + is-on). Leave unbound for an action. |
| `size` | `"md" \| "sm"` | "md" | 36px or the small size for rows and toolbars. |
| `outlined` | `boolean` | false | Bordered variant (iconbtn--out). |
| `star` | `boolean` | false | Star toggle (iconbtn--star). |
| `dot` | `boolean` | false | Unread dot (iconbtn__dot). |
| `tip` | `string` | — | Hover tooltip (data-tip). Not a substitute for label. |
| `disabled` | `boolean` | false | Native disabled. |
| `loading` | `boolean` | false | The action is running: the glyph becomes a spinner, aria-busy is set and clicks (and toggles) are ignored. The label still names the action. |

React (react-ecosphere):

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `label` | `string` | — | Required. The accessible name (aria-label); the button has no visible text. |
| `icon` | `string` | — | RemixIcon name. Defaults to star-line for a star toggle. |
| `iconPressed` | `string` | — | Glyph while pressed — the filled variant (star-fill). |
| `labelPressed` | `string` | — | aria-label while pressed, e.g. “Remove star”. |
| `pressed / onPressedChange` | `boolean` | — | Pass it (or defaultPressed) to make a toggle (aria-pressed + is-on). Leave both unset for an action. |
| `size` | `"md" \| "sm"` | "md" | 36px or the small size for rows and toolbars. |
| `outlined` | `boolean` | false | Bordered variant (iconbtn--out). |
| `star` | `boolean` | false | Star toggle (iconbtn--star). |
| `dot` | `boolean` | false | Unread dot (iconbtn__dot). |
| `tip` | `string` | — | Hover tooltip (data-tip). Not a substitute for label. |
| `disabled` | `boolean` | false | Native disabled. |
| `loading` | `boolean` | false | The action is running: the glyph becomes a spinner, aria-busy is set and clicks (and toggles) are ignored. The label still names the action. |
