Directory/path input


Hello everyone! I’m new to Electron and I’m just starting to build my first app.

What I’d like to create is basically a GUI for a bash script.
The user would fill some fields (simple form), and choose a directory/path on his computer. A script would then run and take the form values as arguments.
It’s a completely offline app, and thus doesn’t need a back-end.

I’m currently using Semantic UI to build the front-end and I’ve successfully added a file input. My question is, how can I let the user choose a directory/path from his computer?
Also, is Electron a good choice for this kind of application? I’m not sure if it’s suitable for offline apps like these, that do nothing but running a bash script.

Thanks in advance!


Electron is meant for building desktop GUI apps, there’s no requirement that an Electron application is always connected to the internet, so it seems like a reasonable choice. To get the user to provide a path to a local file you’ll need to popup a native file prompt using dialog.showOpenDialog. How you invoke that function is entirely up to you (for example you might display a “browse for file” button in your UI and then call that function in the click handler, note however that the dialog module lives in the main/browser process while your UI lives in the renderer process so you will need to use the remote module or IPC to actually invoke that function from your UI. I strongly suggest familiarizing yourself with the Electron/Chromium process model before you do anything else.


That was really helpful, thanks!