Skip to content

Utilities

Separator

Bit.BlazorUI

BitSeparator visually separates content into groups. The line runs across its container unless Vertical stands it up, and any content given to it - a label, an icon - sits between the two segments of the line, where AlignContent puts it. The line is drawn by the theme and restyled through LineStyle, Size, Thickness and Color, while Border keeps it on the neutral tiers and Inset holds it off the ends of its container. To assistive technologies it reports itself as a separator, named by its content, and a separator that is only visual sugar opts out of being announced through Decorative.

Usage

Every example is live. Open its code to see exactly what produced the component running underneath.

Basic

On its own, a separator draws the theme's hairline across the full width of its container. Anything given as its content - a run of text, an icon, any markup - is flanked by the two segments of the line rather than laid over it, so the label reads on any surface underneath, and it also names the separator to assistive technologies.

Simple Separator


Separator with text


Separator with icon

Vertical

Vertical stands the line up between items laid out side by side. Inside a flex row it stretches to the height of the row on its own, so nothing needs measuring; anywhere else it takes its height from its container, which then needs a height of its own.

In a flex row of its own height:

Item 1 Item 2 Item 3


In a fixed-height flex row:

Item 1 Item 2 Item 3 Item 4 Item 5

AlignContent

AlignContent puts the content at the start, the middle or the end of the line, by sharing the line between the segment before it and the one after it. The alignment is direction-aware on a horizontal separator - start and end follow the reading direction - and on a vertical one it means the top, the middle or the bottom.

Horizontal








Vertical

ContentOffset

ContentOffset pushes the content away from the edge of the line it is aligned to, as any CSS length. It is the length of the short segment before the content, so a percentage measures against the length of the separator whichever way it runs. It only means anything while AlignContent is Start or End, since centered content has no edge to be offset from, and it is direction-aware: in RTL, a start-aligned offset pushes from the right.

Horizontal






Vertical

AutoSize

A horizontal separator is as wide as its container and a vertical one stretches to the height of the flex row it stands in. AutoSize gives that up and sizes the separator to its content instead, which is what a separator that should follow its flex container's align-items wants. A vertical separator that gives up its stretch is then only as tall as its own content, so an auto-sized one usually wants a container that stretches it.

While using inside a flex container with align-items css style:



Inset

Inset holds the separator off both ends of its container by any CSS length. An inset rule is what separates the rows of a list without cutting across the gutter the rows are indented by - the divider under an avatar row starts where the text does. It shortens a horizontal separator at both ends and a vertical one at the top and the bottom. It is padding, so a percentage measures against the width of the container either way, which is what CSS does with every percentage padding - a vertical separator wants a length.

Horizontal








Vertical

Item 1 Item 2 Item 3

Thickness

Thickness sets the weight of the line, as any CSS length. Leaving it unset keeps the hairline the theme draws every divider at; a heavier rule marks a stronger break in the content, and it is what gives a dotted or a double line the room its pattern needs.







Item 1 Item 2 Item 3

LineStyle

LineStyle draws the line solid, dashed, dotted or double. The default is solid; a dashed or a dotted rule reads as a softer break than a solid one, while a double rule reads as a stronger one. Both the dots and the gap of a double line need room, so those two want a Thickness heavier than a hairline.









Item 1 Item 2 Item 3 Item 4

Decorative

A separator reports itself to assistive technologies with the separator role, so a screen reader announces the boundary between groups. A page can also carry many rules that mean nothing - each announced as "separator" is noise - and Decorative removes such a separator from the accessibility tree while keeping its looks. The two below are visually identical; only what a screen reader hears differs.

Announced (role="separator")


Decorative (not announced)

Color

Color paints the line in one of the theme's roles rather than in a literal color, so every preset and both schemes re-skin it. Border instead picks between the neutral border tiers of the theme, and loses to Color where both are set. Background paints the patch the content sits on: the line is drawn either side of the content rather than behind it, so this is for content that should read as a chip of its own, and it is transparent by default.

Color:











Border:







Background:




Size

Size steps the weight of the line through the theme's sizes, where Thickness sets a length of its own and wins over it. Small is the hairline every divider of the theme is drawn at, and each step up multiplies it - so a preset that thins its hairline thins the whole scale with it.

Horizontal








Vertical

Small Medium Large Item

Style & Class

Style and Class reach the root element - a max-width with an auto margin, for one, shortens the line the way a length prop would - and Styles and Classes reach each part of the component by name: the Root and the Content the label renders in. The line itself is the two pseudo elements of the root - the segment before the content and the one after it - which the classed example below restyles into one gradient running the length of the separator.

Component's Style & Class:






Styles & Classes:



RTL

Dir renders the separator in a right-to-left direction, and with it the meaning of start and end flips: content aligned to the start of the line sits on the right. The direction is also cascaded, so a separator inside an RTL container inherits it.





API

Every parameter, public member, sub-class and enum this component exposes.

BitSeparator parameters

