Bruno DelorenceBruno
Appearance
Appearance

Choose your reading theme.

Contact

Listing cards

Six listing cards (a recipe, rentals, homes for sale) with high-definition photographs that swipe like a carousel.

listing-cards/listing-cards.tsx
Live · interactive
Chicken and spiced rice in a copper pot, with two small bowls
Hot choice

Lebanese Lemon Garlic Chicken

Juicy chicken roasted with lemon, garlic and sumac, served over warm, fragrant rice.

  • 20 mins
  • 4 servings
  • Medium
  • Yogurt
  • Olive oil
  • +8
A sunlit living room with a caramel sofa and two armchairs
Guests Favorite

Business Bay

$3,679 /m

Bright, calm, spacious, central...

  • Beds: 2
  • Baths: 2
  • Sqft: 1150
A white farmhouse in tall grass, smoke rising from its chimney
Prime Pick

$250,000 List price

Corentin Vallois - Mila lindenbergerstr, 1063 AG

  • 29 m² Living
  • 2 Rooms
A white cottage with arched windows on a mown lawn
Newly listed

Highland Huts

$200k

235 Fernhill Ave, Los...

  • Beds: 2
  • Baths: 1
  • Sqft: 1150
A white farmhouse in tall grass under a pale sky, birds overhead
Prime Pick

List: $250,000

Mila lindenhofstr...
1063 AG Corentin Vallois

29 m²
Living
2
Rooms

By Idris Malouf 2 days ago

A stone guest house under ivy at dusk, its windows lit

The Hills Guest House

58 Ashbrook Road, Ellisley, B17 0LA

  • Beds: 4
  • Baths: 2
  • Sqft: 1150
$620

The live component, numbered part by part. Every measurement is read from it as it is drawn. Point at a row to outline its part, or at a part to find its row.

The choices it offers, each value drawn live and the default marked, with how to pick one.

When to use

  • A grid of things to browse and compare at a glance: homes, stays, recipes, products with photos.
  • Items whose photos sell them, where a few pictures per card save a trip to the detail page.
  • One action per card that can happen right there: save, reserve, start, view details.
  • Mixed kinds on one board, each card shaped by what it lists but drawn from one unit.

When not to use

  • Long lists to scan and sort by a figure. Use a table or a dense list with columns.
  • Items without good pictures: an empty photo box weighs more than a line of text.
  • Several actions on each item. Put them on the detail page, or in a menu on a row.
  • One item on its own page. Use a full gallery and the details laid out in full.

Photos

  • Three or four per card. Enough to decide whether to open it; the rest belongs on the detail page.
  • The whole thing first, then closer crops or other rooms: the first photo is the one most people see.
  • Each photo labelled with what it shows, not with “Photo 1”: “A bedroom with linen sheets and a sheer curtain”.
  • One photo only? Use the still photo card. With a single slide the arrows and the dots leave on their own.

Actions on a card

  • One button per card, at its foot: Start Cooking, View Details, Reserve Apartment. onAction says which was pressed.
  • Saving sits on the photo, as a heart in the corner, so it never competes with the card’s button.
  • Toggles stay in place. The heart and Reserve each hold both of their states, so a press never moves the card.
  • The card itself isn’t a link. Its one button is the way in, and a drag on the photos only turns them.

Each one drawn with the component itself, used well or badly.

A card is read in a glance: the photo first, then a title, a figure and a line or two.

  • The title names the place or the dish in a few words: Business Bay, Highland Huts.
  • The price carries its period when it has one: $3,679 /m. A list price says so.
  • The badge is two words at most, on what sets the listing apart: Newly listed, Prime Pick. One badge per card.
  • The facts are a figure and a noun each, 2 Rooms, 20 mins, in a row of three at most.
  • The button is a verb and its object: View Details, Reserve Apartment. Its pressed label is short enough to fit the same width: Reserved.
  • Each photo’s label describes it in a short sentence, for the people who can’t see it.

You can add this component with the shadcn CLI or by hand:

Either way it needs React 19 and a bundler that supports CSS Modules, such as Next.js or Vite. It has a dark colour scheme: it follows your page’s color-scheme, light unless the page sets one, or its colorScheme prop, with nothing to configure. Browsers without light-dark() show it light.

