SkillAgentSearch skills...

ShinyCleave

Adds Cleave.js functionality to Shiny inputs

Install / Use

/learn @carlganz/ShinyCleave
About this skill

Quality Score

0/100

Supported Platforms

Universal

Tags

README

<!-- README.md is generated from README.Rmd. Please edit that file -->

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)

Related Skills

View on GitHub
GitHub Stars11
CategoryDevelopment
Updated6mo ago
Forks2

Languages

R

Security Score

87/100

Audited on Oct 6, 2025

No findings