README.md

Build Status

Shiny provides many basic inputs that map nicely to R's basic datatypes. However, there many instances where users may want a custom textInput that may or may not map consistent with a specific R datatype. For example, phone numbers, credit cards, and other formatted strings.

The Cleave.js library provides facilities for customizing text inputs.

shinyCleave wraps Cleave.js so that Shiny textInputs can be customized.

Installation

shinyCleave is only available on github at the moment.

devtools::install_github("carlganz/shinyCleave")

Example

shinyCleave provides several additional inputs like phoneInput, and creditCardInput, as well as server-side control of Cleave.js.

Below is an example which users client side phoneInput and creditCardInput, and also sets a text input to only accept numerics, and to format them in the "wan"-style. The app also prints the credit-card type to the console as it is typed.

library(shiny)
library(shinyCleave)

ui <- fluidPage(
  includeCleave(),
  textInput("money","Money input"),
  phoneInput("phone","Phone input"),
  textInput("num", "Format numbers"),
  creditCardInput("card","Credit Card")
)

server <- shinyServer(function(input, output, session) {

  cleave(session, "#money", list(
    prefix = "$"
  ))

  cleave(session, "#num", list(
    numeral = TRUE,
    numeralThousandsGroupStyle= 'wan'
  ))

  observe({
    print(input$card_creditCard)
  })

})

shinyApp(ui=ui,server=server)


CannaData/shinyCleave documentation built on May 6, 2019, 9:28 a.m.