Description Usage Arguments Details Note See Also Examples
Change the value of a colour input on the client.
1 2 3 |
session |
The |
inputId |
The id of the colour input object. |
label |
The label to set for the input object. |
value |
The value to set for the input object. |
showColour |
Whether to shoW the chosen colour via text, background, or both. |
palette |
The type of colour palette to allow the user to select colours from. |
allowedCols |
A list of colours that the user can choose from. |
allowTransparent |
If |
transparentText |
The text to show beside the transparency checkbox
when |
returnName |
If |
The update function sends a message to the client, telling it to change
the settings of a colour input object.
This function works similarly to the update functions provided by shiny.
Any argument with NULL
values will be ignored.
Unlike the rest of the shinyjs
functions, this function does
not require you to call useShinyjs()
first.
See http://daattali.com/shiny/colourInput/ for a live demo.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | if (interactive()) {
library(shiny)
shinyApp(
ui = fluidPage(
div("Selected colour:", textOutput("value", inline = TRUE)),
colourInput("col", "Choose colour", "red"),
h3("Update colour input"),
textInput("text", "New colour: (colour name or HEX value)"),
selectInput("showColour", "Show colour",
c("both", "text", "background")),
checkboxInput("allowTransparent", "Allow transparent", FALSE),
checkboxInput("returnName", "Return R colour name", FALSE),
actionButton("btn", "Update")
),
server = function(input, output, session) {
observeEvent(input$btn, {
updateColourInput(session, "col",
value = input$text, showColour = input$showColour,
allowTransparent = input$allowTransparent,
returnName = input$returnName)
})
output$value <- renderText(input$col)
}
)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.