| file_Input | R Documentation |
This function create a file upload component. It uses the basis of the shiny fileInput function, but restyles the label and adds error onto it.
file_Input(
inputId,
label,
multiple = FALSE,
accept = NULL,
width = NULL,
buttonLabel = "Choose file",
placeholder = "No file chosen",
error = FALSE,
error_message = 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 |
multiple |
Whether the user should be allowed to select and upload multiple files at once. Does not work on older browsers, including Internet Explorer 9 and earlier |
accept |
A character vector of MIME types; gives the browser a hint of what kind of files the server is expecting |
width |
The width of the input, e.g. |
buttonLabel |
The label used on the button. Can be text or an HTML tag object |
placeholder |
The text to show before a file has been uploaded |
error |
If |
error_message |
Text shown when |
a file input HTML shiny tag object
Other Govstyle select inputs:
button_Input(),
checkbox_Input(),
radio_button_Input(),
select_Input(),
update_radio_button_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 file input
shinyGovstyle::file_Input(
inputId = "file1",
label = "Upload a file"
),
# Error file
shinyGovstyle::file_Input(
inputId = "file2",
label = "Upload a file",
error = TRUE
),
# 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 file2
observeEvent(input$submit, {
if (is.null(input$file2)){
shinyGovstyle::error_on(inputId = "file2")
} else {
shinyGovstyle::error_off(
inputId = "file2"
)
}
})
}
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.