Skip to main content

Provides split.js components for Panel.

Project description

panel-splitjs

CI conda-forge pypi-version python-version

A responsive, draggable split panel component for Panel applications, powered by split.js.

Features

  • Draggable divider - Resize panels by dragging the divider between them
  • Collapsible panels - Toggle panels open/closed with optional buttons
  • Flexible orientation - Support for both horizontal and vertical splits
  • Minimum size constraints - Enforce minimum panel sizes to prevent over-collapse
  • Smooth animations - Beautiful transitions when toggling panels
  • Customizable sizes - Control initial and expanded panel sizes
  • Invertible layout - Swap panel positions and button locations

Installation

Install via pip:

pip install panel-splitjs

Or via conda:

conda install -c conda-forge panel-splitjs

Quick Start

import panel as pn
from panel_splitjs import Split

pn.extension()

# Create a simple split layout
split = Split(
    pn.pane.Markdown("## Left Panel\nContent here"),
    pn.pane.Markdown("## Right Panel\nMore content"),
    sizes=(50, 50),  # Equal sizing
    show_buttons=True
)

split.servable()

Usage Examples

Basic Horizontal Split

import panel as pn
from panel_splitjs import HSplit

pn.extension()

left_panel = pn.Column(
    "# Main Content",
    pn.widgets.TextInput(name="Input"),
    pn.pane.Markdown("This is the main content area.")
)

right_panel = pn.Column(
    "# Sidebar",
    pn.widgets.Select(name="Options", options=["A", "B", "C"]),
)

split = HSplit(
    left_panel,
    right_panel,
    sizes=(70, 30),  # 70% left, 30% right
    show_buttons=True
)

split.servable()

Vertical Split

import panel as pn
from panel_splitjs import VSplit

pn.extension()

top_panel = pn.pane.Markdown("## Top Section\nHeader content")
bottom_panel = pn.pane.Markdown("## Bottom Section\nFooter content")

split = VSplit(
    top_panel,
    bottom_panel,
    sizes=(60, 40),
    orientation="vertical"
)

split.servable()

Collapsible Sidebar

import panel as pn
from panel_splitjs import Split

pn.extension()

# Start with sidebar collapsed
split = Split(
    pn.pane.Markdown("## Main Content"),
    pn.pane.Markdown("## Collapsible Sidebar"),
    collapsed=True,
    expanded_sizes=(65, 35),  # When expanded, 65% main, 35% sidebar
    show_buttons=True,
    min_sizes=(200, 200)  # Minimum 200px for each panel
)

# Toggle collapse programmatically
button = pn.widgets.Button(name="Toggle Sidebar")
button.on_click(lambda e: setattr(split, 'collapsed', not split.collapsed))

pn.Column(button, split).servable()

Inverted Layout

import panel as pn
from panel_splitjs import Split

pn.extension()

# Inverted: right panel collapses, button on right side
split = Split(
    pn.pane.Markdown("## Secondary Panel"),
    pn.pane.Markdown("## Main Content"),
    invert=True,  # Swap layout and button position
    collapsed=True,
    expanded_sizes=(35, 65),
    show_buttons=True
)

split.servable()

API Reference

Split

The main split panel component with full customization options.

Parameters:

  • objects (list): Two Panel components to display in the split panels
  • collapsed (bool, default=False): Whether the secondary panel is collapsed
  • expanded_sizes (tuple, default=(50, 50)): Percentage sizes when expanded (must sum to 100)
  • invert (bool, default=False): Swap panel positions and button locations (constant after init)
  • min_sizes (tuple, default=(0, 0)): Minimum sizes in pixels for each panel
  • orientation (str, default="horizontal"): Either "horizontal" or "vertical"
  • show_buttons (bool, default=False): Show collapse/expand toggle buttons
  • sizes (tuple, default=(100, 0)): Initial percentage sizes (must sum to 100)

HSplit

Horizontal split panel (convenience class).

Same parameters as Split but orientation is locked to "horizontal".

VSplit

Vertical split panel (convenience class).

Same parameters as Split but orientation is locked to "vertical".

Common Use Cases

Chat Interface with Output

import panel as pn
from panel_splitjs import Split

pn.extension()

chat = pn.chat.ChatInterface()
output = pn.Column("# Output Area")

split = Split(
    chat,
    output,
    collapsed=False,
    expanded_sizes=(50, 50),
    show_buttons=True,
    min_sizes=(300, 300)
)

split.servable()

Dashboard with Collapsible Controls

import panel as pn
from panel_splitjs import Split

pn.extension()

controls = pn.Column(
    pn.widgets.Select(name="Dataset", options=["A", "B", "C"]),
    pn.widgets.IntSlider(name="Threshold", start=0, end=100),
    pn.widgets.Button(name="Update")
)

visualization = pn.pane.Markdown("## Main Visualization Area")

split = Split(
    controls,
    visualization,
    collapsed=True,
    expanded_sizes=(25, 75),
    show_buttons=True,
    min_sizes=(250, 400)
)

split.servable()

Responsive Layout

import panel as pn
from panel_splitjs import Split

pn.extension()

# Automatically adjust to available space
split = Split(
    pn.pane.Markdown("## Panel 1\nResponsive content"),
    pn.pane.Markdown("## Panel 2\nMore responsive content"),
    sizes=(50, 50),
    min_sizes=(200, 200),  # Prevent panels from getting too small
    show_buttons=True
)

split.servable()

Development

This project is managed by pixi.

Setup

git clone https://github.com/panel-extensions/panel-splitjs
cd panel-splitjs

pixi run pre-commit-install
pixi run postinstall
pixi run test

Building

pixi run build

Testing

pixi run test

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

See LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

panel_splitjs-0.0.1a0.tar.gz (145.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

panel_splitjs-0.0.1a0-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file panel_splitjs-0.0.1a0.tar.gz.

File metadata

  • Download URL: panel_splitjs-0.0.1a0.tar.gz
  • Upload date:
  • Size: 145.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for panel_splitjs-0.0.1a0.tar.gz
Algorithm Hash digest
SHA256 3ab76daecb142dc00f9a60e609fbe1c9171609ec1fe3e625e3e38daf627155d2
MD5 8acf341367d6cbe42d005d6331d6ce9b
BLAKE2b-256 9f2feb50e17a780586cc10c6c8cb8af3fd3ec7db8068a533c98c5e771de86bbb

See more details on using hashes here.

Provenance

The following attestation bundles were made for panel_splitjs-0.0.1a0.tar.gz:

Publisher: build.yml on panel-extensions/panel-splitjs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file panel_splitjs-0.0.1a0-py3-none-any.whl.

File metadata

File hashes

Hashes for panel_splitjs-0.0.1a0-py3-none-any.whl
Algorithm Hash digest
SHA256 0fac49795af1ce710e243aa3cee50702fd1c67ce64e3de378b9af7b81fab1547
MD5 808f1d877e9ac6ba08c82274d1f754f6
BLAKE2b-256 088931cb2aa0aa21e4e1e541b3a0e22da9b6bfaa11f1c780d0da7cc8369ea5ec

See more details on using hashes here.

Provenance

The following attestation bundles were made for panel_splitjs-0.0.1a0-py3-none-any.whl:

Publisher: build.yml on panel-extensions/panel-splitjs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page