File selector
A file selector lets me pick or drop my documents when I need to add them to an online form.
The File selector component allows a user to select multiple files from their device, either by dragging and dropping them into the component or using the file input modal dialog.
Details
- Extends: USWDS File input
- Modifier:
.cfa-file-input
,.cfa-form-group
,.cfa-file-selector
,.cfa-label
,.cfa-hint
,.cfa-button
,.cfa-file-selector__*
The File selector extends the USWDS File input. Further customization is applied using the CSS modifier(s) .cfa-file-input
, .cfa-form-group
, .cfa-file-selector
, .cfa-label
, .cfa-hint
, .cfa-button
, .cfa-file-selector__*
to add styles defined in a custom stylesheet.
Modifier. A modifier is a class name that applies a variant, type, or extended style customization to modify the component's visual appearance.
Examples
Accessibility
Refer to additional accessibility guidance on the USWDS documentation site.
Checklist Key
Source and usage
- Sass stylesheet:
./_cfa-file-selector.scss
- Thymeleaf template fragment:
./cfa-file-selector.th.html
- Embedded Ruby (ERB) partial template:
./_cfa-file-selector.html.erb
- JavaScript enables the drag-and-drop interaction, uploaded file preview and management, and validation messaging. The module extends the open source library Dropzone to provide interaction and customization options. The module can be found at
./cfa-file-selector.js
. Guidance on individual module loading will added. Currently, there is one script that imports all modules. The source is located at@codeforamerica/js/index.js
. This entrypoint is compiled using Rollup.js and distributed to@codeforamerica/dist/js/default.js
.