Separator#
A thin themed line used to visually divide sections of a layout. Renders horizontally by default and stretches to fill the available space.
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")
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")
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)
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 direction: |
|
Grow to consume extra space in the parent. |
|
Alignment when the widget does not fill the available slot:
|
|
External spacing in pixels. Accepts an integer (equal on all
sides), a 2-tuple |
|
Horizontal external spacing (left and right). Accepts an integer
or a 2-tuple |
|
Vertical external spacing (top and bottom). Accepts an integer
or a 2-tuple |
Grid#
Used inside a Grid container.
|
Zero-based row and column indices. |
|
Number of rows or columns to span. |
|
Alignment and fill within the grid cell. Any combination of
|
|
External spacing in pixels. Accepts an integer, a 2-tuple
|
|
Horizontal external spacing. Accepts an integer or |
|
Vertical external spacing. Accepts an integer or |
API#
The complete reference for Separator lives on the
Widgets API page. At a glance:
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()