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
Copy and paste the following code into your project.
/**
* Separator: horizontal or vertical divider. Tier-1 class helper. For
* accessibility, set `role="separator"` + `aria-orientation` on the
* element (or `role="none"` for purely decorative use).
*
* shadcn parity:
* Separator (orientation: horizontal | vertical, decorative: bool)
* → separatorClass({ orientation }) + role + data-orientation
*
* A11y (required for accessible output): a meaningful divider needs
* role="separator" plus aria-orientation. A purely decorative one needs
* role="none" (or aria-hidden="true") so assistive tech does not announce
* an empty separator.
*
* Design tokens used: --border.
*
* @example
* ```html
* <div role="none" class=${separatorClass()} data-orientation="horizontal"></div>
* <div role="separator" aria-orientation="vertical"
* class=${separatorClass({ orientation: 'vertical' })}
* data-orientation="vertical"></div>
* ```
*/
import { cn } from '../lib/utils.ts';
const BASE =
'shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch';
export type SeparatorOrientation = 'horizontal' | 'vertical';
export function separatorClass(_opts: { orientation?: SeparatorOrientation } = {}): string {
// Orientation is driven by the `data-orientation` attribute on the element,
// not by class variants: matches shadcn. The opts arg is reserved for
// future variants (e.g. dashed) and to keep the signature stable.
return cn(BASE);
}
Update the import paths to match your project setup.
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
Menu
Vertical separators between menu items with descriptions.
Settings
Manage preferences
Account
Profile & security
Help
Support & docs
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 & 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 & 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.
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.