Search code examples
rshinycalendardefault-value

shiny r selectDate startview = "century"?


I am trying to figure out a way to get the Shiny R selectDate function to open up at it's widest state. As it stands, it has three options for startview = "____" which are month year or decade. For example:

dateInput("r_num_years", "Date of Birth", format = "mm-dd-yyyy", startview = "decade" )

This gives me the following: startview = "decade"

Then by clicking on the top of this popup you get second image and clicking again you get the third image

I want it to begin in the state portrayed in the third image.

I hope there is a workaround for this. I did look through some of the source code on GitHub, and thought this section of code looked relevant.

This seems like it should be a standard feature, because it obviously has the 'state' or 'mode' already...


Solution

  • You can use startview = "centuries", orstartview = 4.

    Shiny dateInput uses a bootstrap datepicker, you can read more about its options there

    shinyApp(ui=dateInput("r_num_years", "Date of Birth",format = "mm-dd-yyyy", 
                          startview = "centuries" ),
             server=function(input, output){})