Separator#

A thin themed line used to visually divide sections of a layout. Renders horizontally by default and stretches to fill the available space.

Separator — light theme Separator — dark theme

Usage#

Orientation#

The default orientation is 'horizontal'. Pass orient='vertical' for a vertical divider; use length= to constrain its height.

# Vertical divider between breadcrumb items
with bs.HStack(gap=12, anchor_items="center"):
    bs.Label("Home")
    bs.Separator(orient="vertical", length=16)
    bs.Label("Products")
    bs.Separator(orient="vertical", length=16)
    bs.Label("About")
    bs.Separator(orient="vertical", length=16)
    bs.Label("Contact")
Separator vertical — light theme Separator vertical — dark theme

Accent colors#

By default the line color is derived from the active surface. Pass an accent= token to apply a semantic color.

bs.Separator(accent="default")
bs.Separator(accent="primary")
bs.Separator(accent="secondary")
bs.Separator(accent="info")
bs.Separator(accent="success")
bs.Separator(accent="warning")
bs.Separator(accent="danger")
Separator accents — light theme Separator accents — dark theme

Thickness#

The default thickness is 1 px (theme-controlled). Use thickness= for a heavier rule.

bs.Separator(accent="primary", thickness=1)
bs.Separator(accent="primary", thickness=2)
bs.Separator(accent="primary", thickness=4)
Separator thickness — light theme Separator thickness — dark theme

Widget sizing#

All widgets accept self-placement kwargs via **kwargs. The parent container determines which options apply — stack-based parents use stack kwargs, grid-based parents use grid kwargs. Unrecognised keys are silently ignored.

Stack#

Used inside VStack, HStack, App, and other stack containers.

fill

Fill direction: 'x', 'y', 'both', or 'none'.

expand

Grow to consume extra space in the parent. True or False.

anchor

Alignment when the widget does not fill the available slot: 'n', 's', 'e', 'w', 'center', 'nw', etc.

margin

External spacing in pixels. Accepts an integer (equal on all sides), a 2-tuple (horizontal, vertical), or a 4-tuple (left, top, right, bottom).

margin_x

Horizontal external spacing (left and right). Accepts an integer or a 2-tuple (left, right) for asymmetric spacing. Overrides the horizontal component of margin=.

margin_y

Vertical external spacing (top and bottom). Accepts an integer or a 2-tuple (top, bottom) for asymmetric spacing. Overrides the vertical component of margin=.

Grid#

Used inside a Grid container.

row / column

Zero-based row and column indices.

rowspan / columnspan

Number of rows or columns to span.

sticky

Alignment and fill within the grid cell. Any combination of 'n', 's', 'e', 'w' — e.g. 'ew' stretches horizontally, 'nsew' fills the entire cell.

margin

External spacing in pixels. Accepts an integer, a 2-tuple (horizontal, vertical), or a 4-tuple (left, top, right, bottom).

margin_x

Horizontal external spacing. Accepts an integer or (left, right).

margin_y

Vertical external spacing. Accepts an integer or (top, bottom).

API#

The complete reference for Separator lives on the Widgets API page. At a glance:

Separator

A horizontal or vertical dividing line.

Full Example#

 1
 2with bs.App(title="Separator Demo", size=(680, 520), padding=20, gap=24, fill_items='x') as app:
 3
 4    with bs.VStack(gap=10, fill_items='x'):
 5        bs.Label("Accent Colors", font="heading-sm")
 6        for accent in ("default", "primary", "secondary", "info", "success", "warning", "danger"):
 7            bs.Separator(accent=accent)
 8
 9    with bs.VStack(gap=10, fill_items='x'):
10        bs.Label("Thickness", font="heading-sm")
11        for t in (1, 2, 4):
12            bs.Separator(thickness=t, accent="primary")
13
14    with bs.VStack(gap=8, fill_items='x'):
15        bs.Label("Vertical Orientation", font="heading-sm")
16        with bs.HStack(gap=12, anchor_items="center"):
17            bs.Label("Home")
18            bs.Separator(orient="vertical", length=16)
19            bs.Label("Products")
20            bs.Separator(orient="vertical", length=16)
21            bs.Label("Contact")
22
23    # Full-width in-context examples
24    with bs.VStack(fill_items='x'):
25        bs.Label("In Context", font="heading-sm")
26        with bs.HStack(gap=32, anchor_items='n'):
27            with bs.VStack(gap=6, fill_items='x'):
28                bs.Label("Profile", font="heading-md")
29                bs.Separator()
30                bs.Label("Name: Ada Lovelace")
31                bs.Label("Role: Engineer")
32
33            with bs.VStack(gap=6, fill_items='x'):
34                bs.Label("Danger Zone", font="heading-md")
35                bs.Separator(accent="danger", thickness=2)
36                bs.Label("Irreversible action below", accent="danger")
37
38app.run()