File<mds-file>Generato da @maggioli-design-system/magma@2.3.0dist/documentation.json. Incapsulamento: shadow.
Questa pagina è generata dai pacchetti Magma, documentati solo in inglese.
Il primo esempio della pagina Pattern, dal vivo. Cambia le sue proprietà qui sotto e l'anteprima le segue; Ripristina riporta l'esempio com'era.
Proprietà
suffixenumOverrides the automatic filetype recongition by forcing the suffix to one of the available formats choosen
hideDownloadedIconhideDownloadedIconbooleanHides the download icon
descriptionstringOverrides the default filetype description
filenamestringThe filename shown as component title, is used to auto assign one of the filetype known in the filetype dictionary
formatstringSets if the download icon must be shown or not
previewstringThe image preview src if available of a file, useful if you have a logo to display, or a smaller version of a bigger image
Panoramica
The <mds-file> web component is the Magma Design System control for representing a downloadable file as a rich, clickable card. It pairs a filename with an auto-detected file-type icon, badge, and human-readable description, and tracks whether the file has already been downloaded.
Semantic Behavior
Clickable card: The whole host is focusable and clicking it emits mdsFileDownload; the component itself does not fetch or download - the consumer wires the actual download to that event.Download event payload: mdsFileDownload carries description (the description prop, or else the untranslated key of the detected type, such as documentAdobe), extension, filename, the host element as target, and the detected type/format.Downloaded persistence: On click the component records the file as downloaded in localStorage, under a key derived from the filename with a small non-cryptographic hash. Every later render of the same filename on the same origin shows the “done” indicator.Automatic file-type recognition: From filename it derives the format icon, badge variant, and default description; suffix overrides this detection.Localization: Descriptions and the “already downloaded” tooltip are resolved against the active locale.
Properties & Visual Configurations
filename is the primary input: it provides the displayed title and drives icon, badge, suffix, and description detection. The name and extension are rendered separately, split at the last dot so the dots inside the name are kept (report.v2.final.docx shows report.v2.final and .docx; a leading dot belongs to the name, as in .env); the extension is shown only when not explicitly overridden by suffix.suffix forces a specific file type from the supported format set when the filename’s extension is missing or wrong; it bypasses automatic recognition.description overrides the derived, localized file-type description when a custom label is needed.preview supplies an image URL (logo or thumbnail) rendered as the preview surface instead of the generic format icon - use it when a meaningful visual of the file exists.hideDownloadedIcon (default false) suppresses the persisted “already downloaded” indicator; set it when that affordance is not appropriate.format is normally populated by the component itself from detection rather than set by the consumer.