Separator

updated

A line that separates content, horizontal or vertical, with an optional label.

Demo

kappa-ui

Vue components you copy into your project.

Blog
Docs
Source

Open Props in the corner of the example to try size.

size sets the thickness, from 1px for xs, the default, to 5px for xl.

Installation

Usage

<script setup lang="ts">
import { Separator } from '@/components/ui/separator'
</script>

<template>
  <Separator />
  <Separator orientation="vertical" />
  <Separator label="or" />
</template>

Separator is Reka UI's separator with kappa-ui's styles. It is a --border line across the full width, or with orientation="vertical" the full height of its parent, so a vertical one sits in a row with a set height, such as h-5 or a stretching flex item.

As in shadcn, the separator is decorative by default: it gets role="none" and screen readers skip it. When it divides content that a reader should know is divided, set :decorative="false"; it then gets role="separator" and, when vertical, aria-orientation.

Examples

Label

label, or the default slot for richer content, puts text in the middle of the line. A vertical separator keeps the text upright between its two halves.

Label
or continue with
Monthly
or
Yearly

API Reference

class is also accepted and merged over the base classes.

CSS variables

VariableDefaultDescription
--separator-size1pxThe line's thickness, set by size. Set it in class, as in [--separator-size:0.5px], for a thickness outside the scale.

Data attributes

data-slotAttributesDescription
separatordata-orientation, data-sizeThe separator. Without a label it is the line itself. data-size is xs when left out.
separator-line—One of the two lines on either side of a label.
separator-label—The label between the lines.

Changelog

  1. registry 0.22.0

    3adb637 — A length class on Separator now applies: h-4 on a vertical separator or w-12 on a horizontal one sizes it instead of losing to the data-[orientation] rules that stretched it. The orientation's classes are picked from the prop, and data-orientation stays on the element.

  2. registry 0.21.0

    e5495ef — size works the same way everywhere. Every component exports its size type (AlertSize, BadgeSize, CardSize, CheckboxSize, RadioSize, SwitchSize, EmptySize, InputFloatingSize, ItemSize, ListboxSize, SeparatorSize, SliderSize, StepperSize, TabsSize, TextareaSize, TimelineSize) and the props take it without null; Button-based parts take ButtonSize, Input TextControlSize, SelectTrigger SelectSize and Tree TreeSize. ToggleGroup and ToolbarToggleGroup carry data-size on the group as well. Table's row heights moved into tableSize, so a class on DataTable's ui.table overrides --table-row-h at every size, not only at md.

  3. registry 0.13.0

    93e57a0 — Every size on the control scale is named xs to xl; default and the bare icon are gone. To move over:

    - Button: size="default" becomes size="md", or leave size out; size="icon" becomes size="icon-md". The full set is xs to xl and icon-xs to icon-xl. Toggle, ToggleGroup, ToggleGroupItem, the Toolbar parts, AlertDialogAction, AlertDialogCancel and ToastAction take the same names; Button, Toggle and ToggleGroup default to md, the Toolbar parts keep sm and ToastAction keeps xs. InputGroupButton keeps its own xs, sm, icon-xs and icon-sm, 24 and 32px to fit inside the group, xs by default. Pagination hands its md to Button as it is. Button, Toggle and ToggleGroupItem set data-variant, data-color and data-size even when you leave them at their defaults. - AlertDialogContent: size="default" becomes size="md", still the default; sm is unchanged. The size option of useConfirm's confirm, alert and prompt takes the same names. - Table and DataTable: density becomes size, data-density becomes data-size, and the TableDensity type is now TableSize. sm, md and lg keep their 36, 44 and 52px rows; xs (28px) and xl (60px) are new, and DataTable's virtual row estimates cover them. The cells' padding above and below the text is now --table-cell-py on the table: 8px as before, 3px at xs. At xs, DataTable's sort buttons and expand and group toggles shrink to fit the row. The table-density example is now table-sizes. - DrawerMenu: size takes xs to xl like Menu and reads the control scale, plus room for a thumb. sm, md and lg keep their 40, 48 and 56px rows, padding and icons; xs is 36px and xl 64px. Overriding a --control-* token on :root now resizes DrawerMenu rows as well. - Select and Combobox: the list opens at the trigger's or anchor's size instead of always at md, so <SelectTrigger size="xl"> opens an xl list. size on SelectContent or ComboboxList picks another. Behind an as-child button, set size on ComboboxAnchor to match the button. The Select list now sets its menu variables on SelectContent instead of its viewport, so a class such as [--menu-item-height:2.5rem] on SelectContent reaches the items. - Input, Textarea, InputFloating, SelectTrigger, ComboboxAnchor and Separator set data-size with the default filled in, and the anchor sets data-variant too. With as-child, the anchor leaves the button's own data-variant and data-size alone.