| text_Input | R Documentation |
This function create a text input.
text_Input(
inputId,
label,
hint_label = NULL,
type = "text",
width = NULL,
error = FALSE,
error_message = NULL,
prefix = NULL,
suffix = 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 |
type |
Type of text input to accept. Defaults to text |
width |
control the size of the box based on number of characters required. Options are 30, 20, 10, 5, 4, 3, 2. NULL will not limit the size |
error |
If |
error_message |
Text shown when |
prefix |
Add a prefix to the box. Defaults to NULL |
suffix |
Add a suffix to the box. Defaults to NULL |
a text input HTML shiny tag object
Other Govstyle text types:
date_Input(),
gov_list(),
heading_text(),
input_field(),
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 text box
shinyGovstyle::text_Input(inputId = "eventId", label = "Event Name"),
# Error text box
shinyGovstyle::text_Input(
inputId = "eventId2",
label = "Event Name",
hint_label = "This can be found on the letter",
error = TRUE
),
# Rich content: a link in the hint
shinyGovstyle::text_Input(
inputId = "eventId3",
label = "Event Name",
hint_label = shiny::tagList(
"As shown on your ",
shinyGovstyle::external_link(
"https://www.gov.uk",
"confirmation letter"
)
)
),
# 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 eventId2
observeEvent(input$submit, {
if (input$eventId2 != "") {
shinyGovstyle::error_off(inputId = "eventId2")
} else {
shinyGovstyle::error_on(
inputId = "eventId2",
error_message = "Please complete"
)
}
})
}
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.