An shiny input widget for selecting directories
Switch branches/tags
Nothing to show
Clone or download
Pang, Lee
Pang, Lee fix typo in readme
Latest commit 7c42a6c Nov 11, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
R make sure spaces are ok in file paths on linux Oct 31, 2018
inst tt Oct 31, 2018
man fixed a few documentation errors Oct 31, 2018
.gitignore first commit Jan 19, 2016
DESCRIPTION fix maintainer email Nov 11, 2018
LICENSE Create LICENSE Jun 4, 2018
NAMESPACE updating roxygen docs Oct 28, 2018 fix typo in readme Nov 11, 2018
screenshot.png first commit Jan 19, 2016


A widget for interactive selection of directories for R Shiny Applications

directory widget


Provides an input for users to select directories via an interactive, and os native dialog, rather than having to type in paths in a textInput().

NOTE: This is intended to only be used with locally run shiny applications. It will not work on server deployed applications because it uses OS shell calls to present a directory choosing dialog. There is currently no way (that I'm aware) of securely presenting a client side directory selection dialog from a hosted web application.

Install the package

First install the shiny R-package from CRAN as it is required:


Then install this package from github:


Run the demo

Simply run the code to see the widget in action:


Use the widget

In global.R in your own app (create it if it doesn't already exist) add the line:


In ui.R:

  • Add the widget
directoryInput('directory', label = 'select a directory')
  • Add the widget with a default value
directoryInput('directory', label = 'select a directory', value = '~')

In server.R:

  • Important: Pass session into the server, it is used to communicate with the client-side widget
shinyServer(function(input, output, session) {
  # ...
  • Invoke the dialog
path = readDirectoryInput(session, 'directory')
  • Update the widget value
path = 'path/to/directory'
updateDirectoryInput(session, 'directory', value = path)
  • Example: Observe when a user clicks the ... button to select a new directory
  ignoreNULL = TRUE,
  eventExpr = {
  handlerExpr = {
    if (input$directory > 0) {
      # condition prevents handler execution on initial app launch
      # launch the directory selection dialog with initial path read from the widget
      path = choose.dir(default = readDirectoryInput(session, 'directory'))
      # update the widget value
      updateDirectoryInput(session, 'directory', value = path)