Web and native

Separator in kanso-ui 0.59.0, for React.

import { Separator } from '@kanso-labs/kanso-ui'

A 1px rule between items, horizontal or vertical, in the outline variant colour that borders use.

It draws the three forms of the Material Design divider page: full width, inset by 16dp at the leading end, and middle-inset by 16dp at both ends. The insets follow the writing direction and work on a vertical rule too.

What you provide

  • Nothing but a place to sit. A horizontal rule spans its container. A vertical rule has no length of its own: it takes the height of its flex or grid parent, so put it in a row.

Props

PropTypeDefaultDescription
decorativebooleanfalseTakes the rule out of the accessibility tree, for a divider that only draws a line between things that already say where each starts — the sections of a `DisclosureGroup`, or rows that are each a control. A reader then hears nothing between them rather than "separator" at every one. The rule draws the same either way.
inset'both' | 'none' | 'start''none'How far the rule is held off the edges it runs between. `start` holds it 16px off the leading end, where Kanso's inset list starts its rows; `both` holds it off each end. The inset follows the writing mode rather than a fixed side.
labelReactNode—Draws Kanso's now line in place of the hairline: this label in an accent pill, "Now · 14:32", then a 2px accent rule across the rest of the row. It marks the current time in a list ordered by time, between the last entry before it and the first after it, once per list. A screen reader reads the label in its place, and is not told of a separator. Horizontal only, and never decorative, since the label is what it says.
orientation'horizontal' | 'vertical''horizontal'Which way the rule runs. A vertical separator takes its length from a flex or grid parent, and is one line of the text around it, `1em`, in any other. Defaults to whatever the container asks for — a `Toolbar` asks for the rule across its own direction — and to horizontal outside one.

Also takes the props of Omit<SeparatorProps$1, 'orientation'>.

Example

import { Separator, Stack, Text } from '@kanso-labs/kanso-ui'

<Stack gap="none">
  <Text variant="bodyMedium">First item</Text>
  <Separator inset="start" />
  <Text variant="bodyMedium">Second item</Text>
</Stack>

<Stack direction="row" gap="md" align="center">
  <Text variant="labelLarge">First</Text>
  <Separator orientation="vertical" />
  <Text variant="labelLarge">Second</Text>
</Stack>

The design’s classes

k-divider, k-now, k-now__label, k-now__line, with the row hairline from k-item. Maps to Separator in kanso-ui and react-native-kanso-ui; the now line is new in Kanso.