ui.page_sidebar
ui.page_sidebar(sidebar, *args, title=None, fillable=False, fillable_mobile=False, window_title=MISSING, lang=None, theme=None, **kwargs)
Create a page with a sidebar and a title.
Parameters
sidebar: Sidebar
-
Content to display in the sidebar.
*args: TagChild | TagAttrs = ()
-
UI elements.
title: Optional[str | Tag | TagList] = None
-
A title to display at the top of the page.
fillable: bool = False
-
Whether or not the main content area should be considered a fillable (i.e., flexbox) container.
fillable_mobile: bool = False
-
Whether or not
fillable
should apply on mobile devices. window_title: str | MISSING_TYPE = MISSING
-
The browser’s window title (defaults to the host URL of the page). Can also be set as a side effect via panel_title.
lang: Optional[str] = None
-
ISO 639-1 language code for the HTML page, such as
"en"
or"ko"
. This will be used as the lang in the<html>
tag, as in<html lang="en">
. The default,None
, results in an empty string. theme: Optional[str | Path |
Theme
|ThemeProvider
] = None-
A custom Shiny theme created using the Theme class, or a path to a local or online CSS file that will replace the Bootstrap CSS bundled by default with a Shiny app. This file should be a complete
bootstrap.css
orbootstrap.min.css
file.For advanced uses, you can also pass a Tagifiable object. In this case, Shiny will suppress the default Bootstrap CSS.
To modify the theme of an app without replacing the Bootstrap CSS entirely, use include_css to add custom CSS.
**kwargs: TagAttrValue = {}
-
Additional attributes passed to layout_sidebar.
Returns
Type | Description |
---|---|
Tag | A UI element. |
Examples
#| standalone: true
#| components: [editor, viewer]
#| layout: vertical
#| viewerHeight: 400
## file: app.py
import matplotlib.pyplot as plt
import numpy as np
from shiny import App, Inputs, Outputs, Session, render, ui
app_ui = ui.page_sidebar(
ui.sidebar(
ui.input_slider("n", "N", min=0, max=100, value=20),
),
ui.card(
ui.output_plot("plot"),
),
)
def server(input: Inputs, output: Outputs, session: Session):
@render.plot(alt="A histogram")
def plot() -> object:
np.random.seed(19680801)
x = 100 + 15 * np.random.randn(437)
fig, ax = plt.subplots()
ax.hist(x, input.n(), density=True)
return fig
app = App(app_ui, server)