# Files

> Files an agent made or fetched, as cards in a conversation or a task's list.

Page: https://uicontext.com/docs/components/files

Group: Agents.

## When to use

Files an agent made or fetched, as cards in a conversation or a task's list. Use [Deliverable Viewer](https://uicontext.com/docs/components/deliverable-viewer.md) instead when you open one file to read it.

## Usage

```ts
import { FileCard, FileList } from "./ui/uicontext/components/FileList.ts"

export const Files = <M>(h: Html.H<M>) => [
	FileCard(h, { file: { id: "agenda", name: "Kickoff agenda.pdf", size: 1_240_000, detail: "12 pages", href: "/files/agenda.pdf" } }),
	FileList(h, {
		label: "Files",
		files: [{ id: "remit", name: "remittance-4410.pdf", size: 98_304, source: "From Priya Anand's email", href: "/files/remittance-4410.pdf" }],
		empty: "Files the assistant downloads or makes show up here.",
	}),
]
```

## Examples

Each example is a complete file. Its imports point where the CLI installs the source.

### A task's files

Newest first, each with its kind, its size and the step that made or fetched it. Long names are cut in the middle so the version and extension stay.

```ts title="src/demo.ts" source="www/src/examples/files/demo.ts"
import type { Html } from "effect/ui/html"
import * as stylex from "@stylexjs/stylex"
import { FileList } from "./ui/uicontext/components/FileList.ts"
import { sx } from "./ui/uicontext/components/Sx.ts"
import { color, corner } from "./ui/uicontext/components/tokens.stylex.ts"

const styles = stylex.create({ panel: { width: "min(100%, 26rem)", padding: 6, borderRadius: corner.card, borderWidth: 1, borderStyle: "solid", borderColor: color.line } })

export const TaskFiles = <M>(h: Html.H<M>) =>
	h.div.attrs(sx(styles.panel)).children(FileList(h, {
		label: "Files",
		locale: "en-US",
		files: [
			{ id: "csv", name: "operating-november.csv", size: 12_800, source: "Downloaded from the bank", href: "#csv" },
			{ id: "remit", name: "remittance-4410.pdf", size: 98_304, source: "From Priya Anand's email", href: "#remit" },
			{ id: "deck", name: "Q3 Board Deck — FINAL (revised) v12 [approved by legal].pdf", size: 8_400_000, detail: "31 pages", source: "Made from the ledger", href: "#deck" },
			{ id: "photo", name: "IMG_20250914_183022_HDR_portrait_edited_edited.HEIC", size: 3_100_000, source: "From your phone" },
		],
	}))
```

### Attachment cards

A file in a conversation: kind, name, what's in it and its size, and a download. Without a link there's nothing to press.

```ts title="src/cards.ts" source="www/src/examples/files/cards.ts"
import type { Html } from "effect/ui/html"
import * as stylex from "@stylexjs/stylex"
import { FileCard } from "./ui/uicontext/components/FileList.ts"
import { sx } from "./ui/uicontext/components/Sx.ts"
import { space } from "./ui/uicontext/components/tokens.stylex.ts"

const styles = stylex.create({ column: { display: "flex", flexDirection: "column", gap: space.sm } })

export const Cards = <M>(h: Html.H<M>) =>
	h.div.attrs(sx(styles.column)).children(
		FileCard(h, { file: { id: "a", name: "Halcyon kickoff agenda.pdf", size: 1_240_000, detail: "12 pages", href: "#a" } }),
		FileCard(h, { file: { id: "b", name: "Invoices due Friday.csv", size: 4_200, href: "#b" } }),
		FileCard(h, { file: { id: "c", name: "2026-11-30.md", size: 4_700, detail: "Draft" } }),
	)
```

## API reference

### FileCard (view function)

**Options**

| Name | Type | Description |
| --- | --- | --- |
| `file` (required) | `FileItem` | — |
| `locale` | `string` | — |
| `style` | `Style` | — |

### FileList (view function)

**Options**

| Name | Type | Description |
| --- | --- | --- |
| `label` (required) | `string` | — |
| `files` (required) | `FileItem[]` | — |
| `empty` | `string` | Shown with no files: what will appear here |
| `locale` | `string` | — |

## Installation

```sh
pnpm dlx shadcn@latest add checkfu/uicontext/files
```

With npm: `npx shadcn@latest add checkfu/uicontext/files`. With yarn: `yarn dlx shadcn@latest add checkfu/uicontext/files`. With bun: `bunx --bun shadcn@latest add checkfu/uicontext/files`.

It writes these files:

- `src/ui/uicontext/components/FileList.ts`
- `src/ui/uicontext/components/Sx.ts`
- `src/ui/uicontext/components/domain/Format.ts`
- `src/ui/uicontext/components/domain/Outcome.ts`
- `src/ui/uicontext/components/domain/Upload.ts`
- `src/ui/uicontext/components/tokens.stylex.ts`

And installs the npm packages `@stylexjs/stylex`, `effect`.

## Source

- [src/FileList.ts](https://github.com/checkfu/uicontext/blob/main/src/FileList.ts)

## Used in

- [Email](https://uicontext.com/blocks/email.md)

## Related

- [Agent Tools](https://uicontext.com/docs/components/agent-tools.md) (`agent-tools`): Lets agents in the browser read the page and act through the same controls people use.
- [Tool Confirmation](https://uicontext.com/docs/components/tool-confirmation.md) (`tool-confirmation`): Asks a person to confirm before an agent's action changes anything.
- [Prompt Template](https://uicontext.com/docs/components/prompt-template.md) (`prompt-template`): Write a prompt with {{variables}} the app fills in: they stand out, unknown ones are flagged, and a preview shows it with samples.
- [Agent Settings](https://uicontext.com/docs/components/agent-settings.md) (`agent-settings`): Edit an agent's name, instructions, tools and model.
- [Computer](https://uicontext.com/docs/components/computer.md) (`computer`): The machine an agent works on: a live view of its screen, full size or as a thumbnail with Take over, and its browser with tabs and an address bar.
- [Persona Avatar](https://uicontext.com/docs/components/persona-avatar.md) (`persona-avatar`): An agent's face: a shape and a color with eyes that move with what it's doing.
