shiny.ui.input_checkbox#

shiny.ui.input_checkbox(id, label, value=False, *, width=None)#

Create a checkbox that can be used to specify logical values.

Parameters
  • id (str) – An input id.

  • label (Union[Tagifiable, Tag, MetadataNode, str, TagList, float, None, Dict[str, Union[str, float, bool, None]], Sequence[Union[Tagifiable, Tag, MetadataNode, str, TagList, float, None, Dict[str, Union[str, float, bool, None]], Sequence[ForwardRef]]]]) – An input label.

  • value (bool) – Initial value.

  • width (Optional[str]) – The CSS width, e.g. ‘400px’, or ‘100%’

Return type

A UI element.

Notes

Server value

True if checked, False otherwise.

Example

#| standalone: true
#| components: [editor, viewer]
#| layout: vertical
#| viewerHeight: 400
from shiny import *

app_ui = ui.page_fluid(
    ui.input_checkbox("somevalue", "Some value", False), ui.output_ui("value")
)

def server(input: Inputs, output: Outputs, session: Session):
    @output
    @render.ui
    def value():
        return input.somevalue()


app = App(app_ui, server)