import { AssetPreview } from "@elabs-ai/components-ai";npm install @elabs-ai/components-tokens @elabs-ai/components-ui @elabs-ai/components-aiPaste it into Claude Code, Cursor, Codex or any other coding agent. Text in [brackets] is yours to fill in.
Add the brand-ui AssetPreview component (from @elabs-ai/components-ai) to this project. 1. Read https://elabs-ai.com/llms.txt first: it maps every package and the rules. If you can use MCP servers, connect https://elabs-ai.com/mcp and use its search, docs and tokens tools. If not, run the same lookups in the terminal: `npx -y @elabs-ai/components-cli search "<what you need>"` and `npx -y @elabs-ai/components-cli docs <Component>`. 2. Look AssetPreview up before writing code: `npx -y @elabs-ai/components-cli docs AssetPreview` prints its real props, variants, what it pairs with and what to avoid. 3. If @elabs-ai/components-ai is not installed yet: `pnpm add @elabs-ai/components-tokens @elabs-ai/components-ui @elabs-ai/components-ai` (or `npm install @elabs-ai/components-tokens @elabs-ai/components-ui @elabs-ai/components-ai`). If this is the first brand-ui package in the project, wire it once: import `@elabs-ai/components-tokens/styles.css` plus the `themes/light.css` and `themes/dark.css` stylesheets in the CSS entry, add one Tailwind `@source` line per installed @elabs-ai package (Tailwind does not scan node_modules, so without it everything renders unstyled), and wrap the app root in `ThemeProvider` from `@elabs-ai/components-tokens`. 4. Use it here: [the screen or file, and what it should show] 5. Rules: use only @elabs-ai/components-* components and the semantic tokens — no raw colours, no raw font sizes, no arbitrary Tailwind values. Look up each component's real props with the docs tool before you use it; never guess a prop. 6. Done means: the typecheck passes, `npx -y @elabs-ai/components-cli audit src --strict` reports nothing, and you have opened the app and looked at every screen you touched in the light and the dark theme.
Avoid
- Rendering produced markdown through CodeBlock/Shiki — a document is a document; only the explicit Raw toggle shows source.
- Holding the selected asset in local state — selection lives in ContextPanelProvider, which the tree and the preview both read.
- Switching on the file extension in the consumer — pass the `ContextAsset` and let the preview key off `type`.
Works with
Used inside
Pairs with
Examples
Sql
Code/SQL renders via CodeBlock (Shiki), soft-wrapped for the narrow rail.
Csv
CSV renders as a small table with a row-count summary.
Image
Image renders through the ui `Image` primitive (`fit="contain"`, lazy) — no Raw toggle.
Raw By Default
Raw mode as the initial state.
Injected Renderer
A format this package cannot parse, drawn by an injected renderer. `renderPreview` is how a PDF, a spreadsheet or a video reaches the rail: `@elabs-ai/components-viewer` is a layer PEER of this package, so neither may import the other (ADR 0024 §6) and the consuming app owns the edge — `renderPreview={(asset) => asset.source ? <FileViewer source={asset.source} /> : null}`. The stand-in below keeps this story free of that import. A renderer that returns `null` declines, so every built-in format above is untouched by an injection that only knows PDFs.
API
AssetPreview
| Prop | Type | Description |
|---|---|---|
assetrequired | ContextAsset | |
defaultMode | AssetPreviewMode | Initial mode. Default `"preview"`. |
renderPreview | AssetPreviewRenderer | Draw this asset's preview body yourself; return `null` to decline and get the built-in rendering. Wins over a renderer injected on `ContextPanelProvider`, so one rail-wide default can still be overridden for a single preview. |