Attachment tile
One attached file as a list item with its name, size and type icon.
Example
<div role="list" aria-label="Attachments"> <focsd-attachment-tile name="report.pdf" size="204800" media-type="application/pdf" removable></focsd-attachment-tile></div>Usage
Import the module once, then use the tag like any HTML element. Every framework below renders the same element; see Frameworks for setup.
<script type="module"> import '@focsd-dev/ai';</script>
<focsd-attachment-tile name="report.pdf" size="204800" media-type="application/pdf" removable></focsd-attachment-tile>import { useEffect, useRef } from 'react';import '@focsd-dev/ai';
export function Example() { const ref = useRef(null); return <focsd-attachment-tile ref={ref} name="report.pdf" size="204800" media-type="application/pdf" removable></focsd-attachment-tile>;}<script setup>import '@focsd-dev/ai';</script>
<template> <focsd-attachment-tile name="report.pdf" size="204800" media-type="application/pdf" removable></focsd-attachment-tile></template>// Add CUSTOM_ELEMENTS_SCHEMA to the component's schemas, then:import '@focsd-dev/ai';
// template<focsd-attachment-tile name="report.pdf" size="204800" media-type="application/pdf" removable></focsd-attachment-tile><script> import '@focsd-dev/ai';</script>
<focsd-attachment-tile name="report.pdf" size="204800" media-type="application/pdf" removable></focsd-attachment-tile>API
Attributes
| Attribute | Property | Type | Default |
|---|---|---|---|
name | name | string | — |
size | size | number | — |
media-type | mediaType | string | — |
removable | removable | boolean | false |
status | status | AttachmentStatus | ready |
CSS parts
Style the inside of the component with ::part(), for example focsd-attachment-tile::part(tile).
| Part | Description |
|---|---|
tile | The tile. |
icon | The type icon. |
name | The file name. |
size | The file size. |
status | The "Uploading" or "Upload failed" word. |
remove | The remove button. |
Accessibility
- A list item (
role="listitem") with the file name, its size (for example "200 KB") and an icon for its type that is hidden from assistive technology. Place tiles in arole="list". - The remove button is named "Remove report.pdf" and is at least 44 by 44 px; it fires
focsd-attachment-removewithdetail.name. The tile does not remove itself. statusisready,uploadingorerror; uploading and failed uploads say so in words, not by color alone.
Keyboard
| Key | Action |
|---|---|
| Enter / Space (remove button) | Fire focsd-attachment-remove |
Ask the docs
Hi, what are you building?
Ask about any component, theming, forms or frameworks. I answer with the right component, a snippet and a link to its docs.