Panel

Drop any Panel component – Tabulator, chat, indicators, a custom JS widget – into a Shiny app, with its Python callbacks running inside the Shiny server, no Panel server required.

Panel is HoloViz’s component library, built on Bokeh. @render_panel renders any of its pieces – a themed table, a chat interface, an indicator, a custom component – as one Shiny output, with its Python callbacks running inside the Shiny server and no Panel server to stand up. It has one accessor, param(name), which reads any parameter of the rendered object the way input.my_slider() reads a Shiny input.

hero

A themed Tabulator table, indicators, and a chat interface answering questions about the data, in one dashboard. Try the app.

Installation

pip install 'shinywidgets[panel]'

That installs panel and jupyter_bokeh. Panel’s own JavaScript and CSS – including per-extension bundles like Tabulator’s and ECharts’ – are served locally from the installed panel package, no CDN round trip.

Quick start

A pn.widgets.Tabulator with no server of its own:

import panel as pn
import plotly.express as px
from shiny.express import ui
from shinywidgets import render_panel

pn.extension("tabulator")

tips = px.data.tips()

ui.page_opts(title="Panel quickstart", fillable=True)

with ui.card(full_screen=True):
    ui.card_header("A Panel Tabulator, with no Panel server")

    @render_panel
    def table():
        return pn.widgets.Tabulator(
            tips,
            selectable=True,
            disabled=True,
            theme="bootstrap5",
            layout="fit_columns",
            sizing_mode="stretch_both",
        )

quickstart

pn.extension("tabulator") loads Tabulator’s JavaScript up front. disabled=True keeps cells from entering edit mode on click; sizing_mode="stretch_both" fills the card.

Overview

A look at what you can build. Click any of them to open the app, with its code, in Shinylive.

Any pane Panel knows how to draw (pn.pane.Vega, pn.pane.Plotly, pn.pane.Markdown, and more) works the same way.

Component library

A themed, formatted data table

Tabulator is Panel’s standout component: sortable, filterable, with per-column formatters (progress bars, currency, dates) and built-in themes, none of it requiring a line of custom CSS:

import panel as pn
import plotly.express as px
from shiny.express import ui
from shinywidgets import render_panel

pn.extension("tabulator")

gapminder_2007 = px.data.gapminder().query("year == 2007")

ui.page_opts(title="Tabulator formatters", fillable=True)

with ui.card(full_screen=True):
    ui.card_header("Life expectancy by country, 2007")

    @render_panel
    def table():
        return pn.widgets.Tabulator(
            gapminder_2007[["country", "continent", "lifeExp", "gdpPercap"]],
            selectable=True,
            disabled=True,
            theme="bootstrap5",
            layout="fit_columns",
            sizing_mode="stretch_both",
            formatters={
                "lifeExp": {
                    "type": "progress",
                    "min": 40,
                    "max": 85,
                    "color": ["#d7301f", "#fdae61", "#a6d96a", "#1a9850"],
                },
                "gdpPercap": {"type": "money", "symbol": "$", "precision": 0},
            },
        )

tabulator formatters

Dashboard indicators

pn.indicators gives you gauges, big-number tiles, and progress bars with no charting library of your own to wire up:

import panel as pn
from shiny.express import ui
from shinywidgets import render_panel

# Gauge is ECharts-backed; its JS loads through pn.extension() like any
# other extension-bundled pane.
pn.extension("echarts")

ui.page_opts(title="Panel indicators", fillable=True)

with ui.layout_columns(col_widths=[3, 3, 3, 3]):
    with ui.card():
        ui.card_header("Dial")

        @render_panel
        def dial():
            return pn.indicators.Dial(
                name="CPU", value=72, bounds=(0, 100), format="{value}%",
                colors=[(0.6, "green"), (0.85, "gold"), (1, "red")],
                sizing_mode="stretch_both",
            )

    with ui.card():
        ui.card_header("Gauge (ECharts)")

        @render_panel
        def gauge():
            return pn.indicators.Gauge(
                name="Load", value=64, bounds=(0, 100), sizing_mode="stretch_both",
            )

    with ui.card():
        ui.card_header("Number")

        @render_panel
        def number():
            return pn.indicators.Number(
                name="Monthly revenue", value=4239, format="${value:,.0f}",
                colors=[(5000, "red"), (10000, "green")],
                sizing_mode="stretch_both",
            )

    with ui.card():
        ui.card_header("Progress")

        @render_panel
        def progress():
            return pn.indicators.Progress(
                name="Deploy progress", value=64, sizing_mode="stretch_width",
                bar_color="success",
            )

