Divider
<terra-divider> | TerraDivider
Dividers are used to visually separate or group elements.
<terra-divider></terra-divider>
Examples
Width
Use the --terra-divider-width custom property to change the width of the divider.
<terra-divider style="--terra-divider-width: 4px;"></terra-divider>
Color
Use the --terra-divider-color custom property to change the color of the divider.
<terra-divider style="--terra-divider-color: tomato;"></terra-divider>
Spacing
Use the --terra-divider-spacing custom property to change the amount of space between the
divider and its neighboring elements.
<div style="text-align: center;"> Above <terra-divider style="--terra-divider-spacing: 2rem;"></terra-divider> Below </div>
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 <terra-divider vertical></terra-divider> Middle <terra-divider vertical></terra-divider> Last </div>
Menu Dividers
Use dividers in menus to visually group menu items.
<terra-menu style="max-width: 200px;"> <terra-menu-item value="1">Option 1</terra-menu-item> <terra-menu-item value="2">Option 2</terra-menu-item> <terra-menu-item value="3">Option 3</terra-menu-item> <terra-divider></terra-divider> <terra-menu-item value="4">Option 4</terra-menu-item> <terra-menu-item value="5">Option 5</terra-menu-item> <terra-menu-item value="6">Option 6</terra-menu-item> </terra-menu>
[component-metadata:terra-divider]
Importing
If you’re using the autoloader or the traditional loader, you can ignore this section. Otherwise, feel free to use any of the following snippets to cherry pick this component.
To import this component from the CDN using a script tag:
<script type="module" src="https://cdn.jsdelivr.net/npm/@nasa-terra/components@0.0.138/cdn/components/divider/divider.js"></script>
To import this component from the CDN using a JavaScript import:
import 'https://cdn.jsdelivr.net/npm/@nasa-terra/components@0.0.138/cdn/components/divider/divider.js';
To import this component using a bundler:
import '@nasa-terra/components/dist/components/divider/divider.js';
To import this component as a React component:
import TerraDivider from '@nasa-terra/components/dist/react/divider';
Properties
| Name | Description | Reflects | Type | Default |
|---|---|---|---|---|
vertical
|
Draws the divider in a vertical orientation. |
|
boolean
|
false
|
updateComplete
|
A read-only promise that resolves when the component has finished updating. |
Learn more about attributes and properties.
Custom Properties
| Name | Description | Default |
|---|---|---|
--terra-divider-color
|
The color of the divider. | |
--terra-divider-width
|
The width of the divider. | |
--terra-divider-spacing
|
The spacing of the divider. |
Learn more about customizing CSS custom properties.