File Input
See original GitHub issueNative file inputs currently work with <sl-form>, but it would be nice to have a more intuitive file input component. Perhaps something that shows each file as a clearable tag after the user makes a selection. Not sure on the UI, but features should include:
acceptpropmultipleprop- Drag and drop files
- Pasting files
- A standard file input control
- A button variation
- Dropzone with file list
Please vote for this feature using 👍 or 👎
Issue Analytics
- State:
- Created 3 years ago
- Reactions:61
- Comments:9 (4 by maintainers)
Top Results From Across the Web
<input type="file"> - HTML: HyperText Markup Language | MDN
A file input's value attribute contains a string that represents the path to the selected file(s). If no file is selected yet, ...
Read more >HTML input type="file" - W3Schools
The <input type="file"> defines a file-select field and a "Browse" button for file uploads. To define a file-select field that allows multiple files...
Read more >Bootstrap File Input - © Kartik - Krajee JQuery Plugins
It enhances the file input functionality further, by offering support to preview a wide variety of files i.e. images, text, html, video, audio,...
Read more >How to Use HTML5 Input Type 'file' - With Examples
The HTML5 File Input Element ... The file element is created using the input type=file as shown below. The first example creates a...
Read more >fileinput — Iterate over lines from multiple input streams ...
This module implements a helper class and functions to quickly write a loop over standard input or a list of files. If you...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

At first glance, this looks really good and well thought out. Unfortunately, it was submitted the first day of my vacation so I won’t be able to give it a proper review until I get back next week. However, separate PRs would be better so we can keep each one focused and get them merged faster.
Thanks for contributing this, and apologies for the delay. I can’t wait to get home and review it!
Our team (@kaiszybiak, @preethivenkatesh-sdase, @janborkensteinm, @mkitzmann) prepared a proposal for file input components. We are looking forward to your feedback and would like to discuss the next steps.
We suggest to build 4 separate components:
These components could be used individually or composed together (see animation below). We have created drafts for the properties, events, slots, CSS Custom Properties and CSS Parts. In the next step, we would suggest to open individual issues for each component, so the requirements for each one can be discussed separately.
https://user-images.githubusercontent.com/35574021/167856631-8b7b2c5a-dd47-4626-875c-58790e79f129.mov
Dropzone
Dropzones are areas into which files can be dragged and dropped to upload a file.
It might be worth looking into if we could utilize an existing library here like https://github.com/dropzone/dropzone. There has also been some similar work done in Adobe Spectrum Web Components.
Properties
acceptstring'*'disabledbooleanfalsemultiplebooleanfalsenoButtonbooleanfalsenoDragbooleanfalsemaxFileSizenumber | undefinedmaxFilesnumber | undefinedlabelstring | undefinedbuttonLabelstring | undefinedlangstringEvents
sl-drag-leaveonSlDragLeavesl-drag-overonSlDragOversl-droponSlDropsl-changeonSlChangesl-drop-acceptedonSlDropAcceptedsl-drop-rejectedonSlDropRejectedsl-file-dialog-openonSlFileDialogOpensl-file-dialog-cancelonSlFileDialogCancelSlots
contenticonCSS Custom Properties
--border-radius--border-widthCSS Parts
basecontentDependencies
This component imports the following dependencies.
<sl-button><sl-icon><sl-spinner>FileList
A file list provides a list of files and is composed of FileListItem components.
Events
sl-removeonSlRemove{ item: SlFileListItem }Slots
CSS Parts
baseFileListItem
File list items represent an uploaded file and provides information about file type, file size etc.
Properties
loadingbooleanfalseprogressValuenumber0indeterminatebooleanfalseprogressLabelstring''langstringwarningbooleanfalsevaluestring''sizestring''typestring''Slots
iconwarning-iconremove-iconCSS Parts
baselabelDependencies
This component imports the following dependencies.
<sl-button><sl-icon><sl-progress-bar><sl-spinner>FileInput
File inputs can be used to upload one or more files from the local file system.
This could be a separate component or extend the default input component. Its properties should align with the native file input, so it can be used in forms (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file)
Properties
acceptstring'*'multiplebooleanfalsemaxFileSizenumber | undefinedmaxFilesnumber | undefinedsize'small' | 'medium' | 'large''medium'namestringfilledbooleanfalsewarningbooleanfalsepillbooleanfalselabelstring''warningLabelstring''buttonLabelstring''helpTexthelp-textstring''placeholderstringlangstringdisabledbooleanfalserequiredbooleanfalseinvalidrequired,maxFileSize,maxFiles, andacceptusing the browser’s constraint validation API.booleanfalseEvents
sl-changeonSlChangesl-clearonSlClearsl-inputonSlInputsl-focusonSlFocussl-bluronSlBlursl-removeonSlRemovesl-file-dialog-openonSlFileDialogOpensl-file-dialog-cancelonSlFileDialogCancelSlots
labelbuttonwarning-labelpreview-tagprefixsuffixhelp-textCSS Parts
form-controlform-control-labelform-control-inputform-control-help-textbasepreview-tagbuttoninputprefixsuffixDependencies
This component imports the following dependencies.
<sl-button><sl-icon><sl-spinner>