导航

v2.1.0
内容

文件

将单个文件呈现为带有名称的对象,可用作附件、上传项或下载项。

本页内容

文件组件将单份文档呈现为一个独立对象:左侧的小纸页标有扩展名,中间是文件名,下方低调地列出文件信息,末端有一个控件。组件采用平整的面板样式,因此在拖放区下方或对话框内纵向排列时,每个文件都清晰可辨。

文件

<ul class="flex flex-col gap-xs max-w(400) mx-auto">  <li class="file">    <span class="file-page" aria-hidden="true">pdf</span>    <div class="file-body">      <p class="file-name">Q3 infrastructure report.pdf</p>      <p class="file-meta">2.4 MB · PDF document</p>    </div>    <div class="file-end">      <button type="button" class="btn btn-quiet btn-square btn-sm" aria-label="Remove Q3 infrastructure report.pdf">        <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">          <path d="M4 4L12 12" /><path d="M4 12L12 4" />        </svg>      </button>    </div>  </li>  <li class="file">    <img class="file-thumb" src="/demo/moonstone.svg" alt>    <div class="file-body">      <p class="file-name">moonstone-cover.png</p>      <p class="file-meta">1,920 × 1,200 · 840 KB</p>    </div>    <div class="file-end">      <button type="button" class="btn btn-quiet btn-square btn-sm" aria-label="Remove moonstone-cover.png">        <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">          <path d="M4 4L12 12" /><path d="M4 12L12 4" />        </svg>      </button>    </div>  </li>  <li class="file">    <span class="file-page" aria-hidden="true">csv</span>    <div class="file-body">      <p class="file-name">members-export-2026-11.csv</p>      <p class="file-meta">312 rows · 18 KB</p>    </div>    <div class="file-end">      <button type="button" class="btn btn-quiet btn-square btn-sm" aria-label="Remove members-export-2026-11.csv">        <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">          <path d="M4 4L12 12" /><path d="M4 12L12 4" />        </svg>      </button>    </div>  </li></ul>
import XIcon from '@master/icons-react/native/16/soft/x'<ul className="flex flex-col gap-xs max-w(400) mx-auto">  <li className="file">    <span className="file-page" aria-hidden="true">pdf</span>    <div className="file-body">      <p className="file-name">Q3 infrastructure report.pdf</p>      <p className="file-meta">2.4 MB · PDF document</p>    </div>    <div className="file-end">      <button type="button" className="btn btn-quiet btn-square btn-sm" aria-label="Remove Q3 infrastructure report.pdf">        <XIcon className="icon" />      </button>    </div>  </li>  <li className="file">    <img className="file-thumb" src="/demo/moonstone.svg" alt="" />    <div className="file-body">      <p className="file-name">moonstone-cover.png</p>      <p className="file-meta">1,920 × 1,200 · 840 KB</p>    </div>    <div className="file-end">      <button type="button" className="btn btn-quiet btn-square btn-sm" aria-label="Remove moonstone-cover.png">        <XIcon className="icon" />      </button>    </div>  </li>  <li className="file">    <span className="file-page" aria-hidden="true">csv</span>    <div className="file-body">      <p className="file-name">members-export-2026-11.csv</p>      <p className="file-meta">312 rows · 18 KB</p>    </div>    <div className="file-end">      <button type="button" className="btn btn-quiet btn-square btn-sm" aria-label="Remove members-export-2026-11.csv">        <XIcon className="icon" />      </button>    </div>  </li></ul>
<script>  import XIcon from '@master/icons-svelte/native/16/soft/x'</script><ul class="flex flex-col gap-xs max-w(400) mx-auto">  <li class="file">    <span class="file-page" aria-hidden="true">pdf</span>    <div class="file-body">      <p class="file-name">Q3 infrastructure report.pdf</p>      <p class="file-meta">2.4 MB · PDF document</p>    </div>    <div class="file-end">      <button type="button" class="btn btn-quiet btn-square btn-sm" aria-label="Remove Q3 infrastructure report.pdf">        <XIcon class="icon" />      </button>    </div>  </li>  <li class="file">    <img class="file-thumb" src="/demo/moonstone.svg" alt>    <div class="file-body">      <p class="file-name">moonstone-cover.png</p>      <p class="file-meta">1,920 × 1,200 · 840 KB</p>    </div>    <div class="file-end">      <button type="button" class="btn btn-quiet btn-square btn-sm" aria-label="Remove moonstone-cover.png">        <XIcon class="icon" />      </button>    </div>  </li>  <li class="file">    <span class="file-page" aria-hidden="true">csv</span>    <div class="file-body">      <p class="file-name">members-export-2026-11.csv</p>      <p class="file-meta">312 rows · 18 KB</p>    </div>    <div class="file-end">      <button type="button" class="btn btn-quiet btn-square btn-sm" aria-label="Remove members-export-2026-11.csv">        <XIcon class="icon" />      </button>    </div>  </li></ul>
<script setup>import XIcon from '@master/icons-vue/native/16/soft/x'</script><template>  <ul class="flex flex-col gap-xs max-w(400) mx-auto">    <li class="file">      <span class="file-page" aria-hidden="true">pdf</span>      <div class="file-body">        <p class="file-name">Q3 infrastructure report.pdf</p>        <p class="file-meta">2.4 MB · PDF document</p>      </div>      <div class="file-end">        <button type="button" class="btn btn-quiet btn-square btn-sm" aria-label="Remove Q3 infrastructure report.pdf">          <XIcon class="icon" />        </button>      </div>    </li>    <li class="file">      <img class="file-thumb" src="/demo/moonstone.svg" alt>      <div class="file-body">        <p class="file-name">moonstone-cover.png</p>        <p class="file-meta">1,920 × 1,200 · 840 KB</p>      </div>      <div class="file-end">        <button type="button" class="btn btn-quiet btn-square btn-sm" aria-label="Remove moonstone-cover.png">          <XIcon class="icon" />        </button>      </div>    </li>    <li class="file">      <span class="file-page" aria-hidden="true">csv</span>      <div class="file-body">        <p class="file-name">members-export-2026-11.csv</p>        <p class="file-meta">312 rows · 18 KB</p>      </div>      <div class="file-end">        <button type="button" class="btn btn-quiet btn-square btn-sm" aria-label="Remove members-export-2026-11.csv">          <XIcon class="icon" />        </button>      </div>    </li>  </ul></template>

