Create a colour picker htmlwidget. This is not terribly useful right now
since you can use the more powerful colourInput
in Shiny apps and Rmarkdown documents, but this gives you an htmlwidget
version of that colour picker.
colourWidget(
value = "white",
showColour = c("both", "text", "background"),
palette = c("square", "limited"),
allowedCols = NULL,
allowTransparent = FALSE,
returnName = FALSE,
closeOnClick = FALSE,
width = "300px",
height = "35px",
elementId = NULL
)
Initial value (can be a colour name or HEX code)
Whether to show the chosen colour as text inside the input, as the background colour of the input, or both (default).
The type of colour palette to allow the user to select colours
from. square
(default) shows a square colour palette that allows the
user to choose any colour, while limited
only gives the user a
predefined list of colours to choose from.
A list of colours that the user can choose from. Only
applicable when palette == "limited"
. The limited
palette
uses a default list of 40 colours if allowedCols
is not defined. If
the colour specified in value
is not in the list, the default colour
will revert to black.
If TRUE
, enables a slider to choose an alpha
(transparency) value for the colour. When a colour with opacity is
chosen, the return value is an 8-digit HEX code.
If TRUE
, then return the name of an R colour instead
of a HEX value when possible.
If TRUE
, then the colour selection panel will close
immediately after selecting a colour.
Custom width for the input field.
Custom height for the input field.
Use an explicit element ID for the widget (rather than an automatically generated one).
colourWidget()
colourWidget("red", palette = "limited", allowedCols = c("yellow", "red", "#123ABC"))
Run the code above in your browser using DataLab