/reactcolors

React htmlwidget for react-color

Primary LanguageJavaScriptOtherNOASSERTION

reactcolors

R interface to React library react-color. Powered by reactR!

Travis build status lifecycle

Installation

You can install from GitHub with:

remotes::install_github("pvictor/reactcolors")

Example

All color pickers as rendered as htmlwidgets, so you can see the result in RStudio Viewer

color_picker(
  picker = "Sketch",
  presetColors = c("#EFF3FF", "#C6DBEF", "#9ECAE1",
                    "#6BAED6", "#3182BD", "#08519C", "#112446"),
  label = "Pick a color:"
)

You can use them in Shiny applications (inline or through a button):

library(shiny)

ui <- fluidPage(
  tags$h2("Chrome picker color"),
  chrome_picker("inline", "Pick!", inline = TRUE),
  verbatimTextOutput("res_inline"),
  chrome_picker("btn", "Pick!", inline = FALSE),
  verbatimTextOutput("res_btn")
)

server <- function(input, output, session) {
  output$res_inline <- renderPrint(input$inline)
  output$res_btn <- renderPrint(input$btn)
}

shinyApp(ui, server)

Launch the demo with:

app_demo()