Thumbnail Tile

View as Markdown

A file or a picture as a small card: its preview or type, then a name that keeps its extension.

When to use

A file or a picture as a small card: its preview or type, then a name that keeps its extension. Use File Field instead when people are adding the file, not browsing it.

Usage

import { ThumbnailTile } from "./ui/uicontext/components/ThumbnailTile.ts"
export const File = <M>(h: Html.H<M>) => ThumbnailTile(h, { name: "Floor plan.pdf", meta: "1.2 MB", href: "/files/42" })

Examples

Choosing files

With onPress and selected, a tile is a toggle; ratio and fit suit square logos.

Chosen: 1 of 4

API reference

Options

ThumbnailTile options
NameTypeDescription
namerequiredstringThe file's or item's name: "Quarterly report.pdf".
metastringA quieter line under the name: "2.4 MB · Edited 2h ago".
image{ readonly src: string; readonly alt?: string }Its picture. Leave alt empty when the name says it all.
typestringThe word shown when there's no picture; the name's extension by default ("PDF").
ratiostringThe picture's shape, as CSS writes it; "4 / 3" by default.
fit"cover" | "contain"cover (the default) fills the frame; contain shows the whole picture, for logos and designs.
hrefstringMakes the tile a link.
onPressMessageMakes the tile a button.
selectedbooleanChosen, as in a picker: a ring and a check. Pressing a tile with onPress toggles it.
actionView.ContentA small control in the top corner, such as a More menu's button. It sits outside the tile's own target.
styleStyle—

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/thumbnail-tile

Source