Skip to content
WebJs
Menu

Visually or semantically separates content.

WebJs UI
The Foundation for your Design System
A set of beautifully designed components that you can customize, extend, and build on.
import { html } from '@webjsdev/core';
import { separatorClass } from '#components/ui/separator.ts';

export default function SeparatorDemo() {
  return html`
    <div class="flex max-w-sm flex-col gap-4 text-sm">
      <div class="flex flex-col gap-1.5">
        <div class="leading-none font-medium">WebJs UI</div>
        <div class="text-muted-foreground">
          The Foundation for your Design System
        </div>
      </div>
      <div role="none" data-slot="separator" data-orientation="horizontal" class=${separatorClass()}></div>
      <div>
        A set of beautifully designed components that you can customize, extend,
        and build on.
      </div>
    </div>
  `;
}
View Code

Installation

pnpm dlx @webjsdev/ui add separator

Usage

import { separatorClass } from '#components/ui/separator.ts';
<div role="none" data-orientation="horizontal" class=${separatorClass()}></div>

Vertical

Use data-orientation="vertical" for a vertical separator.

Blog
Docs
Source
import { html } from '@webjsdev/core';
import { separatorClass } from '#components/ui/separator.ts';

export default function SeparatorVertical() {
  return html`
    <div class="flex h-5 items-center gap-4 text-sm">
      <div>Blog</div>
      <div role="none" data-slot="separator" data-orientation="vertical" class=${separatorClass({ orientation: 'vertical' })}></div>
      <div>Docs</div>
      <div role="none" data-slot="separator" data-orientation="vertical" class=${separatorClass({ orientation: 'vertical' })}></div>
      <div>Source</div>
    </div>
  `;
}
View Code

Vertical separators between menu items with descriptions.

Settings Manage preferences
Account Profile & security
import { html } from '@webjsdev/core';
import { cn } from '#lib/utils/cn.ts';
import { separatorClass } from '#components/ui/separator.ts';

export default function SeparatorMenu() {
  return html`
    <div class="flex items-center gap-2 text-sm md:gap-4">
      <div class="flex flex-col gap-1">
        <span class="font-medium">Settings</span>
        <span class="text-xs text-muted-foreground">
          Manage preferences
        </span>
      </div>
      <div role="none" data-slot="separator" data-orientation="vertical" class=${separatorClass({ orientation: 'vertical' })}></div>
      <div class="flex flex-col gap-1">
        <span class="font-medium">Account</span>
        <span class="text-xs text-muted-foreground">
          Profile &amp; security
        </span>
      </div>
      <div role="none" data-slot="separator" data-orientation="vertical" class=${cn(separatorClass({ orientation: 'vertical' }), 'hidden md:block')}></div>
      <div class="hidden flex-col gap-1 md:flex">
        <span class="font-medium">Help</span>
        <span class="text-xs text-muted-foreground">Support &amp; docs</span>
      </div>
    </div>
  `;
}
View Code

List

Horizontal separators between list items.

Item 1
Value 1
Item 2
Value 2
Item 3
Value 3
import { html } from '@webjsdev/core';
import { separatorClass } from '#components/ui/separator.ts';

export default function SeparatorList() {
  return html`
    <div class="flex w-full max-w-sm flex-col gap-2 text-sm">
      <dl class="flex items-center justify-between">
        <dt>Item 1</dt>
        <dd class="text-muted-foreground">Value 1</dd>
      </dl>
      <div role="none" data-slot="separator" data-orientation="horizontal" class=${separatorClass()}></div>
      <dl class="flex items-center justify-between">
        <dt>Item 2</dt>
        <dd class="text-muted-foreground">Value 2</dd>
      </dl>
      <div role="none" data-slot="separator" data-orientation="horizontal" class=${separatorClass()}></div>
      <dl class="flex items-center justify-between">
        <dt>Item 3</dt>
        <dd class="text-muted-foreground">Value 3</dd>
      </dl>
    </div>
  `;
}
View Code

RTL

To enable RTL support, see the RTL configuration guide.

WebJs UI
الأساس لنظام التصميم الخاص بك
مجموعة من المكونات المصممة بشكل جميل يمكنك تخصيصها وتوسيعها والبناء عليها.
import { html } from '@webjsdev/core';
import { separatorClass } from '#components/ui/separator.ts';

const translations = {
  en: {
    dir: 'ltr',
    values: {
      title: 'WebJs UI',
      subtitle: 'The Foundation for your Design System',
      description:
        'A set of beautifully designed components that you can customize, extend, and build on.',
    },
  },
  ar: {
    dir: 'rtl',
    values: {
      title: 'WebJs UI',
      subtitle: 'الأساس لنظام التصميم الخاص بك',
      description:
        'مجموعة من المكونات المصممة بشكل جميل يمكنك تخصيصها وتوسيعها والبناء عليها.',
    },
  },
  he: {
    dir: 'rtl',
    values: {
      title: 'WebJs UI',
      subtitle: 'הבסיס למערכת העיצוב שלך',
      description:
        'סט של רכיבים מעוצבים בצורה יפה שאתה יכול להתאים אישית, להרחיב ולבנות עליהם.',
    },
  },
};

export default function SeparatorRtl() {
  const lang = 'ar';
  const { dir, values: t } = translations[lang];

  return html`
    <div class="flex max-w-sm flex-col gap-4 text-sm" dir=${dir} lang=${lang}>
      <div class="flex flex-col gap-1.5">
        <div class="leading-none font-medium">${t.title}</div>
        <div class="text-muted-foreground">${t.subtitle}</div>
      </div>
      <div role="none" data-slot="separator" data-orientation="horizontal" class=${separatorClass()}></div>
      <div>${t.description}</div>
    </div>
  `;
}
View Code

API Reference

separatorClass

separatorClass() returns the classes for a divider. Put them on an empty element. The orientation is read from the element's data-orientation attribute, not from an option, so the same classes draw a horizontal or a vertical line.

AttributeTypeDefault
data-orientation"horizontal" | "vertical""horizontal"
role"none" | "separator""none"
aria-orientation"horizontal" | "vertical"-

A purely decorative divider takes role="none", the default for a separator. A divider that carries meaning takes role="separator" plus aria-orientation, so assistive technology announces it.