Usage

listings.tsx
import { ListingCards } from './listing-cards';export function Listings() {  return (    <ListingCards      autoplay={false}      onLikeChange={(liked) => console.log('saved', liked)}      onAction={(action) => console.log(action)}    />  );}

Each state below is a live instance, locked so you can study it.

The pieces it is built from, each with its measurements read live.

A board of six cards of different kinds: a recipe with its timings and ingredients, a flat to rent, a house for sale, and three photo cards with their details on a soft shade. Ten native-resolution photographs bring warm interiors, real architecture and food photography to the cards. The photos swipe, step with arrows or keys, and follow their dots. Cards lift under the pointer, the heart saves the flat, and the guest house can be reserved.

  • Ten 1448 × 1086 local WebP photographs are shared across the six cards. Each slide shows a whole scene or a closer crop using its original scene coordinates. Native lazy loading and asynchronous decoding keep the board light while preserving detail.
  • Each set of photos is a small carousel. A drag or swipe moves the shown slide and its neighbours with the hand, and past a fifth of the width, or after a flick, it moves on. The arrows wrap around, the arrow keys step up to either end, and the dots shrink when they are far from the photo shown.
  • Each card’s photo box paints on one fixed layer of its own. The slides inside it are absolutely placed boxes that glide frame by frame, so a turn never makes a layer wider than the photos and never repaints the page around it.
  • Every size is a multiple of one unit, set from the stage’s width by a container query, so the board scales as one drawing. Below 680px it turns to two columns, and below 440px to one.
  • The heart and the Reserve button each hold both of their states, drawn in place, and swap them by visibility. The heart pops with the Web Animations API, and a card’s deeper hover shadow fades in by its opacity.
  • Every interface colour is a light-dark() token on the root, so the cards follow the page’s color-scheme, or the colorScheme prop; the photographs, and what is drawn over them (badges, arrows, the heart, the price pill), stay as they are.
PropTypeDefaultDescription
defaultLikedbooleanfalseWhether the flat starts saved.
defaultReservedboolean—Whether the guest house opens already reserved. Setting it to true turns the demo off.
onLikeChange(liked: boolean) => void—Called when the reader saves the flat or takes it off their list.
onAction(action: ListingAction) => void—Called when the reader presses a card’s button: start-cooking, view-details, reserve or cancel-reservation.
autoplaybooleantrueWhile on screen and untouched, a demo pointer flips through photos and presses buttons.
colorScheme'light' | 'dark' | 'system'—Its colours: light, dark, or the reader’s system setting. Without it the component follows the page’s color-scheme, which is light unless the page sets one.
classNamestring—Extra class for the root, a stage of its own.

Screen readers

  • Each card is an article named by its title. Its photos are a group described as a carousel, named “Photos of Business Bay”, and each slide is labelled “2 of 4”; only the slide shown is exposed.
  • Saving, reserving and turning a photo are announced in a polite live region (“Photo 2 of 4.”, “Business Bay saved.”); the demo’s own moves stay silent. The dots are hidden, since the announcement says the same.

Keyboard

In each card, Tab reaches the Previous photo and Next photo buttons first, then the heart or the card’s own button. The two arrows show as soon as either takes the focus, and they wrap around. While the focus is on a button in the photos, Left and Right also step through them and stop at either end. The photos themselves aren’t a tab stop: the two buttons already do that job, as in a usual carousel.

Toggle buttons

The heart and Reserve are real buttons with aria-pressed. The heart keeps one name, “Save Business Bay”, and its pressed state says whether it is saved; Reserve’s visible words change with it. Both draw a 2 px blue focus ring.

Contrast

The words on the cards, the muted ones included, reach 4.5:1 in both schemes (WCAG 1.4.3). On the photo cards, the shades and the frosted badge are dark enough for the white words to keep 4.5:1 over every photo, and the white heart has a dark edge that keeps it 3:1 against a bright one (WCAG 1.4.11).

Touch, pointer and motion

A swipe sideways turns the photos, and an up or down swipe still scrolls the page; the arrow buttons do the same with a single press. The arrows and the heart are drawn small, but each answers a press across at least 24 by 24 px (WCAG 2.5.8). The demo stops for good at the reader’s first press, key, mouse move or keyboard focus on the board (WCAG 2.2.2). Under reduced motion the photos change at once, the heart doesn’t pop, the cards’ transitions stop and the demo never plays.

