Blocks
Copy for LLM
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.
Installation
npx @glasskit-ui/cli add media-thumbInstall the SDK (it provides GlassViewport, useDpad and the stylesheet), then copy these files into your project:
npm install @glasskit-ui/react// components/lib/utils.tsimport { clsx, type ClassValue } from "clsx";import { twMerge } from "tailwind-merge";export type { ClassValue };/** * Merge class names the shadcn way: clsx joins conditionals, tailwind-merge * de-dupes conflicting Tailwind utilities so a consumer's `className` override * wins (e.g. passing `px-2` beats the component's `px-6`). Lens components are * Tailwind utilities + `--gk-*` tokens, so this de-dupe matters. */export function cn(...inputs: ClassValue[]): string { return twMerge(clsx(inputs));}/** * 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 (or a masonry * `gk-gallery`) for a gallery; pass `onSelect` to make the tile D-pad-focusable * and fire it on Enter. */export function MediaThumb({ src, alt = "", label, duration, aspect = "square", onSelect, className,}: { /** Image URL. */ src?: string; alt?: string; /** Optional caption overlay. */ label?: ReactNode; /** Optional duration pill (e.g. "0:14"). */ duration?: ReactNode; aspect?: "square" | "portrait"; /** When set, the tile becomes a focusable button and fires this on Enter. */ onSelect?: () => void; className?: string;}) { const cls = cn( "gk-mediathumb", `gk-mediathumb--${aspect}`, onSelect && "focusable", className, ); const inner = ( <> {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="t-caption absolute top-[9px] end-[9px] rounded-full bg-black/55 px-[9px] py-[4px] text-white [font-variant-numeric:tabular-nums]"> {duration} </span> ) : null} {label != null ? ( <span className="t-caption absolute bottom-[9px] start-[11px] font-semibold text-white [text-shadow:0_1px_3px_rgba(0,0,0,0.6)]"> {label} </span> ) : null} </> ); if (onSelect) { return ( <button type="button" className={cls} onClick={onSelect}> {inner} </button> ); } return <div className={cls}>{inner}</div>;}Usage
// a focusable photo tile (mixed aspects make a masonry stagger)<MediaThumb src={photo.src} label={photo.label} aspect={photo.aspect} // "square" | "portrait" onSelect={() => open(photo)}/>// for a vertical masonry, deal the tiles into two// .gk-gallery__col stacks inside a .gk-gallery container.Props
| Prop | Type | Default | Description |
|---|---|---|---|
src | string | — | Image URL (else a gradient placeholder). |
label | ReactNode | — | Caption overlay. |
duration | ReactNode | — | Duration pill (for video/reels). |
aspect | "square" | "portrait" | "square" | Tile ratio. Mixed aspects make a masonry stagger. |
onSelect | () => void | — | Makes the tile a focusable button, fired on Enter. |
NotificationCard
An incoming notification: avatar, sender, time, a message preview, and optional quick actions. The glanceable comms surface (richer than a Toast).
NowPlaying
A media now-playing card: album art, title + artist, a scrub bar, and elapsed / remaining times. A status display for playback your app tracks. Audio support in the Display webview is undocumented; verify on-device.