indicators

Dial, Number, and Progress all stretch to fill their card with sizing_mode="stretch_both"/"stretch_width". Gauge is ECharts-backed, so it needs pn.extension("echarts") up front; without it the gauge renders blank with only a console error. A few other indicators (LinearGauge, Trend, BooleanStatus) don’t size responsively – give them explicit width=/height= instead.

A chat interface, no LLM

pn.chat.ChatInterface is a full chat UI – message history, avatars, timestamps – driven by a plain Python callback. It doesn’t need a language model to be useful: the callback can be anything, including a rules engine over your app’s own data (see the fleet dashboard in the gallery):

import panel as pn
from shiny.express import ui
from shinywidgets import render_panel

ui.page_opts(title="Panel chat", fillable=True)


def canned_reply(contents: str, user: str, instance: pn.chat.ChatInterface):
    words = len(contents.split())
    return f"You said {words} word{'s' if words != 1 else ''}: \"{contents}\""


with ui.card(full_screen=True):
    ui.card_header("pn.chat.ChatInterface -- no LLM, no Panel server")

    @render_panel
    def chat():
        return pn.chat.ChatInterface(
            callback=canned_reply,
            show_rerun=False,
            show_undo=False,
            sizing_mode="stretch_both",
        )

Typing a message and pressing send runs canned_reply inside the Shiny server and streams the reply back.

Bring your own JavaScript component

pn.custom.JSComponent turns a few lines of ESM into a two-way-synced component. model.<param> reads/writes the Python side; model.on(<param>, cb) reacts to Python-side changes:

import panel as pn
import param
from shiny.express import ui
from shinywidgets import render_panel


class Counter(pn.custom.JSComponent):
    count = param.Integer(default=0)

    _esm = """
    export function render({ model, el }) {
      const button = document.createElement("button");
      const render = () => button.innerText = `Count is ${model.count}`;
      render();
      button.onclick = () => model.count += 1;
      model.on("count", render);
      el.append(button);
    }
    """


ui.page_opts(title="Custom JSComponent", fillable=True)

with ui.card():
    ui.card_header("10 lines of ESM, two-way synced with Python")

    @render_panel
    def counter():
        return Counter()

Compose your own reusable component

pn.viewable.Viewer packages several widgets and some glue logic into one class with a single __panel__() method – a lightweight alternative to a Shiny module when the logic is Panel-only:

import panel as pn
import param
from shiny.express import ui
from shinywidgets import render_panel


class TemperatureConverter(pn.viewable.Viewer):
    """A reusable component: one widget, one computed display, no Shiny code."""

    celsius = param.Number(default=20, bounds=(-40, 120))

    def __panel__(self):
        slider = pn.widgets.FloatSlider.from_param(self.param.celsius, name="Celsius")
        fahrenheit = pn.bind(lambda c: f"**{c * 9 / 5 + 32:.1f} F**", self.param.celsius)
        return pn.Column(slider, pn.pane.Markdown(fahrenheit))


ui.page_opts(title="pn.viewable.Viewer", fillable=True)

with ui.card():
    ui.card_header("A Viewer bundles widgets + logic into one reusable component")

    @render_panel
    def converter():
        return TemperatureConverter()

Dragging the slider updates the Fahrenheit readout entirely through Panel’s own pn.bind() – no Shiny code involved. render_panel.value is the live TemperatureConverter instance, so Shiny can still reach into it reactively with converter.param("celsius").

Reacting to interaction

Read any parameter

Call param(name) in a reactive function and it re-runs whenever that parameter changes – from a browser gesture or a plain Python assignment, both handled the same way. examples/07_param_accessor.py drives the same slider both ways:

import panel as pn
from shiny import reactive
from shiny.express import input, render, ui
from shinywidgets import render_panel

