Data display
Thumbnail
A small square image with a fallback icon: product photos, line images, uploaded files. The sizes are sm (40 px, lines and rows), md (64 px, files and lists) and lg (96 px, galleries and summaries). The icon shows when there is no src or the image does not load; fallback changes it. alt is required: it names the image, the icon and the link. caption is one line under the image, cut with the full text in the title. With href the whole thumbnail is a link. For an upload field use ImageField; for a person use Avatar. size="fill" takes the full width of its box at 4:3, for a tile image (see the media of Card).
import { Thumbnail } from "@percentsa/ui";Examples
Code
export function ThumbnailExample() {
const t = useT();
// data: URL, so the example needs no file.
const photo = "data:image/svg+xml," + encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 8 8"><rect width="8" height="8" fill="#888"/><circle cx="4" cy="4" r="2.5" fill="#ccc"/></svg>');
return (
<Inline gap={6} align="start" className="w-full">
<Thumbnail src={photo} alt={t("Product photo", "صورة المنتج")} size="sm" />
<Thumbnail src={photo} alt={t("Product photo", "صورة المنتج")} size="md" />
<Thumbnail src={photo} alt={t("Product photo", "صورة المنتج")} size="lg" />
<Thumbnail src={null} alt={t("Brake pad set", "طقم فحمات")} size="md" />
<Thumbnail alt="supplier-invoice.pdf" fallback={<FileText />} caption="supplier-invoice.pdf" href="#file" size="md" />
</Inline>
);
}
/** A state at value size: a dot and a word. */