Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/carlganz/shinyCleave
Adds Cleave.js functionality to Shiny inputs
https://github.com/carlganz/shinyCleave
r shiny
Last synced: 3 months ago
JSON representation
Adds Cleave.js functionality to Shiny inputs
- Host: GitHub
- URL: https://github.com/carlganz/shinyCleave
- Owner: carlganz
- License: gpl-3.0
- Created: 2017-02-21T23:43:02.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-07-05T04:00:35.000Z (over 7 years ago)
- Last Synced: 2024-01-28T23:07:21.051Z (9 months ago)
- Topics: r, shiny
- Language: R
- Homepage:
- Size: 275 KB
- Stars: 10
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
- awesome-shiny-extensions - shinyCleave - Customized text inputs (phone number, ZIP code, currency, credit card) based on Cleave.js. (UI Components / Special Input)
- jimsghstars - carlganz/shinyCleave - Adds Cleave.js functionality to Shiny inputs (R)
README
---
output: github_document
---[![Build Status](https://travis-ci.org/CannaData/shinyCleave.svg?branch=master)](https://travis-ci.org/CannaData/shinyCleave)
[Shiny](https://github.com/rstudio/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](https://github.com/nosir/cleave.js) library provides facilities for customizing text inputs.
`shinyCleave` wraps [Cleave.js](https://github.com/nosir/cleave.js) so that [Shiny](https://github.com/rstudio/shiny) `textInputs` can be customized.
# Installation
`shinyCleave` is only available on github at the moment.
```{R, eval=FALSE}
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.
```{R, eval=FALSE}
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)
```