Description Usage Arguments Details Note See Also Examples
Create an input control to select a colour.
As of August 2016, this function is being deprecated and has moved to
the colourpicker
package. Please use the colourpicker
package
in the future.
1 2 3 |
inputId |
The |
label |
Display label for the control, or ' |
value |
Initial value (can be a colour name or HEX code) |
showColour |
Whether to show the chosen colour as text inside the input, as the background colour of the input, or both (default). |
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. Only
applicable when |
allowTransparent |
If |
transparentText |
The text to show beside the transparency checkbox
when |
returnName |
If |
A colour input allows users to select a colour by clicking on the desired
colour, or by entering a valid HEX colour in the input box. The input can
be initialized with either a colour name or a HEX value. The return value is
a HEX value by default, but you can use the returnName = TRUE
parameter
to get an R colour name instead (only when an R colour exists for the
selected colour).
Since most functions in R that accept colours can also accept the value
"transparent", colourInput
has an option to allow selecting the
"transparent" colour. When the user checks the checkbox for this special
colour, the returned value form the input is "transparent".
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.
updateColourInput
colourPicker
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 26 27 28 | if (interactive()) {
library(shiny)
shinyApp(
ui = fluidPage(
strong("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")),
selectInput("palette", "Colour palette",
c("square", "limited")),
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,
palette = input$palette,
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.