material_file_input: Create a shinymaterial file input

Description Usage Arguments Examples

View source: R/shiny-material-file-input.R

Description

Build a shinymaterial file input.

Usage

1
material_file_input(input_id, label = "File", color = NULL)

Arguments

input_id

String. The input identifier used to access the value.

label

String. The file input button text.

color

String. The color of the file input. Leave empty for the default color. Visit https://materializecss.com/color.html for a list of available colors. This input requires using color hex codes, rather than the word form. E.g., "#ef5350", rather than "red lighten-1".

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
if (interactive()) {
  
  ui <- 
  material_page(
    material_row(
      material_column(
        width = 12,
        material_file_input(
          input_id = "file_1", 
          label = "file"
        )
      )
    ),
    material_row(
      material_column(
        width = 12,
        tableOutput("contents")
      )
    )
  )
  
  server <- function(input, output) {
    output$contents <- renderTable({
      # input$file_1 will be NULL initially. After the user selects
      # and uploads a file, it will be a data frame with 'name',
      # 'size', 'type', and 'datapath' columns. The 'datapath'
      # column will contain the local filenames where the data can
      # be found.
      in_file <- input$file_1
      
      if (is.null(in_file))
        return(NULL)
      
      read.csv(in_file$datapath)
    })
  }
  
  shinyApp(ui, server)
  
}

ericrayanderson/shinymaterial documentation built on Oct. 9, 2020, 5:21 p.m.