A form control that lets users select and upload files. — <cs-file-upload>
The value property is a FileList and must be managed via JavaScript:
<cs-file-upload accept=".png,.jpg,.pdf" multiple></cs-file-upload>
<script>
const upload = document.querySelector('cs-file-upload');
upload.addEventListener('cs-change', (e) => {
console.log('Selected files:', e.detail.value);
});
</script>
acceptstringSpecifies the native file input accept attribute to describe the allow-list of file types.
aria-requiredboolean
default: nullSpecifies whether to add aria-required to the file upload control.
file-errorsReadonlyArray<null | string>An array of file errors corresponding to the files in the value.
file-token-alignmentFileUploadProps.FileTokenAlignment
default: 'vertical'Alignment of the file tokens. Defaults to "vertical".
file-warningsReadonlyArray<null | string>An array of file warnings corresponding to the files in the value.
i18n-stringsFileUploadProps.I18nStringsAn object containing all the localized strings required by the component:
uploadButtonText (function): A function to render the text of the file upload button. It takes multiple attribute to define plurality.dropzoneText (function): A function to render the text shown in the dropzone. It takes multiple attribute to define plurality.removeFileAriaLabel (function): A function to render the ARIA label for file token remove button.limitShowFewer (string): The text of the show more tokens button.limitShowMore (string): The text of the show fewer tokens button.errorIconAriaLabel (string): The ARIA label to be shown on the error file icon.warningIconAriaLabel (string): The ARIA label to be shown on the warning file icon.formatFileSize (function): (Optional) A function that takes file size in bytes, and produces a formatted string.formatFileLastModified (function): (Optional) A function that takes the files last modified date, and produces a formatted string.multipleboolean
default: falseSpecifies the native file input multiple attribute to allow users entering more than one file.
show-file-last-modifiedboolean
default: falseShow file last modified timestamp in the token. Use i18nStrings.formatFileLastModified to customize it.
show-file-sizeboolean
default: falseShow file size in the token. Use i18nStrings.formatFileSize to customize it.
show-file-thumbnailboolean
default: falseShow file thumbnail in the token. Only supported for images.
token-limitnumberSpecifies the maximum number of displayed file tokens. If the property isn't set, all of the tokens are displayed.
valueReadonlyArray<File>requiredSpecifies the currently selected file(s). If you want to clear the selection, use empty array.
constraintTextConstraint text that is displayed below the control. Use this to provide additional information about file size limit, etc.
errorTextText that displays as a validation error message.
warningTextText that displays as a validation warning message.
changeCustomEvent<FileUploadProps.ChangeDetail>Called when the user selects new file(s), or removes a file.
The event detail contains the current value of the component.