ファイル
添付、アップロード、ダウンロードの各ファイルを名前付きの項目として表示します。
このページの内容
ファイル1件を独立した項目として表示します。拡張子を記した小さな書類アイコン、ファイル名とその下に控えめに表示する詳細情報、末尾の操作コントロール1つで構成します。各項目は平坦な面を持ち、ドロップゾーンの下やダイアログ内に縦に並べても、ファイルごとの区切りがわかります。
ファイル
<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の書類アイコンです。下部に記した拡張子は、入力時の大文字・小文字にかかわらず大文字で表示されます。拡張子は4文字以内に収めてください。隣のファイル名からも拡張子がわかるため、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の1行表示で、幅はファイル名に応じて決まります。メッセージ入力欄の上に添付ファイルを表示したり、行内でファイルを示したりするのに使います。小サイズのボタンと高さが同じなので、同じ行に並べられます。書類アイコンは小さく拡張子を表示できないため、隣のファイル名と詳細情報で伝えます。末尾の操作コントロールはどのポインターでも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 | 1行で表示します。高さは小サイズのボタンと同じ 32px で、幅はファイル名に合わせます。用紙が小さいため拡張子は表示せず、内側のボタンは 24px で、端から 4px 内側に配置します。file と併用します |
file-interactive | ファイル項目全体がリンクまたはボタンになります。通常時は浮いて見え、ポインターを重ねるとさらに浮き上がり、押すと沈みます。file と併用します |
file-page | 28 × 36の小さな用紙。下端に拡張子を大文字で表示 |
file-thumb | ファイルが画像の場合、ページの代わりに画像を表示 |
file-body | 名前と、その下に概要を添える 1 行 |
file-name | 1 行で表示し、収まらない場合は末尾を省略記号で示すファイル名。 |
file-meta | サイズ、種類、アップロードの進捗、または失敗の理由 |
file-end | 終端の操作ボタン。削除、再試行、ダウンロードのいずれか。 |
file-progress | progress 要素に progress を適用すると、バーがテキストの背面に表示され、アップロードの進捗に応じた範囲までシートに色を付けます。 |
#カスタムプロパティ
| プロパティ | 既定値 | 説明 |
|---|---|---|
--file-padding | .625rem | シートの内側の余白。小サイズでは .25rem。 |
--file-radius | var(--radius-control-lg) | シートの角丸。小サイズでは var(--radius-control-sm)。 |
--file-page-width | 1.75rem | 用紙の幅。小サイズでは 1rem。 |
--file-page-height | 2.25rem | 用紙の高さ。小サイズでは 1.25rem。 |
--file-fold | .5625rem | 折り返した角のサイズ。小サイズでは .3125rem。 |
#関連項目
- ドロップゾーンファイルの選択やドロップに使う広い領域。ネイティブのファイル入力を使うので、スクリプトなしで動作します。
- メッセージ入力欄メッセージやプロンプトを作成するためのコンポーネント。入力に合わせて伸びる入力欄の下にツールが並びます。
- リスト画像やアイコン、テキスト、末尾の要素を並べた行の一覧。