In this build

  • Each card is an article named by its title. Each set of photos is a group described as a carousel, its slides are labelled “2 of 4”, and every photograph is labelled with what it shows.
  • The Previous photo and Next photo buttons show on focus as well as on hover, and the arrow keys step through the photos. Vertical swipes still scroll the page (touch-action: pan-y).
  • The heart and Reserve are real toggle buttons with aria-pressed. Saving, reserving and turning a photo are announced in a polite live region; the demo’s own actions stay silent.
  • Keyboard focus anywhere on the stage stops the demo. Under reduced motion, turns jump and the demo never plays.

The complete source behind this demo. Open source under the MIT license, © 2026 Bruno Delorence: copy it, change it, ship it.

listing-cards.tsx
// Copyright (c) 2026 Bruno Delorence. MIT License.'use client';import { useEffect, useRef, useState, type FocusEvent } from 'react';import type { CarouselHandle } from './carousel';import { CottageCard, FlatCard, GuestHouseCard, HouseCard, ListingCard, RecipeCard } from './cards';import { DemoPointer, runDemo, type Demo } from './demo-pointer';import { useAutoplay } from './use-autoplay';import styles from './listing-cards.module.css';/* * Listing cards: six cards of different kinds on one board, a recipe, a flat to rent, a house for * sale, and three photo cards with their text on a shade. * * - The photos are native-resolution WebP assets (art.tsx), shared across the cards. A slide *   shows the whole photograph or a closer crop in the original scene coordinates. * - Each card's photos are a small carousel (carousel.tsx): drag or swipe them, use the arrows *   that show on hover and on focus, or the arrow keys; the dots follow, and shrink when far from *   the photo shown. * - A card lifts under the pointer: it moves by its transform, and its deeper shadow fades in by *   its opacity, so nothing is painted again as it moves. * - The heart saves the flat and the guest house can be reserved: each swaps between two glyphs *   or two labels drawn in place, by their visibility.
listing-cards.module.css
/* Listing cards (listing-cards.tsx): six cards on a light grey stage, three by two; at night, on   a near-black stage, the three white cards turn a dark grey a step above it.   Colours are the tokens below, light-dark(light, dark) where the two differ: the component takes   the color-scheme it inherits from the page (light unless the page says otherwise), or the one   its colorScheme prop sets (data-color-scheme). The photos are native-resolution WebP assets (art.tsx) and stay as   they are, and so does what lies on them, drawn against the pictures rather than the page: the   badges, arrows, dots and heart, and the photo cards' shades, words and buttons.   Every size is a multiple of --u, one unit of the cards' design, so the whole board scales with   its box as one drawing: the stage is a size container, and --u follows its width (up to 1px).   Narrow, the board turns to two columns, then one, and --u grows again so the text stays legible.   Memory. A phone keeps a page's pixels in tiles the width of the screen, and a tile painted   again gets a second buffer. So the board is one layout boundary of a set size (.scene), each   card's photos paint on a fixed layer of their own (their slides move inside it, frame by   frame, without becoming layers), and the cards lift by transform alone; the heart and the   button swap glyphs by visibility, while the photographic assets stay cached. */.stage {  /* The stage, and the cards on it. */  --surface: #f2f2f2;  --surface-2: #fff;  /* The words on the cards: titles and prices, bold figures and names, the flat's price, the
cards.tsx
'use client';import type { CSSProperties, Ref } from 'react';import { Photo } from './art';import { Carousel, type CarouselHandle } from './carousel';import {  AreaIcon,  BathIcon,  BedIcon,  CheckIcon,  ChefIcon,  ClockIcon,  ExpandIcon,  HeartIcon,  HouseIcon,  MapIcon,  PeopleIcon,  StarIcon,} from './icons';import styles from './listing-cards.module.css';/* * The six cards. Three sit on white (a dark grey at night) with their photos inset: a recipe, a * flat to rent, a house for sale. Three are photos from edge to edge, their text on a shade: a cottage, the house again,
carousel.tsx
'use client';import {  useEffect,  useImperativeHandle,  useRef,  useState,  type KeyboardEvent,  type PointerEvent,  type ReactNode,  type Ref,} from 'react';import { ChevronIcon } from './icons';import styles from './listing-cards.module.css';/* * A card's photos: slides that slide sideways. A finger or a mouse drags them and lets go to the * next photo or back; the arrows (on hover, or both while either has the keyboard focus) step * through them and wrap around, and the Left and Right keys, while the focus is on the photos' * buttons, step up to either end; the dots say where you are, and shrink when far from the * photo shown, as many apps do. * * Each slide is a box the size of the photos, stacked on the others and placed by its transform: * the one shown, its neighbours one width off to either side, the rest hidden. A drag moves the
art.tsx
// Copyright (c) 2026 Bruno Delorence. MIT License./** Native-resolution WebP photographs, shared by every carousel and documentation specimen. */const SCENES = {  dish: [215, 146],  overhead: [215, 146],  living: [223, 201],  bedroom: [223, 201],  farm: [300, 289],  kitchen: [216, 153],  cottage: [222, 287],  salon: [222, 287],  stoneHouse: [222, 288],  lounge: [222, 288],} as const;export type SceneName = keyof typeof SCENES;/** A photograph, whole or cropped in the card's original scene coordinates. */export function Photo({ scene, view, label }: { scene: SceneName; view?: string; label: string }) {  const [width, height] = SCENES[scene];  const [x, y, cropWidth, cropHeight] = view?.split(/\s+/).map(Number) ?? [0, 0, width, height];  return (    <div style={{ position: 'relative', width: '100%', height: '100%', overflow: 'hidden' }}>
icons.tsx
/* * The cards' small line icons, drawn on a 16 × 16 grid in the current colour. They are static * drawings: a state that changes an icon swaps whole glyphs around them instead of restyling one. */type IconProps = { className?: string };const LINE = {  fill: 'none',  stroke: 'currentColor',  strokeWidth: 1.25,  strokeLinecap: 'round',  strokeLinejoin: 'round',} as const;export function StarIcon({ className }: IconProps) {  return (    <svg className={className} viewBox="0 0 16 16" aria-hidden="true">      <path        d="M8 1.6l1.9 3.9 4.3.6-3.1 3 .7 4.3L8 11.4l-3.8 2 .7-4.3-3.1-3 4.3-.6z"        fill="#f5b51b"        stroke="#f5b51b"        strokeWidth="0.8"        strokeLinejoin="round"
demo-pointer.tsx
'use client';import type { CSSProperties, Ref } from 'react';/* * The demo's pointer, and the steps that move it. A demo is a script of awaited steps: wait, * glide the pointer onto a control and press it, or grab a photo and drag it aside, calling the * component's own handlers as a hand would. Stopping the demo (the reader takes over, or it * scrolls away) ends the step in progress at once: its promise rejects, which ends the script * right there, and the pointer fades out. * * Nothing the pointer does while the demo plays needs a layout, because one here in the same * frame as one in the cards would make the browser lay out the whole page (see the note at the * top of the stylesheet). So it moves by animations the compositor plays (a drag too: the dragged * value follows that animation's clock); the press scales a box that keeps a transform at rest, * since a box that gains or loses one is laid out again; and the arrow and the hand are HTML boxes * that swap by their visibility (a change of style inside an SVG lays the SVG out again). */export type Point = { x: number; y: number };export type Demo = {  /** Resolves after `ms`. */  wait: (ms: number) => Promise<void>;
use-autoplay.ts
'use client';import { useCallback, useEffect, useRef, useState } from 'react';/* * When a demo may play on its own: while part of it is on screen and the tab is visible, never * under reduced motion, and never again once the reader has used it: `take()` hands it to the * reader for good, until the component mounts again (WCAG 2.2.2). */export function useAutoplay<T extends HTMLElement>() {  const ref = useRef<T>(null);  const [visible, setVisible] = useState(false);  const [reduced, setReduced] = useState(true);  const [taken, setTaken] = useState(false);  useEffect(() => {    const element = ref.current;    if (!element) return;    let onScreen = false;    const update = () => setVisible(onScreen && !document.hidden);    const observer = new IntersectionObserver(      ([entry]) => {        onScreen = entry.isIntersecting;        update();