Learn R Programming

shinyWidgets

Extend widgets available in shiny

Overview

This package provide custom widgets and other components to enhance your shiny applications.

You can replace classical checkboxes with switch button, add colors to radio buttons and checkbox group, use buttons as radio or checkboxes. Each widget has an update method to change the value of an input from the server.

Installation

Install from CRAN with:

install.packages("shinyWidgets")

Or install the development version from GitHub with:

# install.packages("remotes")
remotes::install_github("dreamRs/shinyWidgets")

Demo

A gallery application is included in the package. Once installed, use the following command to launch it:

shinyWidgets::shinyWidgetsGallery()

A live version is available here : http://shinyapps.dreamrs.fr/shinyWidgets

Widgets

Single checkbox

  • Bootstrap switch

Turn checkboxes into toggle switches :

switchInput(inputId = "id", value = TRUE)
  • Material switch

Turn checkboxes into toggle switches :

materialSwitch(inputId = "id", label = "Primary switch", status = "danger")
  • Pretty checkbox
prettyCheckbox(
  inputId = "id", label = "Check me!", icon = icon("check")
)
  • Pretty switch
prettySwitch(
  inputId = "id",
  label = "Switch:",
  fill = TRUE, 
  status = "primary"
)
  • Pretty toggle
prettyToggle(
  inputId = "id",
  label_on = "Checked!",
  label_off = "Unchecked..."
)

Checkboxes and radio buttons

  • Bootstrap buttons

checkboxGroupButtons( # or radioGroupButtons
  inputId = "id",
  label = "Choice: ",
  choices = c("A", "B", "C")
)
  • Pretty checkbox group and radio buttons
prettyCheckboxGroup( # or prettyRadioButtons
  inputId = "id",
  label = "Choice",
  choices = c("A", "B", "c"),
  outline = TRUE,
  plain = TRUE,
  status = "primary",
  icon = icon("check")
)

Select menu

  • Bootstrap select picker

Select menu with lot of configurations options available:

pickerInput(
  inputId = "id", 
  label = "Select:", 
  choices = month.name, 
  options = pickerOptions(
    actionsBox = TRUE, 
    size = 10,
    selectedTextFormat = "count > 3"
  ), 
  multiple = TRUE
)
  • Virtual select

Select menu that can support long list of choices:

virtualSelectInput(
  inputId = "id",
  label = "Select:",
  choices = list(
    "Spring" = c("March", "April", "May"),
    "Summer" = c("June", "July", "August"),
    "Autumn" = c("September", "October", "November"),
    "Winter" = c("December", "January", "February")
  ),
  showValueAsTags = TRUE,
  search = TRUE,
  multiple = TRUE
)

Date picker

  • Air Datepicker

Date (or month or year) picker with lot of options and a timepicker integrated :

airDatepickerInput(
  inputId = "id",
  label = "Select:",
  placeholder = "Placeholder",
  multiple = 5, 
  clearButton = TRUE
)

Sliders

  • Slider with Text

Slider with strings, to pass whatever you want:

sliderTextInput(
  inputId = "id", 
  label = "Choice:", 
  grid = TRUE, 
  force_edges = TRUE,
  choices = c(
    "Strongly disagree",
    "Disagree",
    "Neither agree nor disagree", 
    "Agree", 
    "Strongly agree"
  )
)
  • noUiSlider

A range slider that can be colored, have more than two handles and positioned vertically (among other things):

noUiSliderInput(
  inputId = "id",
  label = "Select:",
  min = 0, 
  max = 600,
  value = c(100, 220, 400),
  tooltips = TRUE,
  step = 1
)

Tree

  • Tree check

Select value(s) in a hierarchical structure:

treeInput(
  inputId = "ID2",
  label = "Select cities:",
  choices = create_tree(cities),
  returnValue = "text",
  closeDepth = 1
)

Text

  • Search

A text input only triggered by hitting 'Enter' or clicking search button :

searchInput(
  inputId = "id", 
  label = "Enter your search :", 
  placeholder = "This is a placeholder", 
  btnSearch = icon("search"), 
  btnReset = icon("remove"), 
  width = "100%"
)

Other functionnalities

Sweet Alert

Show an alert message to the user to provide some feedback, via sweetalert2 library:

See examples in ?show_alert.

Request confirmation from the user :

See examples in ?ask_confirmation.

Dropdown button

Hide input in a button :

dropdownButton(
  tags$h3("List of Input"),
  selectInput(inputId = 'xcol', label = 'X Variable', choices = names(iris)),
  selectInput(inputId = 'ycol', label = 'Y Variable', choices = names(iris), selected = names(iris)[[2]]),
  sliderInput(inputId = 'clusters', label = 'Cluster count', value = 3, min = 1, max = 9),
  circle = TRUE,
  status = "danger", 
  icon = icon("gear"), width = "300px",
  tooltip = tooltipOptions(title = "Click to see inputs !")
)

See also ?dropMenu()

Development

This package use {packer} to manage JavaScript assets, see packer's documentation for more.

Install nodes modules with:

packer::npm_install()

Modify inputs bindings in srcjs/inputs/, then run:

packer::bundle()

Re-install R package and try functions.

Copy Link

Version

Install

install.packages('shinyWidgets')

Monthly Downloads

57,341

Version

0.9.0

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Victor Perrier

Last Published

February 21st, 2025

Functions in shinyWidgets (0.9.0)

awesomeCheckboxGroup

Awesome Checkbox Group Input Control
bootstrap-utils

Bootstrap panel / alert
circleButton

Circle Action button
checkboxGroupButtons

