# DotsLoader

Three dots that light up in turn, a lighter alternative to `CircularLoader` for inline "typing" or "loading" states. It is a `role="progressbar"` named by `label`; `label=""` makes it decorative. Each dot takes a color of the data palette: `--dots-loader-color` sets one color for all of them.

```ts
import { DotsLoader } from '@likable-hair/svelte';
```

Category: simple. Source: `src/lib/components/simple/loaders/DotsLoader.svelte`.

## Examples

### Dots

Three dots that light up in turn, for small inline states such as "typing". `--dots-loader-color` sets one color for all dots, `--dots-loader-size` their size.

```svelte
<script lang="ts">
	import { DotsLoader } from '@likable-hair/svelte';
</script>

<div class="row">
	<DotsLoader />
	<div class="bubble">
		<DotsLoader label="Giulia is typing" --dots-loader-size="7px" --dots-loader-color="var(--global-color-text-3)" />
	</div>
	<DotsLoader --dots-loader-size="12px" --dots-loader-gap="8px" />
</div>

<style>
	.row {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		gap: 32px;
	}

	.bubble {
		display: inline-flex;
		padding: 12px 14px;
		border-radius: 16px 16px 16px 4px;
		background: var(--global-color-surface-2);
	}
</style>
```

## Props

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `label` | `string` |  | Accessible name. An empty string makes the loader decorative (hidden from screen readers). Defaults to "Loading", in the language of `locale`. |
| `locale` | `string` |  | BCP 47 locale of the texts: `it` and `en` are built in, other languages fall back to English. Defaults to the one set with `setDefaultLocale`, else `en`. |
| `class` | `string` | `''` | Extra classes on the root element. |

It also accepts the native attributes and events of `<span>` (for example `id`, `title`, `aria-label`, `onkeydown`), which are forwarded to the element.

## CSS variables

For a single instance, pass them as style props: `<DotsLoader --dots-loader-color="tomato">`. The `--dots-loader-default-*` defaults apply to the whole app: override them in `:root` or in a theme.

| Per-instance variable | Default |
| --- | --- |
| `--dots-loader-gap` | `--dots-loader-default-gap`: `6px` |
| `--dots-loader-duration` | `--dots-loader-default-duration`: `1.2s` |
| `--dots-loader-size` | `--dots-loader-default-size`: `9px` |
| `--dots-loader-color-1` | `--dots-loader-default-color-1`: `var(--global-color-data-1)` |
| `--dots-loader-color` |  |
| `--dots-loader-dim-opacity` | `--dots-loader-default-dim-opacity`: `0.25` |
| `--dots-loader-color-2` | `--dots-loader-default-color-2`: `var(--global-color-data-3)` |
| `--dots-loader-color-3` | `--dots-loader-default-color-3`: `var(--global-color-data-2)` |
