General
Separator
Usage#
import { WdsSeparatorComponent } from '@wds/angular/separator';my-4). Menus, fields and other components have their own separators (wds-dropdown-separator, wds-field-separator…); use wds-separator everywhere else.
Examples#
Default#
orientation="vertical" stretches to the height of a flex row (here h-5).
import { Component } from '@angular/core';
import { WdsSeparatorComponent } from '@wds/angular/separator';
@Component({
selector: 'app-separator-default-demo',
imports: [WdsSeparatorComponent],
template: `
<div class="flex w-full max-w-sm flex-col">
<div class="space-y-1">
<div class="text-sm font-medium leading-none">WDS Components</div>
<div class="text-sm text-muted-foreground">Web components for enterprise apps.</div>
</div>
<wds-separator class="my-4"></wds-separator>
<div class="flex h-5 items-center gap-4 text-sm">
<span>Blog</span>
<wds-separator orientation="vertical"></wds-separator>
<span>Docs</span>
<wds-separator orientation="vertical"></wds-separator>
<span>Source</span>
</div>
</div>
`,
})
export class SeparatorDefaultDemo {}Decorative#
decorative hides it from screen readers.
import { Component } from '@angular/core';
import { WdsSeparatorComponent } from '@wds/angular/separator';
@Component({
selector: 'app-separator-decorative-demo',
imports: [WdsSeparatorComponent],
template: `
<footer class="flex h-5 items-center gap-3 text-sm text-muted-foreground">
<a href="#" class="text-muted-foreground no-underline hover:text-foreground hover:underline">Privacy</a>
<wds-separator orientation="vertical" decorative></wds-separator>
<a href="#" class="text-muted-foreground no-underline hover:text-foreground hover:underline">Terms</a>
<wds-separator orientation="vertical" decorative></wds-separator>
<a href="#" class="text-muted-foreground no-underline hover:text-foreground hover:underline">Cookies</a>
</footer>
`,
})
export class SeparatorDecorativeDemo {}With label#
import { Component } from '@angular/core';
import { WdsButtonComponent } from '@wds/angular/button';
import { WdsSeparatorComponent } from '@wds/angular/separator';
import { WdsInputComponent } from '@wds/angular/input';
@Component({
selector: 'app-separator-label-demo',
imports: [WdsButtonComponent, WdsSeparatorComponent, WdsInputComponent],
template: `
<div class="flex w-full max-w-sm flex-col gap-4">
<wds-button variant="outline">Continue with GitHub</wds-button>
<wds-separator>Or continue with</wds-separator>
<wds-input type="email" aria-label="Email" placeholder="[email protected]"></wds-input>
<wds-button>Sign in with email</wds-button>
</div>
`,
})
export class SeparatorLabelDemo {}With icon#
<svg> (14px) or a wds-icon before the text of the label.
import { Component } from '@angular/core';
import { WdsSeparatorComponent } from '@wds/angular/separator';
import { WdsIconComponent } from '@wds/angular/icon';
@Component({
selector: 'app-separator-icon-demo',
imports: [WdsSeparatorComponent, WdsIconComponent],
template: `
<div class="flex w-full max-w-sm flex-col gap-6">
<wds-separator>
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect width="18" height="18" x="3" y="4" rx="2" /><path d="M16 2v4" /><path d="M8 2v4" /><path d="M3 10h18" /></svg>
Today
</wds-separator>
<wds-separator>
<wds-icon name="flag-outline" size="xs"></wds-icon>
Milestone 2
</wds-separator>
</div>
`,
})
export class SeparatorIconDemo {}List#
import { Component } from '@angular/core';
import { WdsBadgeComponent } from '@wds/angular/badge';
import { WdsSeparatorComponent } from '@wds/angular/separator';
@Component({
selector: 'app-separator-list-demo',
imports: [WdsBadgeComponent, WdsSeparatorComponent],
template: `
<div class="flex w-full max-w-sm flex-col rounded-lg border border-border">
<div class="flex items-center justify-between p-3 text-sm">
<span>Two-factor authentication</span>
<wds-badge variant="secondary">On</wds-badge>
</div>
<wds-separator decorative></wds-separator>
<div class="flex items-center justify-between p-3 text-sm">
<span>Login alerts</span>
<wds-badge variant="secondary">On</wds-badge>
</div>
<wds-separator decorative></wds-separator>
<div class="flex items-center justify-between p-3 text-sm">
<span>Trusted devices</span>
<span class="text-muted-foreground">3</span>
</div>
</div>
`,
})
export class SeparatorListDemo {}Order summary#
import { Component } from '@angular/core';
import { WdsSeparatorComponent } from '@wds/angular/separator';
@Component({
selector: 'app-separator-order-summary-demo',
imports: [WdsSeparatorComponent],
template: `
<div class="flex w-full max-w-xs flex-col gap-3 text-sm">
<div class="flex justify-between">
<span class="text-muted-foreground">Subtotal</span>
<span class="tabular-nums">$316.00</span>
</div>
<div class="flex justify-between">
<span class="text-muted-foreground">Shipping</span>
<span class="tabular-nums">$12.00</span>
</div>
<div class="flex justify-between">
<span class="text-muted-foreground">Tax</span>
<span class="tabular-nums">$25.28</span>
</div>
<wds-separator></wds-separator>
<div class="flex justify-between font-medium">
<span>Total</span>
<span class="tabular-nums">$353.28</span>
</div>
</div>
`,
})
export class SeparatorOrderSummaryDemo {}Color and size#
--wds-separator-color sets the color of the line and --wds-separator-size its thickness. The label takes the text color of the separator.
import { Component } from '@angular/core';
import { WdsSeparatorComponent } from '@wds/angular/separator';
@Component({
selector: 'app-separator-custom-demo',
imports: [WdsSeparatorComponent],
template: `
<div class="flex w-full max-w-sm flex-col gap-6 text-sm">
<wds-separator class="[--wds-separator-color:var(--wds-primary)] [--wds-separator-size:2px]"></wds-separator>
<wds-separator class="text-primary [--wds-separator-color:var(--wds-primary)]">Today</wds-separator>
</div>
`,
})
export class SeparatorCustomDemo {}API References#
wds-separator#
role="separator". When it only decorates (e.g. between links in a footer) set
decorative, so screen readers skip it.
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
| orientation | WdsSeparatorOrientation | 'horizontal' | |
| decorative | boolean | false | role="none"). |
Slots
| Slot | Description |
|---|---|
| (default) | <svg> icon (14px) or wds-icon. |
CSS parts (::part)
| Part | Description |
|---|---|
| base | |
| label |
CSS custom properties
| Property | Description |
|---|---|
| --wds-separator-color | --wds-border). |
| --wds-separator-size |
Accessibility#
Screen reader#
role="separator", and a vertical one also aria-orientation="vertical". Screen readers announce it between sections.
decorative sets role="none": use it when the line only decorates, e.g. between links or between rows that are already separate items.