Name Type Default value Description
AlignContent BitSeparatorAlignContent? null Where the content should be aligned in the separator. Defaults to the center of the line.
AutoSize bool false Renders the separator with auto width or height, sizing it to its content instead of its container or the flex row it stands in.
Background BitColorKind? null The color kind of the background of the patch the content of the separator sits on. Defaults to transparent.
Border BitColorKind? null The color kind of the line of the separator, out of the neutral border tiers of the theme.
ChildContent RenderFragment? null The content of the Separator, it can be any custom tag or text. It sits between the two segments of the line and also names the separator to assistive technologies, so nothing focusable belongs in it.
Classes BitSeparatorClassStyles? null Custom CSS classes for different parts of the separator.
Color BitColor? null The general color of the line of the separator, painting it in one of the roles of the theme. Wins over Border.
ContentOffset string? null The offset of the content from the edge of the line it is aligned to, as any CSS length, where a percentage measures against the length of the separator. Only takes effect while AlignContent is Start or End.
Decorative bool false Removes the separator from the accessibility tree, for a separator that is purely visual and should not be announced.
Inset string? null Holds the separator off both ends of its container by this length, as any CSS length.
LineStyle BitSeparatorLineStyle? null The style the line of the separator is drawn in: solid, dashed, dotted or double.
Size BitSize? null The size of the line of the separator, out of the sizes of the theme. Thickness wins over it.
Styles BitSeparatorClassStyles? null Custom CSS styles for different parts of the separator.
Thickness string? null The thickness of the line of the separator, as any CSS length. Defaults to the weight of the current Size, which starts at the theme's divider hairline.
Vertical bool false Whether the element is a vertical separator. A vertical separator stretches to the height of the flex row it stands in, and takes it from its container anywhere else.

BitComponentBase parameters

Name Type Default value Description
AriaLabel string? null Gets or sets the accessible label for the component, used by assistive technologies.
Class string? null Gets or sets the CSS class name(s) to apply to the rendered element.
Dir BitDir? null Gets or sets the text directionality for the component's content.
ForceAnimation bool false Gets or sets a value indicating whether the component's animations play at their full duration even when reduced motion is requested.
HtmlAttributes Dictionary<string, object> new Dictionary<string, object>() Captures additional HTML attributes to be applied to the rendered element, in addition to the component's parameters.
Id string? null Gets or sets the unique identifier for the component's root element.
IsEnabled bool true Gets or sets a value indicating whether the component is enabled and can respond to user interaction.
Style string? null Gets or sets the CSS style string to apply to the rendered element.
TabIndex string? null Gets or sets the tab order index for the component when navigating with the keyboard.
Visibility BitVisibility BitVisibility.Visible Gets or sets the visibility state (visible, hidden, or collapsed) of the component.

BitComponentBase public members

Name Type Default value Description
UniqueId Guid Guid.NewGuid() Gets the readonly unique identifier for the component's root element, assigned when the component instance is constructed.
RootElement ElementReference Gets the reference to the root HTML element associated with this component.

BitSeparatorClassStyles properties

Name Type Default value Description
Root string? null Custom CSS classes/styles for the root element of the separator.
Content string? null Custom CSS classes/styles for the element wrapping the ChildContent of the separator, which is only rendered while the separator has content.

BitSeparatorAlignContent enum

Name Value Description
Start 0 The content sits at the start of the line - the top of a vertical separator.
Center 1 The content sits at the middle of the line, which is the default.
End 2 The content sits at the end of the line - the bottom of a vertical separator.

BitSeparatorLineStyle enum

Name Value Description
Solid 0 A continuous line, which is the default.
Dashed 1 A line of short dashes.
Dotted 2 A line of dots.
Double 3 Two parallel lines with a gap between them, which needs a line of at least three pixels to have room to be drawn.

BitSize enum

Name Value Description
Small 0 The small size.
Medium 1 The medium size.
Large 2 The large size.

BitColor enum

Name Value Description
Primary 0 Primary general color.
Secondary 1 Secondary general color.
Tertiary 2 Tertiary general color.
Info 3 Info general color.
Success 4 Success general color.
Warning 5 Warning general color.
SevereWarning 6 SevereWarning general color.
Error 7 Error general color.
PrimaryBackground 8 Primary background color.
SecondaryBackground 9 Secondary background color.
TertiaryBackground 10 Tertiary background color.
PrimaryForeground 11 Primary foreground color.
SecondaryForeground 12 Secondary foreground color.
TertiaryForeground 13 Tertiary foreground color.
PrimaryBorder 14 Primary border color.
SecondaryBorder 15 Secondary border color.
TertiaryBorder 16 Tertiary border color.

BitColorKind enum

Name Value Description
Primary 0 The primary color kind.
Secondary 1 The secondary color kind.
Tertiary 2 The tertiary color kind.
Transparent 3 The transparent color kind.

BitVisibility enum

Name Value Description
Visible 0 The content of the component is visible.
Hidden 1 The content of the component is hidden, but the space it takes on the page remains (visibility:hidden).
Collapsed 2 The component is hidden (display:none).

BitDir enum

Name Value Description
Ltr 0 Ltr (left to right) is to be used for languages that are written from the left to the right (like English).
Rtl 1 Rtl (right to left) is to be used for languages that are written from the right to the left (like Arabic).
Auto 2 Auto lets the user agent decide. It uses a basic algorithm as it parses the characters inside the element until it finds a character with a strong directionality, then applies that directionality to the whole element.

Feedback

Found a mistake, a gap, or something that could be clearer? Every page and every component is one click from its source.