Divider
<mo-divider> | MODivider
Dividers are used to visually separate or group elements.
<mo-divider></mo-divider>
import { MODivider } from '@metsooutotec/modes-web-components/dist/react'; const App = () => <MODivider />;
Examples
Width
Use the --width
custom property to change the width of the divider.
<mo-divider style="--width: 4px;"></mo-divider>
import { MODivider } from '@metsooutotec/modes-web-components/dist/react'; const App = () => <MODivider style={{ '--width': '4px' }} />;
Color
Use the --color
custom property to change the color of the divider.
<mo-divider style="--color: var(--mo-color-primary-7);"></mo-divider>
import { MODivider } from '@metsooutotec/modes-web-components/dist/react'; const App = () => <MODivider style={{ '--color': 'var(--mo-color-primary-7)' }} />;
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 <mo-divider style="--spacing: 2rem;"></mo-divider> Below </div>
import { MODivider } from '@metsooutotec/modes-web-components/dist/react'; const App = () => ( <> Above <MODivider style={{ '--spacing': '2rem' }} /> Below </> );
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 <mo-divider vertical></mo-divider> Middle <mo-divider vertical></mo-divider> Last </div>
import { MODivider } from '@metsooutotec/modes-web-components/dist/react'; const App = () => ( <div style={{ display: 'flex', alignItems: 'center', height: '2rem' }} > First <MODivider vertical /> Middle <MODivider vertical /> Last </div> );
Menu Dividers
Use dividers in menus to visually group menu items.
<mo-menu style="max-width: 200px"> <mo-menu-item value="1">Option 1</mo-menu-item> <mo-menu-item value="2">Option 2</mo-menu-item> <mo-menu-item value="3">Option 3</mo-menu-item> <mo-divider></mo-divider> <mo-menu-item value="4">Option 4</mo-menu-item> <mo-menu-item value="5">Option 5</mo-menu-item> <mo-menu-item value="6">Option 6</mo-menu-item> </mo-menu>
import { MODivider, MOMenu, MOMenuItem } from '@metsooutotec/modes-web-components/dist/react'; const App = () => ( <MOMenu style={{ maxWidth: '200px', border: 'solid 1px var(--mo-panel-border-color)', borderRadius: 'var(--mo-border-radius-medium)' }} > <MOMenuItem value="1">Option 1</MOMenuItem> <MOMenuItem value="2">Option 2</MOMenuItem> <MOMenuItem value="3">Option 3</MOMenuItem> <mo-divider /> <MOMenuItem value="4">Option 4</MOMenuItem> <MOMenuItem value="5">Option 5</MOMenuItem> <MOMenuItem value="6">Option 6</MOMenuItem> </MOMenu> );
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 using a bundler:
import '@metsooutotec/modes-web-components/dist/components/divider/divider.js';
To import this component as a React component:
import MODivider from '@metsooutotec/modes-web-components/dist/react/divider/';
To import this component using a script tag:
<script type="module" src="https://modes-web.metso.com/dist/components/cdn/components/divider/divider.js"></script>
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 |
---|---|---|
--color |
The color of the divider. | |
--width |
The width of the divider. | |
--spacing |
The spacing of the divider. |
Learn more about customizing CSS custom properties.