Divider component is used to visually separate and group elements horizontally or vertically.
import { Divider, Stack } from "@kesko/components";
export default () => (
<Stack>
Item
<Divider />
Item
<Divider />
Item
</Stack>
);<k-stack>
Item
<k-divider></k-divider>
Item
<k-divider></k-divider>
Item
</k-stack>import type { CSSProperties } from "react"
import { Divider } from "@kesko/components";
export default () => (
<Divider style={{"--k-divider-color": "var(--k-color-theme)"} as CSSProperties} />
);<k-divider style="--k-divider-color: var(--k-color-theme)"></k-divider>import { Divider, Stack } from "@kesko/components";
export default () => (
<Stack direction="row">
Item
<Divider orientation="vertical" />
Item
<Divider orientation="vertical" />
Item
</Stack>
);<k-stack direction="row">
Item
<k-divider orientation="vertical"></k-divider>
Item
<k-divider orientation="vertical"></k-divider>
Item
</k-stack>import type { CSSProperties } from "react"
import { Divider } from "@kesko/components";
export default () => (
<Divider style={{"--k-divider-size": "var(--k-size-border-button)"} as CSSProperties} />
);<k-divider style="--k-divider-size: var(--k-size-border-button)"></k-divider>Properties
| Name | Description | Type | Default |
|---|---|---|---|
orientation | The orientation of the divider. | "horizontal" | "vertical" | "horizontal" |
Styles
CSS custom properties provide finer-grained control than props. Prefer the props API when it suits your need.
| Name | Description | Default |
|---|---|---|
--k-divider-color | Overrides the divider color. | var(--k-color-border-divider) |
--k-divider-size | Overrides the divider size. | 1px |
Accessibility #
The divider is a role="separator" with the matching aria-orientation, so screen readers can announce it as a break between content. It is not focusable and carries no text content.
- Separate sections, not sentences. Place it between blocks of content or list groups, where a screen reader announcing “separator” adds meaning. Inside running text or a single label it only interrupts.
- Give vertical dividers a height. A vertical divider only shows a line as tall as its container, with one line of text as the minimum.
- Keep it empty. The component drops any children. A heading or a label that belongs to the next section goes after the divider, not inside it.
- Pick a stronger color when the line carries meaning. The default
--k-color-border-divideris a subtle neutral, about 2:1 against the page background, which is fine for a line that only tidies the layout. When people need to see the line to understand the page, use a color with 3:1 against the surface it sits on.
See the accessibility guidelines and the A11Y checklist for more details.
Usage #
There are two necessary parts to using the Divider component. The @kesko/components package and the CSS Framework are required. Everything else is optional:
npm install @kesko/components @kesko/csspnpm add @kesko/components @kesko/cssyarn add @kesko/components @kesko/cssbun add @kesko/components @kesko/cssOnce installed, load the CSS Framework in your app’s entry point or root layout:
import "@kesko/css";Then, you can import the Divider:
import { Divider } from "@kesko/components";Projects without React can get the same styles from @kesko/css by importing the components stylesheet as well:
@import "@kesko/css";
@import "@kesko/css/components";Resources #
Usage guidelines
Learn how to use the component library with React, Next.js, or basic HTML.
Localization
How to translate the components for multiple languages.
CSS Framework
Utilities and tokens for everything the components don’t cover.
Themes
How to customize the component library theme.
Accessibility checklist
Interactive, browser-based Kesko accessibility checklist.