Layout
TwSeparator
TwSeparator is a Blazor horizontal or vertical divider, with an optional label, line style, thickness and color.
Last updated
Horizontal
By default
TwSeparator is a full width line between blocks of content. Add margin with Class, for example Class="my-4".twblazor
A Tailwind CSS component library for Blazor.
Free and open source under the MIT License.
RAZOR
<div>
<p class="text-sm font-medium text-gray-900 dark:text-white">twblazor</p>
<p class="text-sm text-gray-600 dark:text-gray-300">A Tailwind CSS component library for Blazor.</p>
<TwSeparator Class="my-4" />
<p class="text-sm text-gray-600 dark:text-gray-300">Free and open source under the MIT License.</p>
</div>Vertical
Set
Orientation to SeparatorOrientation.Vertical for a line between items in a row, such as links or toolbar groups. It stretches to the height of the row.Blog
Docs
Source
RAZOR
<div class="flex h-5 items-center gap-4 text-sm text-gray-900 dark:text-white">
<span>Blog</span>
<TwSeparator Orientation="SeparatorOrientation.Vertical" />
<span>Docs</span>
<TwSeparator Orientation="SeparatorOrientation.Vertical" />
<span>Source</span>
</div>With a label
Set
Label to show text in the line, such as "or continue with" between ways to sign in. The label also names the separator for screen readers.
or continue with
RAZOR
<div class="mx-auto flex w-full max-w-sm flex-col gap-4">
<TwButton Label="Sign in with email" Color="Color.Primary" Class="w-full" />
<TwSeparator Label="or continue with" />
<div class="grid grid-cols-2 gap-3">
<TwButton Label="GitHub" StartIcon="Icon.Github" Variant="ButtonVariant.Outlined" Class="w-full" />
<TwButton Label="Google" StartIcon="Icon.Google" Variant="ButtonVariant.Outlined" Class="w-full" />
</div>
</div>Label alignment
Set
LabelAlign to put the label at the Start, Center or End of the line. Start and end follow the reading direction, so they swap sides in a right to left layout.
Start
Center
End
RAZOR
<div class="flex flex-col gap-4">
<TwSeparator Label="Start" LabelAlign="SeparatorLabelAlign.Start" />
<TwSeparator Label="Center" />
<TwSeparator Label="End" LabelAlign="SeparatorLabelAlign.End" />
</div>Custom content
Put any content, such as an icon, between the tags instead of a
Label. Screen readers do not read the content of a separator, so name it with AriaLabel.
Today · 3 unread
RAZOR
<div class="flex flex-col gap-4">
<TwSeparator AriaLabel="End of section">
<TwIcon Icon="Icon.Stars" />
</TwSeparator>
<TwSeparator AriaLabel="Today, 3 unread">
<strong>Today</strong> · 3 unread
</TwSeparator>
</div>Vertical with a label
A vertical separator can have a label too. The lines run above and below it.
Sign in
or
Create an account
RAZOR
<div class="flex h-32 items-stretch gap-4 text-sm text-gray-600 dark:text-gray-300">
<div class="flex flex-1 items-center justify-center">Sign in</div>
<TwSeparator Orientation="SeparatorOrientation.Vertical" Label="or" />
<div class="flex flex-1 items-center justify-center">Create an account</div>
</div>Line style and thickness
Set
Variant to Solid, Dashed or Dotted, and Thickness to Thin, Medium or Thick.
Solid
Dashed
Dotted
Medium
Thick dashed
RAZOR
<div class="flex flex-col gap-6">
<TwSeparator Label="Solid" />
<TwSeparator Label="Dashed" Variant="SeparatorVariant.Dashed" />
<TwSeparator Label="Dotted" Variant="SeparatorVariant.Dotted" />
<TwSeparator Label="Medium" Thickness="SeparatorThickness.Medium" />
<TwSeparator Label="Thick dashed" Thickness="SeparatorThickness.Thick" Variant="SeparatorVariant.Dashed" />
</div>Colors
Separators are neutral by default. Set
Color to color the line and its label, for example a danger colored "New messages" divider.
Primary
Success
New messages
RAZOR
<div class="flex flex-col gap-4">
<TwSeparator Label="Primary" Color="Color.Primary" />
<TwSeparator Label="Success" Color="Color.Success" />
<TwSeparator Label="New messages" Color="Color.Danger" Thickness="SeparatorThickness.Medium" />
<TwSeparator Color="Color.Info" Variant="SeparatorVariant.Dashed" />
</div>In a card
Separate groups of settings or fields inside a
TwCard. A line that only decorates, where the groups need no announced break, can be Decorative.Notifications
Choose how and when we get in touch.
Decorative separators
A separator is announced as a break between content, with its orientation. Set
Decorative when the line only decorates. It then has role="none", and without a label it is hidden from screen readers. A decorative label is read as plain text.
Announced as a separator
Read as plain text
RAZOR
<div class="flex flex-col gap-4">
<TwSeparator Label="Announced as a separator" />
<TwSeparator Label="Read as plain text" Decorative />
<TwSeparator Decorative />
</div>Accessibility
A separator has
role="separator" and aria-orientation, and is named by its Label. Name a separator with custom content with AriaLabel, or point AriaLabelledBy at a heading. A separator is not focusable, so the keyboard passes over it. The line is drawn as a border, so it stays visible in forced colors (Windows high contrast) mode, and start and end follow the reading direction.
Theme configuration
Styling is controlled by
TwBlazorTheme.Components (a TwSeparatorTheme), configured via the
AddTwBlazor() options callback described on the Get Started page.
Every property is a set of Tailwind classes, so changes are picked up by your own Tailwind build.
| Property | Type | Controls |
|---|---|---|
Base |
string | |
Horizontal |
string | |
Vertical |
string | |
LabeledHorizontal |
string | |
LabeledVertical |
string | |
HorizontalLine |
string | |
VerticalLine |
string | |
LabelLine |
string | |
LineStretch |
string | |
LineInset |
string | |
Label |
string | |
Thin |
string | |
Medium |
string | |
Thick |
string | |
Solid |
string | |
Dashed |
string | |
Dotted |
string | |
Neutral |
string |
Global Theme Configuration
These reuse shared design tokens configured once on
TwBlazorTheme, rather than being unique to this component.
| Property | Type | Controls |
|---|---|---|
Colors |
TwBlazorPalette |
Full reference: TwSeparatorTheme on the API docs.