ui.page_opts(title="param(name): read a Panel parameter like an input", fillable=True)

with ui.layout_columns(col_widths=[6, 6]):
    with ui.card():
        ui.card_header("Drag the slider, or bump it from Python")
        ui.input_action_button("bump", "+2 from Python")

        @render_panel
        def slider():
            return pn.widgets.IntSlider(name="Quantity", value=5, start=0, end=20)

    with ui.card():
        ui.card_header("slider.param('value') -- reads both kinds of change")

        @render.text
        def value():
            return f"quantity = {slider.param('value')}"


@reactive.effect
@reactive.event(input.bump)
def _():
    slider.value.value += 2

Dragging the slider and clicking the button both update the same readout – the same accessor, no branching code for which side changed.

A nested widget

param(name) only reaches parameters on the object you returned directly – not on anything nested inside it. examples/08_param_watch_nested.py returns a pn.Row(slider, button), so controls.param("value") raises (Row has no parameter 'value' – a layout, not a slider). Watch the nested widget directly instead, with Panel’s own .param.watch():

import panel as pn
from shiny import reactive
from shiny.express import render, ui
from shinywidgets import render_panel

ui.page_opts(title="A nested widget: param(name) can't reach it", fillable=True)

quantity = reactive.value(10)

with ui.layout_columns(col_widths=[6, 6]):
    with ui.card():
        ui.card_header("A slider + reset button, returned as one pn.Row")

        @render_panel
        def controls():
            slider = pn.widgets.IntSlider(name="Quantity", value=10, start=0, end=100)
            reset = pn.widgets.Button(name="Reset to 10")
            # controls.param("value") can't reach the slider: the rendered
            # object is the Row, which has no "value" of its own. Watch the
            # nested widget directly instead.
            slider.param.watch(lambda e: quantity.set(e.new), "value")
            reset.on_click(lambda _: setattr(slider, "value", 10))
            return pn.Row(slider, reset)

    with ui.card():
        ui.card_header("quantity (a Shiny reactive.value, set by the watcher)")

        @render.text
        def readout():
            return f"quantity = {quantity()}"

Dragging the slider, then clicking reset, both come through the watcher into quantity. This is the one place a plain Panel watcher feeding a reactive.value is still the right tool – the state you want lives one level below the object render_panel tracks.

Updating in place

Because render_panel.value is the live Panel object you returned, you can mutate it from a @reactive.effect instead of re-rendering. Re-rendering gives the user a brand-new table, resetting its sort order and selection; mutating .value in place keeps both, and sends only a small patch over the comm instead of rebuilding and resending the whole table:

import pandas as pd
import panel as pn
import plotly.express as px
from shiny import reactive
from shiny.express import input, ui
from shinywidgets import render_panel

pn.extension("tabulator")

gapminder = px.data.gapminder()
years = sorted(gapminder["year"].unique().tolist())

ui.page_opts(title="Updating a Panel table in place", fillable=True)

with ui.card(full_screen=True):
    ui.input_slider("year", "Year", min=years[0], max=years[-1], value=years[0], step=5)

    @render_panel
    def table():
        with reactive.isolate():
            df = gapminder[gapminder["year"] == input.year()]
        return pn.widgets.Tabulator(
            df[["country", "continent", "lifeExp", "pop"]],
            selectable=True, disabled=True, theme="bootstrap5",
            layout="fit_columns", sizing_mode="stretch_both",
        )


@reactive.effect
def _():
    # Mutating `.value` in place (instead of returning a new Tabulator from
    # the render function) keeps the table's current client-side sort, and
    # re-points the row selection at the same countries by name.
    tab = table.value
    kept = set(tab.value.iloc[tab.selection]["country"])
    df = gapminder[gapminder["year"] == input.year()][
        ["country", "continent", "lifeExp", "pop"]
    ]
    tab.value = df
    tab.selection = [i for i, c in enumerate(df["country"]) if c in kept]

Moving the year slider keeps the same sort order and the same selected countries, at new row positions since their relative rank changed:

Tabulator.selection holds row positions in the current .value, not stable row identifiers – replacing .value without re-pointing .selection leaves the old positions pointing at whatever rows happen to be there now, which is why the snippet above re-maps positions by country name after each update.

