@@ -41,16 +41,18 @@ pn.extension()
4141
4242# Create a simple split layout
4343split = Split(
44- pn.pane.Markdown(" ## Left Panel\n Content here" ),
45- pn.pane.Markdown(" ## Right Panel\n More content" ),
44+ pn.pane.Markdown(" ## Left Panel\n Content here" , width = 150 ),
45+ pn.pane.Markdown(" ## Right Panel\n More content" , width = 150 ),
4646 sizes = (50 , 50 ), # Equal sizing initially
47- min_size = 100 , # Minimum 100px for each panel
48- show_buttons = True
47+ min_size = 150 , # Minimum 150px for each panel
48+ sizing_mode = " stretch_both " ,
4949)
5050
5151split.servable()
5252```
5353
54+ ![ Quick Start Example] ( docs/assets/images/quick-start.gif )
55+
5456## Usage Examples
5557
5658### Basic Horizontal Split
@@ -59,30 +61,35 @@ split.servable()
5961import panel as pn
6062from panel_splitjs import HSplit
6163
62- pn.extension()
64+ pn.extension(sizing_mode = " stretch_width " )
6365
6466left_panel = pn.Column(
6567 " # Main Content" ,
6668 pn.widgets.TextInput(name = " Input" ),
67- pn.pane.Markdown(" This is the main content area." )
69+ pn.pane.Markdown(" This is the main content area." ),
70+ margin = 25 , # To separate toggle button and column
6871)
6972
7073right_panel = pn.Column(
7174 " # Sidebar" ,
7275 pn.widgets.Select(name = " Options" , options = [" A" , " B" , " C" ]),
76+ margin = 25 , # To separate toggle button and column
7377)
7478
7579split = HSplit(
7680 left_panel,
7781 right_panel,
7882 sizes = (70 , 30 ), # 70% left, 30% right
79- min_size = 200 , # Minimum 200px for each panel
80- show_buttons = True
83+ min_size = 300 , # Minimum 300px for each panel
84+ sizing_mode = " stretch_width" ,
85+ height = 250 ,
8186)
8287
8388split.servable()
8489```
8590
91+ ![ Basic Horizontal Split Example] ( docs/assets/images/basic-horizontal-split.png )
92+
8693### Vertical Split
8794
8895``` python
@@ -97,13 +104,42 @@ bottom_panel = pn.pane.Markdown("## Bottom Section\nFooter content")
97104split = VSplit(
98105 top_panel,
99106 bottom_panel,
100- sizes = (60 , 40 ),
101- min_size = 150
107+ sizes = (70 , 30 ),
108+ min_size = 200 ,
109+ height = 600 ,
110+ sizing_mode = " stretch_width"
111+ )
112+
113+ split.servable()
114+ ```
115+
116+ ![ Basic Vertical Split Example] ( docs/assets/images/basic-vertical-split.png )
117+
118+ ### Show Buttons
119+
120+ ``` python
121+ import panel as pn
122+ from panel_splitjs import Split
123+
124+ pn.extension()
125+
126+ # Create a simple split layout
127+ split = Split(
128+ pn.pane.Markdown(" ## Left Panel\n Content here" , width = 150 , margin = (10 ,25 ,10 ,10 )),
129+ pn.pane.Markdown(" ## Right Panel\n More content" , width = 150 , margin = (10 ,10 ,10 ,25 )),
130+ sizes = (50 , 50 ), # Equal sizing initially
131+ min_size = 150 , # Minimum 150px for each panel
132+ show_buttons = True ,
133+ sizing_mode = " stretch_both" ,
102134)
103135
104136split.servable()
105137```
106138
139+ Note: We add ` margin ` to the ` Markdown ` panes to not overlay the buttons onto them.
140+
141+ ![ Show Buttons Example] ( docs/assets/images/show-buttons.png )
142+
107143### Collapsible Sidebar
108144
109145``` python
@@ -113,24 +149,27 @@ from panel_splitjs import Split
113149pn.extension()
114150
115151# Start with right panel collapsed
152+ button = pn.widgets.Button(name = " Toggle Sidebar" )
153+
116154split = Split(
117- pn.pane.Markdown(" ## Main Content" ),
118- pn.pane.Markdown(" ## Collapsible Sidebar" ),
155+ pn.Column(pn. pane.Markdown(" ## Main Content" ), button ),
156+ pn.pane.Markdown(" ## Collapsible Sidebar" , margin = ( 10 , 10 , 10 , 25 ) ),
119157 collapsed = 1 , # 0 for first panel, 1 for second panel, None for not collapsed
120- expanded_sizes = (65 , 35 ), # When expanded, 65% main, 35% sidebar
121- show_buttons = True ,
122- min_size = (200 , 200 ) # Minimum 200px for each panel
158+ expanded_sizes = (80 , 20 ), # When expanded, 80% main, 20% sidebar
159+ sizing_mode = " stretch_both" ,
123160)
124161
125162# Toggle collapse programmatically
126- button = pn.widgets.Button( name = " Toggle Sidebar " )
163+
127164def toggle (event ):
128165 split.collapsed = None if split.collapsed == 1 else 1
129166button.on_click(toggle)
130167
131- pn.Column(button, split) .servable()
168+ split.servable()
132169```
133170
171+ ![ Collapsible Sidebar Example] ( docs/assets/images/Collapsible-sidebar.gif )
172+
134173### Multi-Panel Split
135174
136175``` python
@@ -146,12 +185,15 @@ multi = MultiSplit(
146185 pn.pane.Markdown(" ## Panel 3" ),
147186 sizes = (30 , 40 , 30 ), # Three panels with custom sizing
148187 min_size = 100 , # Minimum 100px for each panel
149- orientation = " horizontal"
188+ orientation = " horizontal" ,
189+ sizing_mode = " stretch_both" ,
150190)
151191
152192multi.servable()
153193```
154194
195+ ![ MultiSplit Example] ( docs/assets/images/multisplit.png )
196+
155197## API Reference
156198
157199### Split
@@ -166,7 +208,7 @@ The main split panel component for creating two-panel layouts with collapsible f
166208- ` max_size ` (int | tuple, default=None): Maximum sizes in pixels - single value applies to both panels, tuple for individual sizes
167209- ` min_size ` (int | tuple, default=0): Minimum sizes in pixels - single value applies to both panels, tuple for individual sizes
168210- ` orientation ` (str, default="horizontal"): Either ` "horizontal" ` or ` "vertical" `
169- - ` show_buttons ` (bool, default=True ): Show collapse/expand toggle buttons on the divider
211+ - ` show_buttons ` (bool, default=False ): Show collapse/expand toggle buttons on the divider
170212- ` sizes ` (tuple, default=(50, 50)): Initial percentage sizes of the panels
171213- ` snap_size ` (int, default=30): Snap to minimum size at this offset in pixels
172214- ` step_size ` (int, default=1): Step size in pixels at which panel sizes can be changed
@@ -207,21 +249,24 @@ from panel_splitjs import Split
207249
208250pn.extension()
209251
210- chat = pn.chat.ChatInterface()
211- output = pn.Column(" # Output Area" )
252+ with pn.config.set(sizing_mode = " stretch_width" ):
253+ chat = pn.chat.ChatInterface(margin = (5 ,25 ,5 ,5 ))
254+ output = pn.Column(" # Output Area" )
212255
213256split = Split(
214257 chat,
215258 output,
216259 collapsed = None , # Both panels visible
217260 expanded_sizes = (50 , 50 ),
218- show_buttons = True ,
219- min_size = ( 300 , 300 ) # Minimum 300px for each panel
261+ min_size = ( 600 , 300 ), # Minimum 600px for the first panel, 300px for the second panel
262+ sizing_mode = " stretch_both " ,
220263)
221264
222265split.servable()
223266```
224267
268+ ![ Chat Example] ( docs/assets/images/chat-example.png )
269+
225270### Dashboard with Collapsible Controls
226271
227272``` python
@@ -230,26 +275,30 @@ from panel_splitjs import Split
230275
231276pn.extension()
232277
233- controls = pn.Column(
234- pn.widgets.Select(name = " Dataset" , options = [" A" , " B" , " C" ]),
235- pn.widgets.IntSlider(name = " Threshold" , start = 0 , end = 100 ),
236- pn.widgets.Button(name = " Update" )
237- )
278+ with pn.config.set(sizing_mode = " stretch_width" ):
279+ controls = pn.Column(
280+ pn.widgets.Select(name = " Dataset" , options = [" A" , " B" , " C" ]),
281+ pn.widgets.IntSlider(name = " Threshold" , start = 0 , end = 100 ),
282+ pn.widgets.Button(name = " Update" ),
283+ margin = (5 ,20 ,5 ,5 ),
284+ )
238285
239- visualization = pn.pane.Markdown(" ## Main Visualization Area" )
286+ visualization = pn.pane.Markdown(" ## Main Visualization Area" )
240287
241288split = Split(
242289 controls,
243290 visualization,
244- collapsed = 0 , # Start with controls collapsed
245- expanded_sizes = ( 25 , 75 ),
291+ sizes = ( 20 , 80 ),
292+ min_size = ( 300 , 0 ),
246293 show_buttons = True ,
247- min_size = ( 250 , 400 ) # Minimum sizes for each panel
294+ sizing_mode = " stretch_both " ,
248295)
249296
250297split.servable()
251298```
252299
300+ ![ Dashboard with Collapsible Controls] ( docs/assets/images/dashboard-with-Collapsible-controls.png )
301+
253302### Responsive Layout with Size Constraints
254303
255304``` python
@@ -259,18 +308,21 @@ from panel_splitjs import Split
259308pn.extension()
260309
261310split = Split(
262- pn.pane.Markdown(" ## Panel 1\n Responsive content" ),
263- pn.pane.Markdown(" ## Panel 2\n More responsive content" ),
311+ pn.pane.Markdown(" ## Panel 1\n Responsive content" , sizing_mode = " stretch_width " , margin = ( 5 , 25 , 5 , 5 ) ),
312+ pn.pane.Markdown(" ## Panel 2\n More responsive content" , sizing_mode = " stretch_width " , margin = ( 5 , 5 , 5 , 25 ) ),
264313 sizes = (50 , 50 ),
265314 min_size = 200 , # Minimum 200px per panel
266315 max_size = 800 , # Maximum 800px per panel
267316 snap_size = 50 , # Snap to min size when within 50px
268- show_buttons = True
317+ show_buttons = True ,
318+ sizing_mode = " stretch_both" ,
269319)
270320
271321split.servable()
272322```
273323
324+ ![ Responsive Layout with Size Constraints] ( docs/assets/images/responsive-layout-with-size-constraints.png )
325+
274326### Complex Multi-Panel Layout
275327
276328``` python
@@ -280,10 +332,11 @@ from panel_splitjs import MultiSplit
280332pn.extension()
281333
282334# Create a four-panel layout
283- sidebar = pn.Column(" ## Sidebar" , pn.widgets.Select(options = [" A" , " B" , " C" ]))
284- main = pn.pane.Markdown(" ## Main Content Area" )
285- detail = pn.pane.Markdown(" ## Detail Panel" )
286- console = pn.pane.Markdown(" ## Console Output" )
335+ with pn.config.set(sizing_mode = " stretch_width" ):
336+ sidebar = pn.Column(" ## Sidebar" , pn.widgets.Select(options = [" A" , " B" , " C" ]))
337+ main = pn.pane.Markdown(" ## Main Content Area" )
338+ detail = pn.pane.Markdown(" ## Detail Panel" )
339+ console = pn.pane.Markdown(" ## Console Output" )
287340
288341multi = MultiSplit(
289342 sidebar,
@@ -292,12 +345,15 @@ multi = MultiSplit(
292345 console,
293346 sizes = (15 , 40 , 25 , 20 ), # Custom sizing for each panel
294347 min_size = (150 , 300 , 200 , 150 ), # Individual minimums
295- orientation = " horizontal"
348+ orientation = " horizontal" ,
349+ sizing_mode = " stretch_both" ,
296350)
297351
298352multi.servable()
299353```
300354
355+ ![ Complex Multi-Panel Layout] ( docs/assets/images/complex-multi-panel-layout.png )
356+
301357### Nested Splits
302358
303359``` python
@@ -310,21 +366,25 @@ pn.extension()
310366left = pn.pane.Markdown(" ## Left Panel" )
311367
312368# Right side has a vertical split
313- top_right = pn.pane.Markdown(" ## Top Right" )
314- bottom_right = pn.pane.Markdown(" ## Bottom Right" )
315- right = VSplit(top_right, bottom_right, sizes = (60 , 40 ))
316-
317- # Main horizontal split
318- layout = HSplit(
319- left,
320- right,
321- sizes = (30 , 70 ),
322- min_size = 200
323- )
369+ with pn.config.set(sizing_mode = " stretch_both" ):
370+ top_right = pn.pane.Markdown(" ## Top Right" )
371+ bottom_right = pn.pane.Markdown(" ## Bottom Right" )
372+ right = VSplit(top_right, bottom_right, sizes = (60 , 40 ))
373+
374+ # Main horizontal split
375+ layout = HSplit(
376+ left,
377+ right,
378+ sizes = (30 , 70 ),
379+ min_size = 200 ,
380+ sizing_mode = " stretch_both" ,
381+ )
324382
325383layout.servable()
326384```
327385
386+ ![ Nested Splits] ( docs/assets/images/nested-splits.png )
387+
328388## Development
329389
330390This project is managed by [ pixi] ( https://pixi.sh ) .
@@ -352,6 +412,15 @@ pixi run build
352412pixi run test
353413```
354414
415+ ### Pre-commit
416+
417+ Before committing the first time please install ` pre-commit ` :
418+
419+ ``` bash
420+ pip install pre-commit
421+ pre-commit install
422+ ```
423+
355424## Contributing
356425
357426Contributions are welcome! Please feel free to submit a Pull Request.
0 commit comments