#纸页图标

file-page 是一张 28 × 36 的小纸页,略微凸起,底部标有扩展名。输入时大小写不限,显示时统一转为大写。扩展名最多写四个字符。旁边的文件名已包含相同信息,因此用 aria-hidden 对辅助技术隐藏纸页图标。

折角由浏览器绘制。借助 corner-shape,末端的上角被切成斜角,折起的部分由一个小正方形经斜角裁切后留下的区域构成。浏览器不支持 corner-shape 时,纸页图标显示为四个圆角,无折角。

文件为图片时,在 <img> 上使用 file-thumb 代替纸页图标。

#上传中

在文件组件内放入带有 progress file-progress 的原生 <progress>。此时整个面板就是进度条。进度条铺在文字背后,从面板的一侧延伸到另一侧,按上传进度为面板着色,填充边缘沿用面板的边角形状。省略 value 时,进度未知,一条同色的色带会横向移动。

同时在 file-meta 中写明上传进度,并在上传期间用 aria-busy="true" 标记文件。

上传中

<ul class="flex flex-col gap-xs max-w(400) mx-auto">  <li class="file" aria-busy="true">    <span class="file-page" aria-hidden="true">zip</span>    <div class="file-body">      <p class="file-name">atlas-build-2026-11-11.zip</p>      <p class="file-meta">Uploading · 64% of 182 MB</p>    </div>    <div class="file-end">      <button type="button" class="btn btn-quiet btn-square btn-sm" aria-label="Cancel the upload of atlas-build-2026-11-11.zip">        <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">          <path d="M4 4L12 12" /><path d="M4 12L12 4" />        </svg>      </button>    </div>    <progress class="progress file-progress" max="100" value="64" aria-label="Upload of atlas-build-2026-11-11.zip">      64%    </progress>  </li>  <li class="file" aria-busy="true">    <span class="file-page" aria-hidden="true">mp4</span>    <div class="file-body">      <p class="file-name">onboarding-walkthrough.mp4</p>      <p class="file-meta">Scanning for viruses…</p>    </div>    <progress class="progress file-progress" aria-label="Scan of onboarding-walkthrough.mp4"></progress>  </li></ul>
import XIcon from '@master/icons-react/native/16/soft/x'<ul className="flex flex-col gap-xs max-w(400) mx-auto">  <li className="file" aria-busy="true">    <span className="file-page" aria-hidden="true">zip</span>    <div className="file-body">      <p className="file-name">atlas-build-2026-11-11.zip</p>      <p className="file-meta">Uploading · 64% of 182 MB</p>    </div>    <div className="file-end">      <button type="button" className="btn btn-quiet btn-square btn-sm" aria-label="Cancel the upload of atlas-build-2026-11-11.zip">        <XIcon className="icon" />      </button>    </div>    <progress className="progress file-progress" max="100" value="64" aria-label="Upload of atlas-build-2026-11-11.zip">      64%    </progress>  </li>  <li className="file" aria-busy="true">    <span className="file-page" aria-hidden="true">mp4</span>    <div className="file-body">      <p className="file-name">onboarding-walkthrough.mp4</p>      <p className="file-meta">Scanning for viruses…</p>    </div>    <progress className="progress file-progress" aria-label="Scan of onboarding-walkthrough.mp4"></progress>  </li></ul>
<script>  import XIcon from '@master/icons-svelte/native/16/soft/x'</script><ul class="flex flex-col gap-xs max-w(400) mx-auto">  <li class="file" aria-busy="true">    <span class="file-page" aria-hidden="true">zip</span>    <div class="file-body">      <p class="file-name">atlas-build-2026-11-11.zip</p>      <p class="file-meta">Uploading · 64% of 182 MB</p>    </div>    <div class="file-end">      <button type="button" class="btn btn-quiet btn-square btn-sm" aria-label="Cancel the upload of atlas-build-2026-11-11.zip">        <XIcon class="icon" />      </button>    </div>    <progress class="progress file-progress" max="100" value="64" aria-label="Upload of atlas-build-2026-11-11.zip">      64%    </progress>  </li>  <li class="file" aria-busy="true">    <span class="file-page" aria-hidden="true">mp4</span>    <div class="file-body">      <p class="file-name">onboarding-walkthrough.mp4</p>      <p class="file-meta">Scanning for viruses…</p>    </div>    <progress class="progress file-progress" aria-label="Scan of onboarding-walkthrough.mp4"></progress>  </li></ul>
<script setup>import XIcon from '@master/icons-vue/native/16/soft/x'</script><template>  <ul class="flex flex-col gap-xs max-w(400) mx-auto">    <li class="file" aria-busy="true">      <span class="file-page" aria-hidden="true">zip</span>      <div class="file-body">        <p class="file-name">atlas-build-2026-11-11.zip</p>        <p class="file-meta">Uploading · 64% of 182 MB</p>      </div>      <div class="file-end">        <button type="button" class="btn btn-quiet btn-square btn-sm" aria-label="Cancel the upload of atlas-build-2026-11-11.zip">          <XIcon class="icon" />        </button>      </div>      <progress class="progress file-progress" max="100" value="64" aria-label="Upload of atlas-build-2026-11-11.zip">        64%      </progress>    </li>    <li class="file" aria-busy="true">      <span class="file-page" aria-hidden="true">mp4</span>      <div class="file-body">        <p class="file-name">onboarding-walkthrough.mp4</p>        <p class="file-meta">Scanning for viruses…</p>      </div>      <progress class="progress file-progress" aria-label="Scan of onboarding-walkthrough.mp4"></progress>    </li>  </ul></template>

