GlassKit UI
Components

MediaThumb

A photo / reel tile (Photos, Instagram): a rounded media tile with optional duration pill and caption overlay. Compose in a grid for a gallery.

Trail
0:14
Café
600 × 600 · live

Installation

npx @glasskit-ui/cli add media-thumb

Install the SDK (it provides GlassViewport, useDpad and the stylesheet), then copy these files into your project:

npm install @glasskit-ui/react
// components/lib/utils.tsexport type ClassValue = string | number | null | undefined | false;/** * Join truthy class names. Dependency-free on purpose: the lens components * style via bespoke semantic classes (no conflicting Tailwind utilities to * de-dupe), so this needs no clsx/tailwind-merge and resolves from anywhere * the registry is vendored. */export function cn(...inputs: ClassValue[]): string {  return inputs.filter(Boolean).join(" ");}/** * Accessible name from a free-form `label` prop: the label itself when it's a * plain string, otherwise undefined (a ReactNode can't become an aria-label). */export function stringLabel(label: unknown): string | undefined {  return typeof label === "string" ? label : undefined;}
// components/glasskit/media-thumb.tsximport type { ReactNode } from "react";import { cn } from "../lib/utils";/** * <MediaThumb> — a photo / reel tile (Photos, Instagram). A rounded media tile * with an optional duration pill and a caption overlay. Pass an <img> as `src`, * or it falls back to a gradient placeholder. Compose in a grid for a gallery. */export function MediaThumb({  src,  alt = "",  label,  duration,  aspect = "square",  className,}: {  /** Image URL. */  src?: string;  alt?: string;  /** Optional caption overlay. */  label?: ReactNode;  /** Optional duration pill (e.g. "0:14"). */  duration?: ReactNode;  aspect?: "square" | "portrait";  className?: string;}) {  return (    <div className={cn("gk-mediathumb", `gk-mediathumb--${aspect}`, className)}>      {src ? (        // eslint-disable-next-line @next/next/no-img-element        <img className="gk-mediathumb__img" src={src} alt={alt} />      ) : (        <span className="gk-mediathumb__ph gk-grad-violet" aria-hidden="true" />      )}      {duration != null ? (        <span className="gk-mediathumb__dur t-caption">{duration}</span>      ) : null}      {label != null ? (        <span className="gk-mediathumb__label t-caption">{label}</span>      ) : null}    </div>  );}

Usage

<MediaThumb src={photo} label="Trail" /><MediaThumb src={reel} duration="0:14" aspect="portrait" />

Props

Prop

Type