twFileInput {shiny.tailwind}R Documentation

Wrapper around shiny::fileInput() but allowing for more classes

Description

Wrapper around shiny::fileInput() but allowing for more classes

Usage

twFileInput(
  inputId,
  label,
  multiple = FALSE,
  accept = NULL,
  width = NULL,
  buttonLabel = "Browse...",
  placeholder = "No file selected",
  container_class = NULL,
  label_class = NULL,
  select_class = NULL,
  button_class = NULL,
  progress_class = NULL
)

Arguments

inputId

The input slot that will be used to access the value.

label

Display label for the control, or NULL for no label.

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 "unique file type specifiers" which gives the browser a hint as to the type of file the server expects. Many browsers use this prevent the user from selecting an invalid file.

A unique file type specifier can be:

  • A case insensitive extension like .csv or .rds.

  • A valid MIME type, like text/plain or application/pdf

  • One of ⁠audio/*⁠, ⁠video/*⁠, or ⁠image/*⁠ meaning any audio, video, or image type, respectively.

width

The width of the input, e.g. '400px', or '100%'; see validateCssUnit().

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.

container_class

additional classes to be applied to the container

label_class

additional classes to be applied to the label

select_class

additional classes to be applied to the select elements

button_class

additional classes to be applied to the upload button

progress_class

additional classes to be applied to the progress bar (ie color)

Value

a list with a shiny.tag class

See Also

shiny::fileInput()

Examples

shiny::fileInput("id", "label",
  multiple = TRUE, accept = c(".csv", ".rds"),
  width = "200px", buttonLabel = "Upload", placeholder = "Here"
)
twFileInput("id", "label",
  multiple = TRUE, accept = c(".csv", ".rds"),
  width = "200px", buttonLabel = "Upload", placeholder = "Here",
  container_class = "CONTAINER", label_class = "LABEL",
  select_class = "SELECT"
)

# basic full shiny example
library(shiny)
ui <- fluidPage(
  use_tailwind(),
  twFileInput(
    inputId = "file", label = "Upload", multiple = TRUE,
    buttonLabel = "Upload", placeholder = "Nothing selected",
    container_class = "shadow-md rounded-md bg-gray-50 m-2 p-2 w-96",
    label_class = "font-serif text-red-800",
    select_class = "font-mono font-bold text-red-800 rounded-r-lg",
    button_class = paste(
      "bg-red-800 border-red-800 hover:bg-red-700",
      "hover:border-red-700 text-white hover:text-gray-50"
    ),
    progress_class = "bg-red-800"
  ),
  verbatimTextOutput("data")
)

server <- function(input, output) {
  output$data <- renderText({
    paste(capture.output(str(input$file)), collapse = "\n")
  })
}

if (interactive()) shiny::shinyApp(ui, server)

[Package shiny.tailwind version 0.2.2 Index]