#上传失败

file-failed 为文件面板加上危险状态的轮廓,并将 file-meta 改为危险状态的墨色。在该处说明出错原因,并在末端提供解决操作。ARIA 没有表示列表项失败的属性,因此用类名设置失败状态,由文字传达失败信息。为这段文字加上 role="alert",即可在用户浏览页面期间发生失败时播报。

上传失败

<div class="file file-failed max-w(400) mx-auto">  <span class="file-page" aria-hidden="true">mov</span>  <div class="file-body">    <p class="file-name">walkthrough-final-v2.mov</p>    <p class="file-meta" role="alert">Larger than the 100 MB limit</p>  </div>  <div class="file-end"><button type="button" class="btn btn-sm">Replace</button></div></div>
<div className="file file-failed max-w(400) mx-auto">  <span className="file-page" aria-hidden="true">mov</span>  <div className="file-body">    <p className="file-name">walkthrough-final-v2.mov</p>    <p className="file-meta" role="alert">Larger than the 100 MB limit</p>  </div>  <div className="file-end"><button type="button" className="btn btn-sm">Replace</button></div></div>
<div class="file file-failed max-w(400) mx-auto">  <span class="file-page" aria-hidden="true">mov</span>  <div class="file-body">    <p class="file-name">walkthrough-final-v2.mov</p>    <p class="file-meta" role="alert">Larger than the 100 MB limit</p>  </div>  <div class="file-end"><button type="button" class="btn btn-sm">Replace</button></div></div>
<template>  <div class="file file-failed max-w(400) mx-auto">    <span class="file-page" aria-hidden="true">mov</span>    <div class="file-body">      <p class="file-name">walkthrough-final-v2.mov</p>      <p class="file-meta" role="alert">Larger than the 100 MB limit</p>    </div>    <div class="file-end"><button type="button" class="btn btn-sm">Replace</button></div>  </div></template>

