| Title: | Interactive Calendar and Date Picker Widget |
| Version: | 1.0.0 |
| Description: | An R interface to the 'Vanilla Calendar Pro' 'JavaScript' library (version 3.2.0, bundled) for creating interactive and customizable calendar widgets and date pickers. The package enables integration of modern calendar components in R and 'Shiny' applications, with support for date, month, year and time selection, popup input mode, theming, and in-place updates from the 'Shiny' server. |
| URL: | https://github.com/ESCRI11/vanilla-calendar-r |
| BugReports: | https://github.com/ESCRI11/vanilla-calendar-r/issues |
| License: | GPL (≥ 3) |
| Copyright: | The bundled Vanilla Calendar Pro library is copyright Yury Uvarov and released under the MIT licence; see inst/htmlwidgets/lib/VanillaCalendar-3.2.0/LICENSE. |
| Encoding: | UTF-8 |
| Config/roxygen2/version: | 8.1.0 |
| Imports: | htmlwidgets |
| Suggests: | shiny, testthat (≥ 3.0.0), shinytest2, chromote, htmltools, withr, knitr, rmarkdown |
| Config/testthat/edition: | 3 |
| VignetteBuilder: | knitr |
| NeedsCompilation: | no |
| Packaged: | 2026-08-21 09:11:28 UTC; massagno |
| Author: | Xavier Escribà Montagut [aut, cre], Yury Uvarov [ctb, cph] (Author of the bundled 'Vanilla Calendar Pro' library) |
| Maintainer: | Xavier Escribà Montagut <xavier.escriba.montagut@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-08-28 10:00:15 UTC |
Vanilla Calendar Widget
Description
Creates a Vanilla Calendar Pro calendar or date picker for use in R, R Markdown and Shiny applications.
Usage
VanillaCalendar(
options = list(),
width = NULL,
height = NULL,
elementId = NULL
)
Arguments
options |
A named list of Vanilla Calendar Pro options, passed to the
JavaScript library. Every option documented in the
upstream reference
is accepted; names are validated against the bundled library version and
unknown names raise a warning. |
width, height |
Must be a valid CSS unit (like |
elementId |
An optional ID for the widget element. |
Value
An object of class htmlwidget.
Shiny inputs
When rendered in Shiny, the widget reports its state back to the server.
For an output with id "cal":
input$cal_selectedA
Datevector of the selected dates (length 0 when nothing is selected).input$cal_selected_monthSelected month, 1-12.
input$cal_selected_yearSelected year.
input$cal_displayedFirst day of the displayed month, as a
Date, updated when the user clicks the arrows.input$cal_timeSelected time as a string, e.g.
"14:30", whenselectionTimeModeis enabled.input$cal_weekA list with
weekandyear, whenenableWeekNumbersis enabled and a week number is clicked.input$cal_readyTRUEonce the calendar has initialised.
Input mode
With options = list(inputMode = TRUE) the widget renders a text input and
shows the calendar as a popup, the behaviour documented under
input mode
upstream. Pair it with height = "auto".
Theming
selectedTheme accepts "light", "dark" or "system". In system mode the
library reads the theme from the attribute named by themeAttrDetect, which
defaults to "html[data-theme]". Shiny apps using bslib should set
themeAttrDetect = "html[data-bs-theme]" to follow the app theme.
See Also
VanillaCalendarProxy() to update a calendar in place from Shiny.
Examples
# Basic calendar with default settings
VanillaCalendar()
# Calendar with custom options
VanillaCalendar(
options = list(
type = "default",
locale = "en",
selectionDatesMode = "multiple",
selectedDates = Sys.Date(),
selectedTheme = "light"
),
width = "500px",
height = "400px"
)
# Date picker attached to a text input
VanillaCalendar(
options = list(inputMode = TRUE, selectionDatesMode = "single"),
height = "auto"
)
Shiny bindings for VanillaCalendar
Description
Output and render functions for using VanillaCalendar within Shiny applications and interactive Rmd documents.
Usage
VanillaCalendarOutput(outputId, width = "100%", height = "400px")
renderVanillaCalendar(expr, env = parent.frame(), quoted = FALSE)
Arguments
outputId |
output variable to read from |
width, height |
Must be a valid CSS unit (like |
expr |
An expression that generates a VanillaCalendar |
env |
The environment in which to evaluate |
quoted |
Is |
Value
VanillaCalendarOutput() returns a Shiny output element;
renderVanillaCalendar() returns a Shiny render function.
Examples
# Only run examples in interactive R sessions
if (interactive()) {
library(shiny)
library(VanillaCalendar)
ui <- fluidPage(
VanillaCalendarOutput("calendar"),
verbatimTextOutput("dates")
)
server <- function(input, output) {
output$calendar <- renderVanillaCalendar({
VanillaCalendar(
options = list(
type = "default",
locale = "en",
selectionDatesMode = "multiple"
)
)
})
output$dates <- renderPrint(input$calendar_selected)
}
shinyApp(ui, server)
}
Update a calendar in place from Shiny
Description
VanillaCalendarProxy() creates a handle to a calendar that is already
rendered, so that it can be changed without re-rendering it — the calendar
keeps its position, focus and selection instead of flickering back to its
initial state. The methods map onto the
Calendar instance methods
of Vanilla Calendar Pro.
vcSet() applies new options to the calendar.
vcUpdate() re-renders the calendar with its current options.
vcShow() and vcHide() show and hide a popup calendar in
input mode.
vcDestroy() removes the calendar from the page.
Usage
VanillaCalendarProxy(id, session = shiny::getDefaultReactiveDomain())
vcSet(proxy, options, reset = NULL)
vcUpdate(proxy, reset = NULL)
vcShow(proxy)
vcHide(proxy)
vcDestroy(proxy)
Arguments
id |
The output id of the calendar, as used in
|
session |
The Shiny session object. |
proxy |
A |
options |
A named list of options to apply, handled exactly as in
|
reset |
Optional named list overriding which parts of the calendar are
reset to their option values, with any of the logical entries |
Value
The proxy object, invisibly, so calls can be piped.
Examples
if (interactive()) {
library(shiny)
library(VanillaCalendar)
ui <- fluidPage(
selectInput("theme", "Theme", c("light", "dark")),
actionButton("clear", "Clear selection"),
VanillaCalendarOutput("cal")
)
server <- function(input, output, session) {
output$cal <- renderVanillaCalendar(
VanillaCalendar(list(selectionDatesMode = "multiple"))
)
observeEvent(input$theme, {
vcSet(VanillaCalendarProxy("cal"), list(selectedTheme = input$theme))
})
observeEvent(input$clear, {
vcSet(VanillaCalendarProxy("cal"), list(selectedDates = list()),
reset = list(dates = TRUE))
})
}
shinyApp(ui, server)
}