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:
accept
propmultiple
prop- 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
accept
string
'*'
disabled
boolean
false
multiple
boolean
false
noButton
boolean
false
noDrag
boolean
false
maxFileSize
number | undefined
maxFiles
number | undefined
label
string | undefined
buttonLabel
string | undefined
lang
string
Events
sl-drag-leave
onSlDragLeave
sl-drag-over
onSlDragOver
sl-drop
onSlDrop
sl-change
onSlChange
sl-drop-accepted
onSlDropAccepted
sl-drop-rejected
onSlDropRejected
sl-file-dialog-open
onSlFileDialogOpen
sl-file-dialog-cancel
onSlFileDialogCancel
Slots
content
icon
CSS Custom Properties
--border-radius
--border-width
CSS Parts
base
content
Dependencies
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-remove
onSlRemove
{ item: SlFileListItem }
Slots
CSS Parts
base
FileListItem
File list items represent an uploaded file and provides information about file type, file size etc.
Properties
loading
boolean
false
progressValue
number
0
indeterminate
boolean
false
progressLabel
string
''
lang
string
warning
boolean
false
value
string
''
size
string
''
type
string
''
Slots
icon
warning-icon
remove-icon
CSS Parts
base
label
Dependencies
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
accept
string
'*'
multiple
boolean
false
maxFileSize
number | undefined
maxFiles
number | undefined
size
'small' | 'medium' | 'large'
'medium'
name
string
filled
boolean
false
warning
boolean
false
pill
boolean
false
label
string
''
warningLabel
string
''
buttonLabel
string
''
helpText
help-text
string
''
placeholder
string
lang
string
disabled
boolean
false
required
boolean
false
invalid
required
,maxFileSize
,maxFiles
, andaccept
using the browser’s constraint validation API.boolean
false
Events
sl-change
onSlChange
sl-clear
onSlClear
sl-input
onSlInput
sl-focus
onSlFocus
sl-blur
onSlBlur
sl-remove
onSlRemove
sl-file-dialog-open
onSlFileDialogOpen
sl-file-dialog-cancel
onSlFileDialogCancel
Slots
label
button
warning-label
preview-tag
prefix
suffix
help-text
CSS Parts
form-control
form-control-label
form-control-input
form-control-help-text
base
preview-tag
button
input
prefix
suffix
Dependencies
This component imports the following dependencies.
<sl-button>
<sl-icon>
<sl-spinner>