#紧凑样式

file-sm 采用单行布局,高 32px,宽度随文件名而定,可用作消息编辑器上方的附件,也可放在提及该文件的行内。它与小号按钮等高,可以同行排列。纸页图标太小,无法容纳扩展名,因此扩展名由旁边的文件名和文件信息呈现。无论使用哪种指针,末端控件的可见尺寸都是 24px,距面板边缘 4px。触摸屏上的触控区域以控件为中心扩展至 44px。

紧凑样式

<form class="composer max-w(480) mx-auto">  <div class="composer-attachments">    <span class="file file-sm">      <span class="file-page" aria-hidden="true"></span>      <span class="file-body">        <span class="file-name">report.pdf</span><span class="file-meta">2.4 MB</span>      </span>      <span class="file-end">        <button type="button" class="btn btn-quiet btn-square btn-sm" aria-label="Remove report.pdf">          <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">            <path d="M4 4L12 12" /><path d="M4 12L12 4" />          </svg>        </button>      </span>    </span>    <span class="file file-sm">      <img class="file-thumb" src="/demo/moonstone.svg" alt>      <span class="file-body"><span class="file-name">cover.png</span></span>      <span class="file-end">        <button type="button" class="btn btn-quiet btn-square btn-sm" aria-label="Remove cover.png">          <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">            <path d="M4 4L12 12" /><path d="M4 12L12 4" />          </svg>        </button>      </span>    </span>  </div>  <textarea class="composer-field" rows="1" placeholder="Add a note about these files" aria-label="Message"></textarea>  <div class="composer-toolbar">    <div class="composer-end">      <button type="submit" class="btn btn-primary btn-sm">Send</button>    </div>  </div></form>
import XIcon from '@master/icons-react/native/16/soft/x'<form className="composer max-w(480) mx-auto">  <div className="composer-attachments">    <span className="file file-sm">      <span className="file-page" aria-hidden="true"></span>      <span className="file-body">        <span className="file-name">report.pdf</span><span className="file-meta">2.4 MB</span>      </span>      <span className="file-end">        <button type="button" className="btn btn-quiet btn-square btn-sm" aria-label="Remove report.pdf">          <XIcon className="icon" />        </button>      </span>    </span>    <span className="file file-sm">      <img className="file-thumb" src="/demo/moonstone.svg" alt="" />      <span className="file-body"><span className="file-name">cover.png</span></span>      <span className="file-end">        <button type="button" className="btn btn-quiet btn-square btn-sm" aria-label="Remove cover.png">          <XIcon className="icon" />        </button>      </span>    </span>  </div>  <textarea className="composer-field" rows={1} placeholder="Add a note about these files" aria-label="Message">{``}</textarea>  <div className="composer-toolbar">    <div className="composer-end">      <button type="submit" className="btn btn-primary btn-sm">Send</button>    </div>  </div></form>
<script>  import XIcon from '@master/icons-svelte/native/16/soft/x'</script><form class="composer max-w(480) mx-auto">  <div class="composer-attachments">    <span class="file file-sm">      <span class="file-page" aria-hidden="true"></span>      <span class="file-body">        <span class="file-name">report.pdf</span><span class="file-meta">2.4 MB</span>      </span>      <span class="file-end">        <button type="button" class="btn btn-quiet btn-square btn-sm" aria-label="Remove report.pdf">          <XIcon class="icon" />        </button>      </span>    </span>    <span class="file file-sm">      <img class="file-thumb" src="/demo/moonstone.svg" alt>      <span class="file-body"><span class="file-name">cover.png</span></span>      <span class="file-end">        <button type="button" class="btn btn-quiet btn-square btn-sm" aria-label="Remove cover.png">          <XIcon class="icon" />        </button>      </span>    </span>  </div>  <textarea class="composer-field" rows="1" placeholder="Add a note about these files" aria-label="Message"></textarea>  <div class="composer-toolbar">    <div class="composer-end">      <button type="submit" class="btn btn-primary btn-sm">Send</button>    </div>  </div></form>
<script setup>import XIcon from '@master/icons-vue/native/16/soft/x'</script><template>  <form class="composer max-w(480) mx-auto">    <div class="composer-attachments">      <span class="file file-sm">        <span class="file-page" aria-hidden="true"></span>        <span class="file-body">          <span class="file-name">report.pdf</span><span class="file-meta">2.4 MB</span>        </span>        <span class="file-end">          <button type="button" class="btn btn-quiet btn-square btn-sm" aria-label="Remove report.pdf">            <XIcon class="icon" />          </button>        </span>      </span>      <span class="file file-sm">        <img class="file-thumb" src="/demo/moonstone.svg" alt>        <span class="file-body"><span class="file-name">cover.png</span></span>        <span class="file-end">          <button type="button" class="btn btn-quiet btn-square btn-sm" aria-label="Remove cover.png">            <XIcon class="icon" />          </button>        </span>      </span>    </div>    <textarea class="composer-field" rows="1" placeholder="Add a note about these files" aria-label="Message"></textarea>    <div class="composer-toolbar">      <div class="composer-end">        <button type="submit" class="btn btn-primary btn-sm">Send</button>      </div>    </div>  </form></template>