Buttons Group checkbox Input Control
colorPickr

Color Pickr
closeSweetAlert

Close Sweet Alert
calendarProInput

Calendar Pro Input
downloadBttn

Create a download actionBttn
drop-menu-interaction

Interact with Drop Menu
deprecated

Deprecated function
demoVirtualSelect

Demo for virtualSelectInput()
awesomeRadio

Awesome Radio Buttons Input Control
create_tree

Create choice structure for treeInput()
demoAirDatepicker

Some examples on how to use airDatepickerInput
colorSelectorInput

Color Selector Input
html_dependency_winbox

Winbox JavaScript Dependencies
demoNoUiSlider

Some examples on how to use noUiSliderInput
demoNumericRange

An example showing how numericRangeInput works
chooseSliderSkin

Theme selector for sliderInput
dropMenu

Drop Menu
updateCurrencyInput

Update a Formatted Numeric Input Widget
dropMenuOptions

Drop menu options
execute_safely

Execute an expression safely in server
knobInput

Knob Input
currencyInput

Format Numeric Inputs
html-dependencies

HTML dependencies
inputSweetAlert

Launch an input text dialog
dropdown

Dropdown
dropdownButton

Dropdown Button
pickerGroup-module

Picker Group
pickerInput

Select Picker Input Control
prettyCheckbox

Pretty Checkbox Input
prepare_slim_choices

Prepare choices for slimSelectInput()
materialSwitch

Material Design Switch Input Control
prepare_choices

Prepare choices for virtualSelectInput()
pickerOptions

Options for pickerInput
multiInput

Create a multiselect input control
noUiSliderInput

Numeric range slider
prettySwitch

Pretty Switch Input
numericInputIcon

Create a numeric input control with icon(s)
selectizeGroup-module

Selectize Group
numericRangeInput

Numeric Range Input
prettyToggle

Pretty Toggle Input
prettyCheckboxGroup

Pretty Checkbox Group Input Control
setBackgroundColor

Custom background color for your shinyapp
progress-bar

Progress Bars
progressSweetAlert

Progress bar in a sweet alert
prettyRadioButtons

Pretty radio Buttons Input Control
shinyWidgetsGallery

Launch the shinyWidget Gallery
sliderTextInput

Slider Text Input Widget
slimSelectInput

Slim Select Input
show_toast

Show a toast notification
sweetalert

Display a Sweet Alert to the user
sweetalert-confirmation

Launch a confirmation dialog
stati-card

Minimal statistic cards
spectrumInput

Palette Color Picker with Spectrum Library
toggleDropdownButton

Toggle a dropdown menu
updateAirDateInput

Change the value of airDatepickerInput() on the client
textInputAddon

Text with Add-on Input Control
time-input

Time input
setBackgroundImage

Custom background image for your shinyapp
radioGroupButtons

Buttons Group Radio Input Control
treeInput

Tree Input Widget
shinyWidgets

shinyWidgets: Custom inputs widgets for Shiny.
searchInput

Search Input
tooltipOptions

Tooltip options
textInputIcon

Create a text input control with icon(s)
updateNoUiSliderInput

Change the value of a no ui slider input on the client
switchInput

Bootstrap Switch Input Control
updateAutonumericInput

Update an Autonumeric Input Object
updateCalendarPro

Update calendar pro from server
updateAwesomeCheckboxGroup

Change the value of a awesomeCheckboxGroup input on the client
updateAwesomeCheckbox

Change the value of an awesome checkbox input on the client
updateNumericInputIcon

Change the value of a numeric input icon on the client
updateMaterialSwitch

Change the value of a materialSwitch input on the client
updateKnobInput

Change the value of a knob input on the client
updateColorPickr

Update color pickr server-side
updatePrettyCheckbox

Change the value of a pretty checkbox on the client
updatePrettyCheckboxGroup

Change the value of a pretty checkbox on the client
updateAwesomeRadio

Change the value of a radio input on the client
updatePickerInput

Change the value of a select picker input on the client
updateNumericRangeInput

Change the value of a numeric range input
updateMultiInput

Change the value of a multi input on the client
updateSearchInput

Change the value of a search input on the client
updatePrettyToggle

Change the value of a pretty toggle on the client
updateRadioGroupButtons

Change the value of a radio group buttons input on the client
updateCheckboxGroupButtons

Change the value of a checkboxes group buttons input on the client
updateSliderTextInput

Change the value of a slider text input on the client
updatePrettyRadioButtons

Change the value pretty radio buttons on the client
updateTextInputIcon

Change the value of a text input icon on the client
updateSwitchInput

Change the value of a switch input on the client
updateTreeInput

Update Tree Input
vertical-tab

Vertical tab panel
virtualSelectInput

Virtual Select Input
updateVerticalTabsetPanel

Update selected vertical tab
wbOptions

WinBox Options
updatePrettySwitch

Change the value of a pretty switch on the client
wNumbFormat

Format numbers in noUiSliderInput
updateVirtualSelect

Update virtual select from server
useSweetAlert

Load Sweet Alert dependencies
updateSlimSelect

Update slim select from server
updateSpectrumInput

Change the value of a spectrum input on the client
wbControls

WinBox controls
airDatepicker

Air Date Picker Input
actionGroupButtons

Actions Buttons Group Inputs
WinBox

WinBox
awesomeCheckbox

Awesome Checkbox Input Control
addSpinner

Display a spinner above an output when this one recalculate
animations

Animation names
autonumericInput

Autonumeric Input Widget
actionBttn

Awesome action button
animateOptions

Animate options
appendVerticalTab

Mutate Vertical Tabset Panel