ShinyCleave
Adds Cleave.js functionality to Shiny inputs
Install / Use
/learn @carlganz/ShinyCleaveREADME
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
node-connect
351.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
351.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
351.8kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