#可打开的文件

整个文件组件作为链接或按钮时,添加 file-interactive。它和按钮一样,默认凸起,指针悬停时抬升,按下时下沉。链接内部的各部分使用 <span>。

可打开的文件

<div class="grid grid-cols(2) gap-sm max-w(520) mx-auto">  <a class="file file-interactive" href="#" download>    <span class="file-page" aria-hidden="true">docx</span>    <span class="file-body">      <span class="file-name">Master services agreement.docx</span>      <span class="file-meta">48 KB · Download</span>    </span>  </a>  <a class="file file-interactive" href="#" download>    <span class="file-page" aria-hidden="true">xlsx</span>    <span class="file-body">      <span class="file-name">Pricing schedule.xlsx</span>      <span class="file-meta">22 KB · Download</span>    </span>  </a></div>
<div className="grid grid-cols(2) gap-sm max-w(520) mx-auto">  <a className="file file-interactive" href="#" download>    <span className="file-page" aria-hidden="true">docx</span>    <span className="file-body">      <span className="file-name">Master services agreement.docx</span>      <span className="file-meta">48 KB · Download</span>    </span>  </a>  <a className="file file-interactive" href="#" download>    <span className="file-page" aria-hidden="true">xlsx</span>    <span className="file-body">      <span className="file-name">Pricing schedule.xlsx</span>      <span className="file-meta">22 KB · Download</span>    </span>  </a></div>
<div class="grid grid-cols(2) gap-sm max-w(520) mx-auto">  <a class="file file-interactive" href="#" download>    <span class="file-page" aria-hidden="true">docx</span>    <span class="file-body">      <span class="file-name">Master services agreement.docx</span>      <span class="file-meta">48 KB · Download</span>    </span>  </a>  <a class="file file-interactive" href="#" download>    <span class="file-page" aria-hidden="true">xlsx</span>    <span class="file-body">      <span class="file-name">Pricing schedule.xlsx</span>      <span class="file-meta">22 KB · Download</span>    </span>  </a></div>
<template>  <div class="grid grid-cols(2) gap-sm max-w(520) mx-auto">    <a class="file file-interactive" href="#" download>      <span class="file-page" aria-hidden="true">docx</span>      <span class="file-body">        <span class="file-name">Master services agreement.docx</span>        <span class="file-meta">48 KB · Download</span>      </span>    </a>    <a class="file file-interactive" href="#" download>      <span class="file-page" aria-hidden="true">xlsx</span>      <span class="file-body">        <span class="file-name">Pricing schedule.xlsx</span>        <span class="file-meta">22 KB · Download</span>      </span>    </a>  </div></template>

