Title: | Combined Slider and Numeric Input for 'Shiny' |
---|---|
Description: | Provides a combined slider and numeric input for usage in a 'Shiny' app. The slider and the numeric input are linked together: each one is updated when the other one changes. Many styling properties are customizable (e.g. colors and size). |
Authors: | Stéphane Laurent [aut, cre], Segun Adebayo [ctb, cph] ('chakra-ui' library (https://github.com/chakra-ui/chakra-ui)), Goran Gajic [ctb, cph] ('react-icons' library (https://github.com/react-icons/react-icons)), Peter Newnham [ctb, cph] ('react-html-parser' library (https://github.com/wrakky/react-html-parser)) |
Maintainer: | Stéphane Laurent <[email protected]> |
License: | GPL-3 |
Version: | 0.1.0 |
Built: | 2024-11-01 02:53:01 UTC |
Source: | https://github.com/stla/shinychakraslider |
This creates a number input in the Shiny UI.
chakraNumberInput( inputId, label = NULL, value, min, max, step = NULL, size = "md", options = list() )
chakraNumberInput( inputId, label = NULL, value, min, max, step = NULL, size = "md", options = list() )
inputId |
the input slot that will be used to access the value |
label |
the label for the widget; this can be some HTML code |
value |
initial value |
min |
minimum allowed value |
max |
maximum allowed value |
step |
stepping interval to use when adjusting the value |
size |
size of the widget, can be |
options |
a list of options for the number input created with
|
This creates a chakra slider in the Shiny UI. A chakra slider has two elements: a number input and a slider, which are linked together.
chakraSliderInput( inputId, label = NULL, value, min, max, step = NULL, width = "100%", size = "md", numberInputOptions = list(), trackColor = NULL, thumbOptions = list(), gap = "2rem" )
chakraSliderInput( inputId, label = NULL, value, min, max, step = NULL, width = "100%", size = "md", numberInputOptions = list(), trackColor = NULL, thumbOptions = list(), gap = "2rem" )
inputId |
the input slot that will be used to access the value |
label |
the label for the widget; this can be some HTML code |
value |
initial value |
min |
minimum allowed value |
max |
maximum allowed value |
step |
stepping interval to use when adjusting the value |
width |
width of the widget, e.g. |
size |
size of the widget, can be |
numberInputOptions |
list of options for the number input;
see |
trackColor |
color(s) for the track of the slider, can be a single color or a vector of two colors, one for the left side and one for the right side |
thumbOptions |
list of options for the thumb of the slider;
see |
gap |
size of the gap between the number input and the slider,
e.g. |
library(shiny) library(shinyChakraSlider) ui <- fluidPage( br(), chakraSliderInput( "slider", label = tags$span( style = "font-size: 20px; font-style: italic; color: darkred;", "Chakra Slider" ), value = 5, min = 0, max = 10, step = 0.5, width = "50%", size = "lg", numberInputOptions = numberInputOptions( width = "25%", fontSize = "15px", fontColor = "navyblue", borderColor = "gold", borderWidth = "medium", focusBorderColor = "navyblue", stepperColor = c("palegreen", "lightpink") ), trackColor = c("lightpink2", "springgreen"), thumbOptions = thumbOptions( width = "30px", height = "30px", color = "white", borderColor = "darkblue", borderWidth = "8px", icon = "circle", iconSize = "2.5em" ) ), br(), tags$div( style = "width: 50%;", wellPanel( style = "vertical-align: top; width: 150px; padding: 11.5px; float: left;", textOutput("value"), ), tags$div( style = "float: right;", actionButton("update", "Update value", class = "btn-danger btn-lg") ) ) ) server <- function(input, output, session){ output[["value"]] <- renderText({ paste0("Value: ", input[["slider"]]) }) observeEvent(input[["update"]], { updateChakraSliderInput(session, "slider", value = 8) }) } if(interactive()){ shinyApp(ui, server) }
library(shiny) library(shinyChakraSlider) ui <- fluidPage( br(), chakraSliderInput( "slider", label = tags$span( style = "font-size: 20px; font-style: italic; color: darkred;", "Chakra Slider" ), value = 5, min = 0, max = 10, step = 0.5, width = "50%", size = "lg", numberInputOptions = numberInputOptions( width = "25%", fontSize = "15px", fontColor = "navyblue", borderColor = "gold", borderWidth = "medium", focusBorderColor = "navyblue", stepperColor = c("palegreen", "lightpink") ), trackColor = c("lightpink2", "springgreen"), thumbOptions = thumbOptions( width = "30px", height = "30px", color = "white", borderColor = "darkblue", borderWidth = "8px", icon = "circle", iconSize = "2.5em" ) ), br(), tags$div( style = "width: 50%;", wellPanel( style = "vertical-align: top; width: 150px; padding: 11.5px; float: left;", textOutput("value"), ), tags$div( style = "float: right;", actionButton("update", "Update value", class = "btn-danger btn-lg") ) ) ) server <- function(input, output, session){ output[["value"]] <- renderText({ paste0("Value: ", input[["slider"]]) }) observeEvent(input[["update"]], { updateChakraSliderInput(session, "slider", value = 8) }) } if(interactive()){ shinyApp(ui, server) }
Create a list of options to be passed to
numberInputOptions
in chakraNumberInput
or
chakraSliderInput
.
numberInputOptions( width = NULL, fontSize = NULL, fontColor = NULL, borderColor = NULL, focusBorderColor = NULL, borderWidth = NULL, stepperColor = NULL )
numberInputOptions( width = NULL, fontSize = NULL, fontColor = NULL, borderColor = NULL, focusBorderColor = NULL, borderWidth = NULL, stepperColor = NULL )
width |
width of the number input, e.g. |
fontSize |
font size of the displayed value, e.g. |
fontColor |
color of the displayed value |
borderColor |
color of the border of the number input |
focusBorderColor |
color of the border of the number input on focus |
borderWidth |
width of the border of the number input,
e.g. |
stepperColor |
color(s) of the steppers, can be a single color or a vector of two colors, one for each stepper (increment and decrement) |
Create a list of options to be passed to thumbOptions
in chakraSliderInput
thumbOptions( width = NULL, height = NULL, color = NULL, borderColor = NULL, borderWidth = NULL, icon = NULL, iconColor = NULL, iconSize = NULL )
thumbOptions( width = NULL, height = NULL, color = NULL, borderColor = NULL, borderWidth = NULL, icon = NULL, iconColor = NULL, iconSize = NULL )
width |
width of the thumb, e.g. |
height |
height of the thumb, e.g. |
color |
color of the thumb |
borderColor |
color of the border of the thumb |
borderWidth |
width of the border of the thumb, e.g.
|
icon |
an icon for the thumb, can be |
iconColor |
color of the icon |
iconSize |
size of the icon, e.g. |
Update the value of a chakra number input.
updateChakraNumberInput(session, inputId, value)
updateChakraNumberInput(session, inputId, value)
session |
the Shiny session object |
inputId |
the id of the chakra number input to update |
value |
the new value of the chakra number input |
Update the value of a chakra slider.
updateChakraSliderInput(session, inputId, value)
updateChakraSliderInput(session, inputId, value)
session |
the Shiny session object |
inputId |
the id of the chakra slider to update |
value |
the new value of the chakra slider |