Thumbnail

A framed image. The edge is drawn inside the picture, so it reads as a window onto the image rather than a field holding one.

@patternmode/thumbnail

  • Light study1264 × 848
  • Concrete room1264 × 848
  • Slit window, raised1264 × 848
  • Earth corridor1264 × 848
  • Warm chamber1264 × 848
  • Rammed light1264 × 848

Reference

States and variants

Square at a fixed size by default, so a list stays even. Every value is a custom property.

  • Sunlight crossing the floor of a room with textured earth walls

    Inset edge

    default
  • Sunlight crossing the floor of a room with textured earth walls

    Inset edge with lift

    raised
  • Sunlight crossing the floor of a room with textured earth walls

    Larger radius

    radius={12}
  • Sunlight crossing the floor of a room with textured earth walls

    Whole picture

    fit="contain"
  • Sunlight crossing the floor of a room with textured earth walls

    Sized by the picture

    size={null}
  • Sunlight crossing the floor of a room with textured earth walls

    Dark mode

    edge turns to a highlight

Install and use

Pass src for a plain img, or children for your own media element. Needs Tailwind CSS v4.

npm i @patternmode/thumbnail
import { Thumbnail } from "@patternmode/thumbnail";
import "@patternmode/thumbnail/styles.css";

<Thumbnail src={thumbHref} alt="" size={32} />

<Thumbnail size={null} fit="contain">
  <Image src={previewHref} alt={caption} width={640} height={640} />
</Thumbnail>

Core API

Thumbnail

A media frame with an inset edge. Accepts ordinary span props and a ref.

src
stringImage URL. Renders a plain image element.
alt
string""Image description; use an empty string when adjacent text describes it.
children
ReactNodeYour own image, video, or canvas. Takes precedence over src.
size
number | string | null"2rem"Square edge length. Numbers are pixels; null lets the media determine height.
radius
number | string"3px"Corner radius. Numbers are pixels.
fit
"cover" | "contain""cover"Crop to fill the frame or keep the whole image visible.
position
string"center"Object position for an off-centre crop.
raised
booleanfalseAdds a small downward shadow to separate the image from its surface.

Accessibility

Decide the alt text from the row around the image.

alt=""
The default. If the row already names the thing, repeating it is noise.
children
Your own element keeps its own alt and props. The frame doesn't wrap or clone them.
Dark mode
Follows prefers-color-scheme. A black edge on a dark surface would vanish.

Package

Package
@patternmode/thumbnail
Version
0.1.6
Needs
react, react-dom
Licence
MIT