File upload feedback
Choosing a file and uploading it are different events. A clear interface explains which files are selected, whether a transfer has started, and what cancellation means. The two examples on this page demonstrate selection and progress separately, without reading your files or sending them anywhere.
// glass-input-attachments · original package example
{
// Explicit offline demonstration. No backend operation is performed.
// For an application: use .mount(element, { onChange, onSubmit, ... }) instead.
const initialScene = "pastel";
const host = document.querySelector('[data-glass-input="attachments"]');
void(async()=>{const response=await fetch(new URL('./buttons.css',document.baseURI));if(!response.ok)throw Error('Styles unavailable');const cssText=await response.text();const controller = globalThis.SLGlassInputs["glass-input-attachments"].mountPreview(host, {scene:initialScene,cssText,assetBase:new URL('./',document.baseURI)});
window.addEventListener('pagehide', event => { if(!event.persisted) controller.destroy(); });})();
}
// glass-feedback-upload-progress · original package example
{
// Explicit offline demonstration. No backend operation is performed.
// For an application: use .mount(element, { onChange }) instead.
const initialScene = "pastel";
const host = document.querySelector('[data-glass-more="upload-progress"]');
void(async()=>{const response=await fetch(new URL('./buttons.css',document.baseURI));if(!response.ok)throw Error('Styles unavailable');const cssText=await response.text();const controller = globalThis.SLGlassMore["glass-feedback-upload-progress"].mountPreview(host, {scene:initialScene,cssText,assetBase:new URL('./',document.baseURI)});
window.addEventListener('pagehide', event => { if(!event.persisted) controller.destroy(); });})();
}Interactive demo. No data is sent.
Show the selected files before transfer
Try Attach files in the attachment preview. Each activation adds an example file descriptor, with a name and size, rather than opening your device’s file picker. Remove one item and add it again, then clear the list. This lets you inspect the list’s appearance and focus behavior without handing over personal documents.
In a real application, show the selected filenames, their sizes, and an obvious removal action before submission. Long names need enough context to distinguish similar files. Let the person correct the selection without starting again. A list of local files means they were chosen; it does not establish that a server has received them.
Explain limits before someone meets them
The shipped attachment controller has count and size limits in its local selection model. Its application mode can open a native file picker; the preview uses sample descriptors instead. If you adopt the package, inspect those actual limits and make them agree with your product’s requirements and server checks rather than inventing a different promise in the label.
Write an actionable message for a rejected file: identify which item was not accepted and what the person can change. Keep accepted files visible when another selection fails. Browser hints about file types can help selection, but the application must still validate received data. Selecting a file should not silently commit the whole form.
Distinguish measured progress from a demonstration
The progress example follows a named sample archive. Start upload begins a timed local sequence, ending at Upload complete. The percentage is produced by the demonstration; it is not a measurement of your connection. This makes the component useful for inspecting feedback while keeping its result separate from a real transfer.
For production, derive progress from the actual operation when that information is available. Explain any remaining processing step after transfer, because sending bytes and accepting a file can finish at different times. If you cannot measure progress, choose an honest waiting state instead of a percentage that advances only because a timer ran.
<label for="attachments">Attachments</label>
<input id="attachments" type="file" multiple>
<p id="upload-status" role="status">No transfer started.</p>Make cancellation and restart understandable
While the sample is running, Cancel upload changes it to a cancelled state. Restart upload starts a fresh demonstration. Try cancelling near the beginning and near completion. The progress model here returns to zero; there is no resume operation. Do not label this example as resumable uploading or as a failed-network recovery feature.
In an application, cancellation must reach the transfer mechanism, not just hide the bar. Explain whether a restart sends the file again and whether selected files remain available. Add genuine failure handling in the host application if needed: the shipped progress example illustrates ready, uploading, complete, and cancelled states, without simulating a server error.
Test selection and transport separately
Review empty and full selections, removal, long names, and keyboard access before testing the transfer. Then test delayed completion, cancellation, and the actual server’s failure response in the integrated application. Status should remain readable and available to assistive technology. Reduced motion should leave the current phase and value understandable even when transitions are quiet.
Take the complete SL UI Library source package when integrating these controls. React and Next.js wrappers use the original controller and adjacent assets. The two article previews are independent demonstrations: selecting an example attachment does not feed the sample progress bar. Connect real files, transport, validation, and persistence explicitly in your own application.
Reference documentation
Technical documentation behind these examples. You can use the article without opening these links.