API Reference Intro#
This website documents the public API of Shiny (for Python). See the Getting Started tutorial for a more approachable introduction to the API. The left-hand sidebar lists the full public API, without any grouping, but the sections below (linked to the right-hand sidebar) break it into semantically similar groups. Most of the reference pages include a live example app at the bottom, or at least mention another page with a relevant example.
We’ve intentionally designed Shiny’s API so that you can from shiny import *
to get
access to most of what you need for most apps without introducing an excessive amount of
namespace pollution. Namely, it gives you:
User interface (UI/HTML) helpers, available via the
ui
subpackage.To avoid clashing with this
ui
namespace when you dofrom shiny import *
, you’ll want to name you UI object something else, likeapp_ui
.
Reactive programming utilities, available via the
reactive
subpackage.Decorators for rendering
output
, available via therender
subpackage.3rd party packages that want to implement their own rendering functions are encouraged to use a @render_foo() naming convention so users may import with from mypkg import render_foo.
A handful of other things you’ll want for most apps (e.g.,
App
,Module
, etc).If you’re using type checking, you’ll also want to use the
Inputs
,Outputs
, andSession
Classes to type the instances supplied to your server function, for example:
#| standalone: true
#| components: [editor, viewer]
#| layout: vertical
#| viewerHeight: 400
## file: app.py
from shiny import *
app_ui = ui.page_fluid(
ui.input_slider("n", "Value of n", min=1, max=10, value=5),
ui.output_text("n2")
)
def server(input: Inputs, output: Outputs, session: Session) -> None:
@output
@render.text
def n2():
return f"The value of n*2 is {input.n() * 2}"
app = App(app_ui, server)
API Reference#
Page containers#
Create a user interface page container.
|
Create a navbar with a navs bar and a title. |
|
Create a fluid page. |
|
Create a fixed page. |
|
Create a Bootstrap UI page container. |
UI Layout#
Control the layout of multiple UI components.
|
Layout a sidebar and main area |
|
Create a sidebar panel |
|
Create an main area panel |
|
Responsive row-column based layout |
|
Responsive row-column based layout |
UI Inputs#
Create UI that prompts the user for input values or interaction.
|
Create a select list that can be used to choose a single or multiple items from a list of values. |
|
Create a select list that can be used to choose a single or multiple items from a list of values. |
|
Constructs a slider widget to select a number, date, or date-time from a range. |
|
Creates a text input which, when clicked on, brings up a calendar that the user can click on to select dates. |
|
Creates a pair of text inputs which, when clicked on, bring up calendars that the user can click on to select dates. |
|
Create a checkbox that can be used to specify logical values. |
|
Create a group of checkboxes that can be used to toggle multiple choices independently. |
|
Create a switch that can be used to specify logical values. |
|
Create a set of radio buttons used to select an item from a list. |
|
Create an input control for entry of numeric values. |
|
Create an input control for entry of text values |
|
Create a textarea input control for entry of unstructured text values. |
|
Create an password control for entry of passwords. |
|
Creates an action button whose value is initially zero, and increments by one each time it is pressed. |
|
Creates a link whose value is initially zero, and increments by one each time it is pressed. |
Update inputs#
Programmatically update input values
|
Change the value of a select input on the client. |
|
Change the value of a selectize.js powered input on the client. |
|
Change the value of a slider input on the client. |
|
Change the value of a date input on the client. |
|
Change the start and end values of a date range input on the client. |
|
Change the value of a checkbox input on the client. |
|
Change the value of a checkbox group input on the client. |
|
Change the value of a switch input on the client. |
|
Change the value of a radio input on the client. |
|
Change the value of a number input on the client. |
|
Change the value of a text input on the client. |
|
Change the value of a text input on the client. |
|
Change the value of a navs container on the client. |
UI panels#
Visually group together a section of UI components.
|
Create a panel of absolutely positioned content. |
|
Create a panel of absolutely positioned content. |
|
Create a conditional panel |
|
Create title(s) for the application. |
|
Create a well panel |
Uploads & downloads#
Allows users to upload and download files.
|
Create a file upload control that can be used to upload one or more files. |
|
Create a download button |
Custom UI#
Lower-level UI functions for creating custom HTML/CSS/JS.
Mark a string as raw HTML. |
|
Create an HTML tag list (i.e., a fragment of HTML) |
Functions for creating HTML tags. |
|
Convert a string of markdown to |
|
Insert UI objects |
|
Remove UI objects |
Rendering outputs#
UI (output_*()) and server (render
)ing functions for generating content server-side.
|
Create a output container for a static plot. |
Reactively render a plot object as an HTML image. |
|
|
Create a output container for a static image. |
Reactively render a image file as an HTML image. |
|
|
Create a output container for a table. |
Reactively render a Pandas data frame object (or similar) as a basic HTML table. |
|
|
Create a output container for some text. |
|
Create a output container for some text. |
Reactively render text. |
|
|
Create a output container for a UI (i.e., HTML) element. |
Reactively render HTML content. |
Reactive programming#
Reactive programming facilities for Python.
Mark a function as a reactive calculation. |
|
Mark a function as a reactive side effect. |
Create a reactive value |
Create a non-reactive scope within a reactive scope. |
|
|
Scheduled Invalidation |
Run any pending invalidations (i.e., flush the reactive environment). |
|
|
Create a reactive polling object. |
|
Create a reactive file reader. |
|
Deprecated. |
Create and run applications#
Create, run, stop, and hook into the lifecycle of Shiny applications.
|
Starts a Shiny app. |
|
Create a Shiny app instance. |
|
A class representing Shiny input values. |
|
A class representing Shiny output definitions. |
|
A class representing a user session. |
Display messages#
Display messages to the user.
|
Create a help text element |
|
Show a notification to the user. |
|
Remove a notification. |
|
Creates the UI for a modal dialog, using Bootstrap's modal class. |
|
Show a modal dialog. |
|
Remove a modal dialog. |
|
Creates a button that will dismiss a |
|
Initialize a progress bar. |
Error validation#
Control how errors are shown to the user.
|
Throw a silent exception for falsy values. |
Throw a silent exception. |
|
Throw a silent exception and don't clear output |
|
Throw a safe exception. |
Modules#
Control application complexity by namespacing UI and server code.
|
|
|
|
Type hints#
Classes for type hinting input/output values.
|
Information about a file upload. |
|
Return type for |
Developer facing tools#
Tools for Shiny developers.
Get the current user session. |
|
|
Raise an exception if no Shiny session is currently active. |
|
Context manager for current session. |
Get the current reactive context. |
|
Manage Shiny input handlers. |