Linking widgets

A table drives a chart

table.param("selection") reads a Tabulator’s current row selection directly, which plugs into any other renderer – here a Shiny-native render_plotly chart with no Panel involvement:

import panel as pn
import plotly.express as px
from shiny.express import ui
from shinywidgets import render_panel, render_plotly

pn.extension("tabulator")

gapminder = px.data.gapminder()
latest = gapminder[gapminder["year"] == 2007].sort_values("pop", ascending=False).head(15)

ui.page_opts(title="Table selection drives a plotly chart", fillable=True)

with ui.layout_columns(col_widths=[7, 5]):
    with ui.card(full_screen=True):
        ui.card_header("The 15 most populous countries, 2007 (select some rows)")

        @render_panel
        def table():
            return pn.widgets.Tabulator(
                latest[["country", "continent", "pop"]],
                selectable=True, disabled=True, theme="bootstrap5",
                layout="fit_columns", sizing_mode="stretch_both",
            )

    with ui.card(full_screen=True):
        ui.card_header("Life expectancy trend of the selected countries")

        @render_plotly
        def trend():
            idx = table.param("selection")
            countries = table.value.value.iloc[idx]["country"].tolist() if idx else []
            df = gapminder[gapminder["country"].isin(countries)] if countries else gapminder.iloc[:0]
            return px.line(df, x="year", y="lifeExp", color="country", markers=True)

Cmd-clicking several rows populates the trend chart with their life-expectancy history. table.value (outside table’s own render function, where it’s fine) turns the selected positions back into rows – param("selection") gives you the indices, .value gives you the frame they index into.

Click a row for detail

A single-row click can drive a focused detail view – here a pn.indicators.Number in a separate card, mutated in place rather than re-rendered, so it never flickers:

import panel as pn
import plotly.express as px
from shiny import reactive
from shiny.express import ui
from shinywidgets import render_panel

pn.extension("tabulator")

latest = px.data.gapminder().query("year == 2007").sort_values("pop", ascending=False).head(15)

ui.page_opts(title="Click a row to update a detail card in place", fillable=True)

with ui.layout_columns(col_widths=[7, 5]):
    with ui.card(full_screen=True):
        ui.card_header("Click a country")

        @render_panel
        def table():
            return pn.widgets.Tabulator(
                latest[["country", "continent", "lifeExp", "pop"]],
                selectable=1, disabled=True, theme="bootstrap5",
                layout="fit_columns", sizing_mode="stretch_both",
            )

    with ui.card():
        ui.card_header("Selected country (updated in place, not re-rendered)")

        @render_panel
        def detail():
            # Built once with a placeholder; the effect below mutates it.
            return pn.indicators.Number(
                name="Select a row", value=0, format="{value:.1f} yrs",
                sizing_mode="stretch_width",
            )


@reactive.effect
def _():
    idx = table.param("selection")
    ind = detail.value
    if not idx:
        ind.name, ind.value = "Select a row", 0
    else:
        row = table.value.value.iloc[idx[0]]
        ind.name = f"{row['country']} -- life expectancy"
        ind.value = row["lifeExp"]

selectable=1 (an integer, not True) caps the Tabulator at a single selected row – useful whenever “click one row for detail” is the interaction you want, rather than multi-select.

A chat drives an indicator

param(name) works the same way regardless of which Panel component produces the state. Here, the number of messages in a pn.chat.ChatInterface (its objects parameter) drives a pn.indicators.Number in a sibling card:

import panel as pn
from shiny import reactive
from shiny.express import ui
from shinywidgets import render_panel


def canned_reply(contents: str, user: str, instance: pn.chat.ChatInterface):
    return f"Got it: \"{contents}\""


ui.page_opts(title="Chat activity drives an indicator", fillable=True)

with ui.layout_columns(col_widths=[8, 4]):
    with ui.card(full_screen=True):
        ui.card_header("Chat")

        @render_panel
        def chat():
            return pn.chat.ChatInterface(
                callback=canned_reply, show_rerun=False, show_undo=False,
                sizing_mode="stretch_both",
            )

    with ui.card():
        ui.card_header("Messages so far (a different Panel widget, updated in place)")

        @render_panel
        def counter():
            return pn.indicators.Number(
                name="Messages", value=0, sizing_mode="stretch_width",
            )