#无障碍

  • 多个文件组成列表。使用 <ul>,并在每个 <li> 上添加 file。
  • 控件的无障碍名称应指明它作用于哪个文件,例如“移除 report.pdf”,而不是只写“移除”。
  • 为 <progress> 提供无障碍名称,并在文字中保留百分比。面板着色直观地呈现这个数值。
  • 过长的文件名会从末尾截断。如果末尾信息很重要,例如文件扩展名,请在 title 中保留完整文件名。

#类名

类名说明
file容纳页面图标、文字和控件的平面面板
file-failed用于上传失败的文件。轮廓和 file-meta 使用危险墨色,在 file-meta 中说明失败原因。与 file 一同使用
file-sm单行显示,高 32px,与小按钮等高,宽度随文件名而定。页面图标较小,省略扩展名。内部按钮尺寸为 24px,向内缩进 4px。与 file 一同使用
file-interactive整个文件项是一个链接或按钮,默认凸起,悬停时抬高,按下时下沉。与 file 一同使用
file-page小型页面图标,尺寸为 28 × 36,底部用大写字母标注文件扩展名。
file-thumb文件为图片时,以图片替代页面图标
file-body名称及其下方的一行信息。
file-name文件名显示为单行,超出时在末尾显示省略号
file-meta文件大小、类型、上传进度或失败原因
file-end末端控件,用于移除、重试或下载。
file-progress在 progress 元素上使用 progress 类,将进度条置于文字底层,并按上传进度为面板着色

#自定义属性

属性默认值说明
--file-padding.625rem面板的内边距,小尺寸文件项中为 .25rem
--file-radiusvar(--radius-control-lg)面板的圆角,小尺寸文件项使用 var(--radius-control-sm)
--file-page-width1.75rem页面图标的宽度,小尺寸文件项中为 1rem
--file-page-height2.25rem页面图标的高度,小尺寸文件项中为 1.25rem
--file-fold.5625rem折角大小,小尺寸文件项中为 .3125rem

#源码

