Files
webawesome/docs/pages/components/divider.md
Cory LaViska 015429e05d sl => wa
2023-09-08 13:45:49 -04:00

3.2 KiB

meta, layout
meta layout
title description
Divider Dividers are used to visually separate or group elements.
component
<wa-divider></wa-divider>
import WaDivider from '@shoelace-style/shoelace/dist/react/divider';

const App = () => <WaDivider />;

Examples

Width

Use the --width custom property to change the width of the divider.

<wa-divider style="--width: 4px;"></wa-divider>

{% raw %}

import WaDivider from '@shoelace-style/shoelace/dist/react/divider';

const App = () => <WaDivider style={{ '--width': '4px' }} />;

{% endraw %}

Color

Use the --color custom property to change the color of the divider.

<wa-divider style="--color: tomato;"></wa-divider>

{% raw %}

import WaDivider from '@shoelace-style/shoelace/dist/react/divider';

const App = () => <WaDivider style={{ '--color': 'tomato' }} />;

{% endraw %}

Spacing

Use the --spacing custom property to change the amount of space between the divider and it's neighboring elements.

<div style="text-align: center;">
  Above
  <wa-divider style="--spacing: 2rem;"></wa-divider>
  Below
</div>

{% raw %}

import WaDivider from '@shoelace-style/shoelace/dist/react/divider';

const App = () => (
  <>
    Above
    <WaDivider style={{ '--spacing': '2rem' }} />
    Below
  </>
);

{% endraw %}

Vertical

Add the vertical attribute to draw the divider in a vertical orientation. The divider will span the full height of its container. Vertical dividers work especially well inside of a flex container.

<div style="display: flex; align-items: center; height: 2rem;">
  First
  <wa-divider vertical></wa-divider>
  Middle
  <wa-divider vertical></wa-divider>
  Last
</div>

{% raw %}

import WaDivider from '@shoelace-style/shoelace/dist/react/divider';

const App = () => (
  <div
    style={{
      display: 'flex',
      alignItems: 'center',
      height: '2rem'
    }}
  >
    First
    <WaDivider vertical />
    Middle
    <WaDivider vertical />
    Last
  </div>
);

{% endraw %}

Menu Dividers

Use dividers in menus to visually group menu items.

<wa-menu style="max-width: 200px;">
  <wa-menu-item value="1">Option 1</wa-menu-item>
  <wa-menu-item value="2">Option 2</wa-menu-item>
  <wa-menu-item value="3">Option 3</wa-menu-item>
  <wa-divider></wa-divider>
  <wa-menu-item value="4">Option 4</wa-menu-item>
  <wa-menu-item value="5">Option 5</wa-menu-item>
  <wa-menu-item value="6">Option 6</wa-menu-item>
</wa-menu>

{% raw %}

import WaDivider from '@shoelace-style/shoelace/dist/react/divider';
import WaMenu from '@shoelace-style/shoelace/dist/react/menu';
import WaMenuItem from '@shoelace-style/shoelace/dist/react/menu-item';

const App = () => (
  <WaMenu style={{ maxWidth: '200px' }}>
    <WaMenuItem value="1">Option 1</WaMenuItem>
    <WaMenuItem value="2">Option 2</WaMenuItem>
    <WaMenuItem value="3">Option 3</WaMenuItem>
    <wa-divider />
    <WaMenuItem value="4">Option 4</WaMenuItem>
    <WaMenuItem value="5">Option 5</WaMenuItem>
    <WaMenuItem value="6">Option 6</WaMenuItem>
  </WaMenu>
);

{% endraw %}