# Spinner

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

A ring for work in flight — a save, a refresh — alone, with a caption, or over the content it is recomputing.

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

## Sizes

One role="status" named by label (visually hidden). It is honest for a second or two; a page or section loading its data for the first time takes a Skeleton instead.

Vue (vue-ecosphere):

```vue
<EcoSpinner size="sm" />
<EcoSpinner />
<EcoSpinner size="lg" label="Loading the timetable" />
```

React (react-ecosphere):

```tsx
<EcoSpinner size="sm" />
<EcoSpinner />
<EcoSpinner size="lg" label="Loading the timetable" />
```

## With a caption

Say what is happening, not just that something is.

Vue (vue-ecosphere):

```vue
<EcoSpinner caption="Recalculating totals…" label="Recalculating totals" />
```

React (react-ecosphere):

```tsx
<EcoSpinner caption="Recalculating totals…" label="Recalculating totals" />
```

## Over content

Wrap a region that is being refreshed. It stays in place, dimmed and inert, so nothing jumps; keep the control that started the work outside the wrapper. Replaces a-spin :spinning.

Vue (vue-ecosphere):

```vue
<EcoButton size="sm" icon="refresh-line" :loading="refreshing" @click="refresh">Refresh</EcoButton>

<EcoSpinner :spinning="refreshing" label="Refreshing the invoice">
  <EcoCard title="INV-2041">
    <EcoKeyValue :items="facts" />
  </EcoCard>
</EcoSpinner>
```

React (react-ecosphere):

```tsx
const [refreshing, setRefreshing] = useState(false);

<EcoButton size="sm" icon="refresh-line" loading={refreshing} onClick={refresh}>Refresh</EcoButton>

<EcoSpinner spinning={refreshing} label="Refreshing the invoice">
  <EcoCard title="INV-2041">
    <EcoKeyValue items={facts} />
  </EcoCard>
</EcoSpinner>
```

## Reduced motion

With prefers-reduced-motion the ring stops turning and pulses slowly instead. It never freezes: a still ring reads as a hang.

## API

Vue (vue-ecosphere):

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `size` | `"sm" \| "md" \| "lg"` | "md" | 16px inline with text, 24px, or 36px for a whole panel. |
| `label` | `string` | "Loading" | Accessible name in a visually hidden sr span inside role="status". Say what is loading. "" renders it decoratively (inside a control already marked aria-busy). |
| `caption` | `string` | — | Visible line under the ring that says what is happening. |
| `spinning` | `boolean` | true | Show the ring. When wrapping content, also the mask, aria-busy and inert. |
| `#default` | `slot` | — | Content to wrap. It stays rendered; while spinning it is dimmed under a mask, aria-busy and inert, with the ring centred. |

React (react-ecosphere):

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `size` | `"sm" \| "md" \| "lg"` | "md" | 16px inline with text, 24px, or 36px for a whole panel. |
| `label` | `string` | "Loading" | Accessible name in a visually hidden sr span inside role="status". Say what is loading. "" renders it decoratively (inside a control already marked aria-busy). |
| `caption` | `string` | — | Visible line under the ring that says what is happening. |
| `spinning` | `boolean` | true | Show the ring. When wrapping content, also the mask, aria-busy and inert. |
| `children` | `ReactNode` | — | Content to wrap. It stays rendered; while spinning it is dimmed under a mask, aria-busy and inert, with the ring centred. |
