Separator
Separator renders a semantic divider for visually grouping content. It supports horizontal and vertical orientations, optional centered labels, and configurable thickness and spacing.
Bootstrap Reference
Quick Start
from faststrap import Separator
# Horizontal divider
Separator()
# Vertical divider
Separator(orientation="vertical")
# Labeled divider
Separator(label="Section")
Visual Examples & Use Cases
1. Horizontal Separator
2. Vertical Separator
3. Labeled Separator
4. Custom Thickness and Spacing
Practical Functionality
1. Inside a Card
Card(
Card.Header("Settings"),
Card.Body(
Separator(label="General"),
# ... general settings
Separator(label="Security"),
# ... security settings
),
)
2. Inside a Stack
3. Vertical Separator in a Toolbar
Cluster(
Button("Save", variant="primary"),
Separator(orientation="vertical"),
Button("Cancel", variant="secondary"),
Separator(orientation="vertical"),
Button("Delete", variant="danger"),
)
Parameter Reference
| Parameter | Type | Default | Description |
|---|---|---|---|
orientation |
"horizontal" \| "vertical" |
"horizontal" |
Divider orientation. |
thickness |
int \| None |
None |
Border width in pixels (default: 1). |
spacing |
int \| None |
None |
Margin in Bootstrap spacing units (0–5). |
label |
str \| None |
None |
Centered text label on the divider. |
**kwargs |
Any |
{} |
Additional HTML attributes (cls, id, etc.). |
Accessibility
- Renders
role="separator"on the wrapper element. - Sets
aria-orientationto match theorientationparameter. - When
labelis provided, the text is wrapped in a<span>for screen readers.
API Reference
faststrap.components.layout.separator.Separator(*, orientation='horizontal', thickness=None, spacing=None, label=None, **kwargs)
Render a semantic separator/divider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
orientation
|
Literal['horizontal', 'vertical']
|
horizontal (default) or vertical |
'horizontal'
|
thickness
|
int | None
|
border width in px (default: 1) |
None
|
spacing
|
int | None
|
margin in Bootstrap spacing units (0-5) |
None
|
label
|
str | None
|
optional text label centered on the divider |
None
|
**kwargs
|
Any
|
Additional HTML attributes (cls, id, hx-, data-, etc.) |
{}
|
Returns:
| Type | Description |
|---|---|
Div
|
FastHTML Div element with separator styling |