Skip to Content
Urban Cowboy
Components

Photo

Image with a deterministic gradient fallback for missing or broken sources.

Photo renders an <img> or, when the source is absent or fails to load, a gradient-filled role="img" placeholder with the same accessible label. It is used across room and journey cards so a broken asset never leaves an empty box. The docs demo uses a checked-in local SVG instead of a remote photograph, so it works offline and under the Pages base path.

The Lodge building illustration
*
*
string
string
string

Former Storybook states

Props

PropValuesNotes
srcstring, null or undefinedAbsent source renders the gradient fallback
altstringAccessible label for both the image and the fallback
classNamestringSizing and shape; applied to both states
gradientstringTailwind gradient classes for the fallback

The component is lazy-loaded (loading="lazy") and resets its error state whenever src changes, so swapping in a valid source recovers the image.

Responsive behaviour

Sizing is entirely caller-controlled through className; the component adds no intrinsic dimensions. The fallback fills the same box, so layouts do not shift when an image fails.

Usage

import { Photo } from '@/components/media/photo';

<Photo src={photoUrl} alt="Alpine Bathing Suite" className="size-64 object-cover" />

View source