@reactive.effect
def _():
    counter.value.value = len(chat.param("objects"))

Accessor reference

Accessor Returns Before any interaction Across a re-render Default rate policy
param(name) the current value of the rendered object’s name parameter seeded value (the parameter’s value at render) re-seeded (follows the new .value object) none – read the parameter’s own throttled variant (e.g. value_throttled) if the library provides one

param(name)

  • Seeded at render with the parameter’s current value, and re-seeded on every re-render, following the new .value object – there’s no None to guard against, and no warm-up read needed.
  • Live from any reactive context, read at any time: a @render.* function, @reactive.calc, @reactive.effect, a download handler, an LLM tool callback. You don’t need a dedicated watcher wired up ahead of time.
  • Raises if .value isn’t a param.Parameterized object (e.g., the render function returned a raw DataFrame or string), or has no parameter by that name – the error names the object’s actual parameters.
  • Can’t be read inside this output’s own render function, the same restriction as every accessor: the render function builds a new object each time it runs, so there’s nothing stable to watch yet.
  • In-place mutation of a mutable parameter (e.g., appending to a param.List) needs an explicit obj.param.trigger(name) afterwards to be seen.

Tuning accessors

Rate limiting

param(name)’s rate policy is fixed at “none” regardless of render_panel(rate_policy=..., rate_delay=...), which have nothing to act on here. To throttle a continuously-changing parameter (a dragged slider firing on every pixel), read the library’s own throttled variant instead of adding rate limiting yourself – slider.param("value_throttled") for an IntSlider/FloatSlider. For anything else, add a plain time-based guard in a manual .param.watch() callback.

.read()

reactive_read() is built for ipywidget traits (.has_trait(), .observe()); a Panel object has neither – reactive_read(table.value, "selection") raises AttributeError. render_panel’s own generic .read(name) doesn’t reach param(name) either, and there’s no other trait on a Panel object worth reading reactively. Always call .param(name) directly.

Large data

Panel has no large-data story of its own – render_panel is a thin wrapper around whichever component you hand it, so scale depends entirely on that component’s own guide: itables or reactable for a large table, bokeh or holoviews for a large chart (Panel’s own panes render through Bokeh via jupyter_bokeh, the same engine as the HoloViews guide). Build the large-data version of the component directly and pass it to render_panel, or render it with that component’s own @render_* decorator alongside a render_panel output for anything Panel-specific – see Large data & performance for how the underlying approaches compare.

Layout and sizing

  • sizing_mode="stretch_both" (or "stretch_width"/"scale_both"/"scale_height") is what lets a Panel object fill its card. A plain pn.widgets.Tabulator(df) with no sizing_mode keeps its own intrinsic width even inside a full_screen=True card.
  • Stacking more than one ui.layout_columns() under ui.page_opts(fillable=True) needs the same care as any Shiny fill layout: give exactly one block room to grow, and pass fill=False (or an explicit height=) to the others, or they compete for the same vertical space and overlap. The fleet dashboard gallery app does this with a fixed-height indicator row above a filling table-and-chat row.

Gotchas

  • Panel templates aren’t supported: pn.template.FastListTemplate(...) (or any BaseTemplate subclass) raises AttributeError: 'FastListTemplate' object has no attribute 'get_root'. Use Shiny’s own page layouts instead.
  • A component that first appears after the initial render (e.g., inside a pn.bind()-driven conditional) can render blank with only a browser console error, if its pn.extension(...) wasn’t declared up front. Declare every extension you might use, at import time, to avoid this.
  • Build Panel objects inside your render function (or server()), not at the top level of a Shiny Core app. A module-level widget is constructed once and shared by every visitor under Shiny Core (Shiny Express already re-runs top-level code per session, so this is automatic there).
  • render_panel.widget isn’t useful for a Panel component. Use .value, the Panel object exactly as you returned it, for everything: reading state, mutating it in place, and passing it to .param.watch().

Learn more