@master/ui/components/file.css
/* * File: one file as a thing with a name: an attachment, an upload, a download. * A flat sheet holds a small page with the file's extension written on it, the name over a quiet line of * facts, and one control at the end. The page is a sheet of its own, 28 by 36, whose top corner is folded: * where the browser has corner-shape that corner is a bevel and the flap is what the bevel leaves of a small * square; elsewhere the page keeps four round corners and no flap. * While it uploads, a native <progress> lies under the words and tints the sheet as far as the upload has * come. A file that failed is file-failed: its contour and its facts take the danger ink. That state is a * class because ARIA has no word for it on a list item; the reason, in words, is in the facts. */@layer components.ui {  .file {    --file-padding: .625rem;    --file-radius: var(--radius-control-lg);    --file-page-width: 1.75rem;    --file-page-height: 2.25rem;    --file-fold: .5625rem;    --surface-color: var(--color-surface-raised);    position: relative;    /* What the sheet holds stands over the progress within the sheet, never over the page around it. */    isolation: isolate;    display: flex;    align-items: center;    gap: .75rem;    min-width: 0;    margin: 0;    padding: var(--file-padding);    padding-inline-end: calc(var(--file-padding) + .125rem);    border: 0;    border-radius: calc(var(--file-radius) * var(--corner-scale));    corner-shape: var(--corner-shape);    /* The progress fill is finished by the sheet's own corner. */    overflow: clip;    background: var(--color-surface-raised);    color: var(--color-text-body);    box-shadow: var(--shadow-flat);    font: 400 .875rem/1.4 var(--font-family-sans);    font-feature-settings: inherit;    text-align: start;    text-decoration: none;    /* Failed: the edge says so before the words do. */    &.file-failed {      --file-failed-edge: 0 0 0 .5px color-mix(in oklab, var(--color-danger) 60%, transparent), 0 0 0 3.5px color-mix(in oklab, var(--color-danger) 9%, transparent);      box-shadow: var(--file-failed-edge);      /* Why it failed is the one line that must be read whole: it wraps where the facts of a sound file end in an ellipsis. */      .file-meta {        color: var(--color-danger);        white-space: normal;        overflow-wrap: anywhere;      }    }    /* One line, 32px, as tall as a small button: an attachment above a composer, or a file named in a row. */    &.file-sm {      --file-padding: .25rem;      --file-radius: var(--radius-control-sm);      --file-page-width: 1rem;      --file-page-height: 1.25rem;      --file-fold: .3125rem;      display: inline-flex;      gap: .5rem;      max-width: 100%;      min-height: 2rem;      padding-inline: .625rem var(--file-padding);      font-size: .8125rem;      vertical-align: middle;      &:not(:has(.file-end)) {        padding-inline-end: .75rem;      }      .file-body {        display: flex;        align-items: baseline;        gap: .5rem;      }      /* The page is too small to carry its extension; the facts beside the name do. */      .file-page {        margin-inline: 0;        padding: 0;        color: transparent;        font-size: 0;      }      /* Its control is 24px, 4px inside the sheet, with the concentric corner. */      .btn {        --btn-height: 1.5rem;        --btn-radius: calc(var(--file-radius) - var(--file-padding) / var(--corner-scale));        --icon-size: .875rem;      }      /* A picture is the same 24px square at the other end, 4px in. */      .file-thumb {        width: 1.5rem;        height: 1.5rem;        margin-inline-start: calc(var(--file-padding) - .625rem);        border-radius: calc(var(--file-radius) * var(--corner-scale) - var(--file-padding));      }    }    /* A file that opens or downloads: a link or a button. It stands raised, lifts under the pointer and sinks when pressed. */    &.file-interactive {      --file-lift: calc(-1 * var(--lift));      @apply --surface-sheet;      box-shadow: var(--shadow-raised);      -webkit-tap-highlight-color: transparent;      user-select: none;      -webkit-user-select: none;      appearance: none;      cursor: pointer;      transition-property: box-shadow, translate;      transition-duration: var(--duration-quick);      transition-timing-function: var(--easing-glide);      @media (hover: hover) {        &:hover:not(:disabled, [aria-disabled="true"]) {          translate: 0 var(--file-lift);          box-shadow: var(--shadow-raised-hover);        }      }      &:active:not(:disabled, [aria-disabled="true"]) {        translate: 0 0;        background: var(--color-surface-inset);        box-shadow: var(--shadow-pressed);        transition-duration: var(--duration-press);      }      &:focus-visible {        @apply --focus-ring;      }      /*       * A file that cannot open yet, such as a download still being prepared, lies flat in a well, in disabled       * ink, as a disabled button does, and answers neither the pointer nor a press. Say why in file-meta.       */      &:is(:disabled, [aria-disabled="true"]) {        background: var(--color-surface-inset);        box-shadow: var(--shadow-flat);        cursor: not-allowed;        .file-name, .file-meta {          color: var(--color-text-disabled);        }      }      /* A failed file that opens keeps its danger edge over the sheet's depth, at rest, lifted and pressed. */      &.file-failed {        box-shadow: var(--file-failed-edge), var(--shadow-raised);        @media (hover: hover) {          &:hover:not(:disabled, [aria-disabled="true"]) {            box-shadow: var(--file-failed-edge), var(--shadow-raised-hover);          }        }        &:active:not(:disabled, [aria-disabled="true"]) {          box-shadow: var(--file-failed-edge), var(--shadow-pressed);        }      }      @media (prefers-reduced-motion: reduce) {        --file-lift: 0px;      }    }    @media (forced-colors: active) {      outline: 1px solid CanvasText;      outline-offset: -1px;      &.file-failed {        outline-color: Mark;      }      &.file-interactive:is(:disabled, [aria-disabled="true"]) {        outline-color: GrayText;        .file-name, .file-meta {          color: GrayText;        }      }    }  }  /*   * The page: a small raised sheet with the extension at its foot. Its contour is one step firmer than a   * surface's, since it is paper on paper.   */  .file-page {    position: relative;    display: flex;    flex: none;    align-items: flex-end;    justify-content: center;    width: var(--file-page-width);    height: var(--file-page-height);    /* It stands in the middle of the picture's 36px square, so names line up down a list of both. */    margin-inline: calc((2.25rem - var(--file-page-width)) / 2);    padding-bottom: .3125rem;    border-radius: calc(.1875rem * var(--corner-scale));    corner-shape: var(--corner-shape);    overflow: clip;    @apply --surface-sheet;    color: var(--color-text-muted);    box-shadow: inset 0 .5px 0 var(--color-highlight), 0 0 0 .5px var(--color-line-strong), 0 1px 2px -1px var(--color-shade-1), 0 2px 4px -2px var(--color-shade-2);    font: 600 .5rem/1 var(--font-family-sans);    font-feature-settings: inherit;    letter-spacing: .02em;    text-transform: uppercase;    user-select: none;    -webkit-user-select: none;    @supports (corner-shape: bevel) {      border-start-end-radius: var(--file-fold);      corner-start-end-shape: bevel;      /* The flap: a square in the folded corner, of which the bevel keeps the half that lies on the page. */      &::after {        content: '';        position: absolute;        inset-block-start: 0;        inset-inline-end: 0;        width: var(--file-fold);        height: var(--file-fold);        border-end-start-radius: 1.5px;        background: var(--color-surface-tray);        box-shadow: 0 0 0 .5px var(--color-line-strong), -1px 1px 2px -.5px var(--color-shade-1);      }      /* Right to left the fold is at the top left, and the flap casts its shadow toward the right. */      &:dir(rtl)::after {        box-shadow: 0 0 0 .5px var(--color-line-strong), 1px 1px 2px -.5px var(--color-shade-1);      }    }    @media (forced-colors: active) {      outline: 1px solid CanvasText;      outline-offset: -1px;    }  }  /* A picture stands in for the page when the file is one. Its corner is the sheet's less the padding, and never under 3px. */  .file-thumb {    display: block;    flex: none;    width: 2.25rem;    height: 2.25rem;    border-radius: max(.1875rem, calc(var(--file-radius) * var(--corner-scale) - var(--file-padding)));    corner-shape: var(--corner-shape);    object-fit: cover;    background: var(--color-surface-chip);    outline: 1px solid var(--color-line-image);    outline-offset: -1px;  }  /* The name and the facts: 20px and 16px lines, together as tall as the page beside them. */  .file-body {    display: grid;    flex: 1 1 0;    min-width: 0;  }  .file-name {    margin: 0;    overflow: hidden;    color: var(--color-text-strong);    font-weight: var(--font-weight-control);    line-height: 1.25rem;    text-overflow: ellipsis;    white-space: nowrap;  }  /* Size, kind, how far the upload is, or why it failed. */  .file-meta {    margin: 0;    overflow: hidden;    color: var(--color-text-muted);    font-size: .78125rem;    font-variant-numeric: tabular-nums;    line-height: 1rem;    text-overflow: ellipsis;    white-space: nowrap;  }  /* One control at the end: remove, retry or download. */  .file-end {    display: inline-flex;    flex: none;    align-items: center;    gap: .25rem;  }  /*   * On a <progress class="progress">: the bar is the sheet itself. It lies under the words from edge to edge   * and fills with a chip tone, so an upload reads as the sheet being tinted from its start, and the sheet's   * own corner finishes the fill. Without a value a band of the same tone travels across.   */  .file-progress {    --progress-color: var(--color-surface-chip);    position: absolute;    inset: 0;    height: 100%;    border-radius: 0;    background: transparent;    box-shadow: none;    pointer-events: none;    /* The fill ends in a hairline where the upload has come to: on its right, or on its left right to left. */    &::-webkit-progress-value {      border-radius: 0;      box-shadow: .5px 0 0 var(--color-line-contour);    }    &:dir(rtl)::-webkit-progress-value {      box-shadow: -.5px 0 0 var(--color-line-contour);    }    &::-moz-progress-bar {      border-radius: 0;    }    &:indeterminate {      background: linear-gradient(90deg, transparent, var(--progress-color) 30%, var(--progress-color) 70%, transparent) 0 0 / 40% 100% no-repeat;    }    /* Without travel the band would stand still at the start and read as an amount: an even tint says unknown. */    @media (prefers-reduced-motion: reduce) {      &:indeterminate {        background: color-mix(in oklab, var(--progress-color) 50%, transparent);      }    }  }  /* What the sheet holds stands over the bar. */  .file-page, .file-thumb, .file-body, .file-end {    position: relative;    z-index: 1;  }}