| date_Input | R Documentation |
This function create a date input that follows GDS component
date_Input(
inputId,
label,
hint_label = NULL,
error = FALSE,
error_message = NULL,
day = NULL,
month = NULL,
year = NULL,
label_size = c("m", "s", "l", "xl"),
heading_level = NULL
)
inputId |
The id assigned to the component's root element. For Shiny
input components this is also the name used to access the value via
|
label |
Display label for the control, or |
hint_label |
Display hint label for the control, or |
error |
If |
error_message |
Text shown when |
day |
Select a default day on start up. Defaults to |
month |
Select a default month on start up. Defaults to |
year |
Select a default year on start up. Defaults to |
label_size |
Size modifier for the legend. One of |
heading_level |
Optional heading level for the legend. If supplied
(an integer 1-6), the legend text is wrapped in a |
a data input HTML shiny tag object
Other Govstyle text types:
gov_list(),
heading_text(),
input_field(),
text_Input(),
text_area_Input()
ui <- shinyGovstyle::gov_page(
# Required for error handling function.
shinyjs::useShinyjs(),
shinyGovstyle::header(
org_name = "Example",
service_name = "User Examples",
logo = "shinyGovstyle/images/moj_logo.png"
),
shinyGovstyle::phase_banner(
inputId = "banner", type = "beta", 'This is a new service'
),
shinyGovstyle::gov_main_layout(
# Simple date input
shinyGovstyle::date_Input(
inputId = "dob_input",
label = "Please enter your birthday"
),
# Error date input
shinyGovstyle::date_Input(
inputId = "dob_input2",
label = "Please enter your birthday",
hint_label = "For example, 12 11 2007",
error = TRUE
),
# Rich content: a link in the hint
shinyGovstyle::date_Input(
inputId = "dob_input3",
label = "Please enter your birthday",
hint_label = shiny::tagList(
"Check the format in the ",
shinyGovstyle::external_link(
"https://www.gov.uk",
"GOV.UK guidance"
)
)
),
# Button to trigger error
shinyGovstyle::button_Input(inputId = "submit", label = "Submit")
),
shinyGovstyle::footer(full = TRUE)
)
server <- function(input, output, session) {
# Trigger error on blank submit of dob_input2
observeEvent(input$submit, {
if (input$dob_input2 == "//") {
shinyGovstyle::error_on(inputId = "dob_input2")
} else {
shinyGovstyle::error_off(inputId = "dob_input2")
}
})
}
if (interactive()) shinyApp(ui = ui, server = server)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.