SplitPane
@experimental
Two-pane resizable layout for master/detail screens, documentation editors, code inspectors, productivity apps, and exam question banks.
Quick Start
from faststrap.components.layout import SplitPane
from faststrap import Card, ListGroup, ListGroupItem
SplitPane(
left=Card(
ListGroup(
ListGroupItem("Item 1", active=True),
ListGroupItem("Item 2"),
ListGroupItem("Item 3"),
),
header="Items",
),
right=Card("Select an item to view details.", header="Detail"),
initial_ratio="30/70",
)
Features
- Resizable divider (drag to adjust pane ratio)
- Collapsible left pane with toggle button
- Responsive: stacks vertically on mobile
- Configurable initial ratio
- Works with any FastHTML/Faststrap content in either pane
- Minimal JavaScript for drag-to-resize (progressive enhancement)
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
left |
Any |
required | Left/master pane content |
right |
Any |
required | Right/detail pane content |
initial_ratio |
str |
"30/70" |
Pane width ratio, e.g. "30/70" or "40/60" |
collapsible |
bool |
False |
Show collapse toggle for left pane |
collapsed |
bool |
False |
Start with left pane collapsed |
divider_width |
str |
"4px" |
Width of the draggable divider |
min_left |
str |
"200px" |
Minimum left pane width |
max_left |
str |
"50%" |
Maximum left pane width |
stack_on |
"sm" \| "md" \| "lg" \| "xl" \| "xxl" \| None |
"md" |
Breakpoint to stack vertically |
**kwargs |
Any |
Extra wrapper attributes |
Usage Examples
Exam Editor
from faststrap import SplitPane, Card, DataTable, Form
SplitPane(
left=Card(
DataTable(questions_df, page_size=20),
header="Question Bank",
),
right=Card(
Form(
FormGroup("Question", Input(name="question")),
FormGroup("Answer", Input(name="answer")),
),
header="Editor",
),
initial_ratio="40/60",
collapsible=True,
)
Documentation Editor
from faststrap import Markdown, SplitPane
SplitPane(
left=Markdown(doc_text),
right=Card("Inspector"),
initial_ratio="2/1",
stack_on="lg",
)
Notes
- Requires minimal JavaScript for the drag-to-resize interaction (progressive enhancement).
- On mobile, panes stack vertically automatically.
- Marked
@experimental.
API Reference
faststrap.components.layout.split_pane.SplitPane(left, right, *, initial_ratio='30/70', collapsible=False, collapsed=False, divider_width='4px', min_left='200px', max_left='50%', stack_on='md', **kwargs)
Two-pane resizable layout for master/detail, editors, and dashboards.
Minimal JavaScript for drag-to-resize. Stacks vertically on mobile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
left
|
Any
|
Left/master pane content. |
required |
right
|
Any
|
Right/detail pane content. |
required |
initial_ratio
|
str
|
CSS |
'30/70'
|
collapsible
|
bool
|
Show a collapse toggle for the left pane. |
False
|
collapsed
|
bool
|
Start with the left pane collapsed. |
False
|
divider_width
|
str
|
Width of the draggable divider. |
'4px'
|
min_left
|
str
|
Minimum width for the left pane. |
'200px'
|
max_left
|
str
|
Maximum width for the left pane. |
'50%'
|
stack_on
|
str | None
|
Bootstrap breakpoint at which panes stack vertically.
Pass |
'md'
|
**kwargs
|
Any
|
Additional HTML attributes for the wrapper. |
{}
|
Returns:
| Type | Description |
|---|---|
Div
|
FastHTML |
Source code in src/faststrap/components/layout/split_pane.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | |