# Divider

Line that separates content. Without content it is a native `<hr>` (a separator for assistive technology); with `label` or `children` the text sits in the middle of the line, as in "— or —", and stays readable. `variant="gradient"` paints the theme gradient faded at both ends, `orientation="vertical"` separates items in a row and stretches to its height. It has a margin only across the line (10px, `--divider-spacing`). Its state is exposed as `data-variant` and `data-orientation` for app CSS.

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

Category: simple. Source: `src/lib/components/simple/common/Divider.svelte`.

## Examples

### Solid and gradient

A native `<hr>` with 10px above and below. `variant="gradient"` uses the theme gradient faded at both ends.

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

<div class="card">
	<p>Cut and blow-dry · 45′</p>
	<Divider />
	<p>Color · 1h 30′</p>
	<Divider variant="gradient" />
	<p>Total · €95</p>
</div>

<style>
	.card {
		width: 100%;
		max-width: 360px;
		font-size: 14px;
	}

	p {
		margin: 0;
	}
</style>
```

### Text in the middle

With `label` (or any content as children) the text sits in the middle of the line and screen readers read it.

```svelte
<script lang="ts">
	import { mdiGoogle } from '@mdi/js';
	import { Button, Divider, SimpleTextField } from '@likable-hair/svelte';
</script>

<div class="sign-in">
	<Button variant="secondary" icon={mdiGoogle} --button-width="100%">Continue with Google</Button>
	<Divider label="or" />
	<SimpleTextField label="Email" type="email" placeholder="name@salon.com" />
	<Divider variant="gradient">Already a client?</Divider>
</div>

<style>
	.sign-in {
		display: grid;
		width: 100%;
		max-width: 320px;
	}
</style>
```

### Vertical

`orientation="vertical"` separates items in a row: in a flex row it is as tall as the row, with 10px on each side.

```svelte
<script lang="ts">
	import {
		mdiFormatBold,
		mdiFormatItalic,
		mdiFormatListBulleted,
		mdiFormatListNumbered,
		mdiLinkVariant
	} from '@mdi/js';
	import { Button, Divider } from '@likable-hair/svelte';
</script>

<div class="toolbar" role="toolbar" aria-label="Formatting">
	<Button buttonType="text" variant="secondary" icon={mdiFormatBold} aria-label="Bold" />
	<Button buttonType="text" variant="secondary" icon={mdiFormatItalic} aria-label="Italic" />
	<Divider orientation="vertical" />
	<Button buttonType="text" variant="secondary" icon={mdiFormatListBulleted} aria-label="Bulleted list" />
	<Button buttonType="text" variant="secondary" icon={mdiFormatListNumbered} aria-label="Numbered list" />
	<Divider orientation="vertical" variant="gradient" />
	<Button buttonType="text" variant="secondary" icon={mdiLinkVariant} aria-label="Link" />
</div>

<style>
	.toolbar {
		display: flex;
		align-items: center;
		padding: 4px;
		border: 1px solid var(--global-color-border);
		border-radius: var(--global-radius-md);
	}
</style>
```

## Props

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `variant` | `'solid' \| 'gradient'` | `'solid'` | Line style: `solid` uses `--divider-color`, `gradient` the theme gradient (`--global-gradient`) faded at both ends. |
| `orientation` | `'horizontal' \| 'vertical'` | `'horizontal'` | `vertical` separates items in a row: in a flex row it is as tall as the row, elsewhere at least `--divider-vertical-min-height`. |
| `label` | `string` |  | Text in the middle of the line, such as "or". The divider becomes a `<div>` and the text is read by screen readers. |
| `dividerElement` (bindable) | `HTMLElement` |  | The root element: the `<hr>`, or the `<div>` when there is text. |

## Snippets

| Name | Parameters | Description |
| --- | --- | --- |
| `children` |  | Content in the middle of the line, instead of `label`. |

## CSS variables

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

| Per-instance variable | Default |
| --- | --- |
| `--divider-color` | `--divider-default-color`: `var(--global-color-border-strong)` |
| `--divider-weight` | `--divider-default-weight`: `1px` |
| `--divider-spacing` | `--divider-default-spacing`: `10px` |
| `--divider-margin-top` |  |
| `--divider-margin-right` |  |
| `--divider-margin-bottom` |  |
| `--divider-margin-left` |  |
| `--divider-vertical-min-height` | `--divider-default-vertical-min-height`: `1em` |
| `--divider-radius` | `--divider-default-radius`: `var(--global-radius-full)` |
| `--divider-gap` | `--divider-default-gap`: `14px` |
| `--divider-label-color` | `--divider-default-label-color`: `var(--global-color-text-3)` |
| `--divider-label-font-family` | `--divider-default-label-font-family`: `inherit` |
| `--divider-label-font-size` | `--divider-default-label-font-size`: `11.5px` |
| `--divider-label-font-weight` | `--divider-default-label-font-weight`: `500` |
| `--divider-label-letter-spacing` | `--divider-default-label-letter-spacing`: `0.14em` |
| `--divider-label-text-transform` | `--divider-default-label-text-transform`: `uppercase` |

### Other defaults

| Variable | Value |
| --- | --- |
| `--divider-default-gradient-background` | `var(--global-gradient)` |
