# Spinner

Indeterminate loading spinner, sized to match an `Icon`. Decorative (`aria-hidden`) by default; with `label` it is a `progressbar` named by the label.

## Use for

- an indeterminate loading indicator
- a spinner standing in for an icon

## Practices

- Do: Pass a localized `label` when the spinner is the only sign of progress.
- Don't: Render a spinner inside a button by hand. Use `SubmitButton` instead.
- Don't: Show it as soon as work starts. Gate it with `useSpinDelay` so it does not flash.

## API reference

### Spinner

Renders a `span` and forwards its ref. Carries `data-size`.

Slot: `cl-spinner`

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `size` | `'sm' \| 'md'` | `'md'` | `sm` or `md`, matching the `Icon` sizes. |
| `label` | `string` |  | Accessible name. Makes the spinner a `progressbar` instead of decorative. |

## Examples

### Decorative

```tsx
<Spinner />
```

### Announced

```tsx
<Spinner size='sm' label={t('loading')} />
```

## Related

- `SubmitButton`
- [useSpinDelay](/docs/hooks/use-spin-delay.md)
- [Skeleton](/docs/components/skeleton.md)
