Bruno DelorenceBruno
Appearance
Appearance

Choose your reading theme.

Contact

Clothing rail

A shop page with its garments on a clothes rail: the front one turns to face you, the rest hang side on.

clothing-rail/clothing-rail.tsx
Live · interactive
Shop

On the railDelorence / North Quay

Orchard

Swipe to browse. Tap to explore.

04 / 10
Explore Delorence

Sewn slowly, worn daily. Cut & finished in small batches.

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 small collection of clothes, a handful to a dozen pieces, shown one at a time on a phone.
  • A shop or a drop page where each garment deserves the whole screen, and the turn of the fabric is part of the sale.
  • Browsing that should feel like walking along a rail: swipe or press an arrow, and the next one turns to face you.
  • Garments you can show from the front, the side and the back, as transparent renders aligned to the same hook.

When not to use

  • A catalogue to search, filter or compare. Use a product grid with filters.
  • Anything to buy on the spot. The detail has a link to the shop, not sizes, a price or a basket; use a product page.
  • Products without three matching views. A flat photograph on a background won’t turn; use an image carousel.
  • More than a dozen or so items. Each move is one step along the rail, so the far end is a long way off.
  • A page that has to stay still. The demo and the red strip move on their own until the first input.

Moving along the rail

  • Swipe sideways across the rail, about 26 units, and it moves one garment; a vertical drag still scrolls the page.
  • Previous and Next move one at a time, and stop at the ends: the rail doesn’t wrap.
  • Left and Right arrow keys, Home and End, anywhere on the page, move one, or to the first or the last.
  • Each move plays in four steps: the front garment turns away, the rail slides, a beat, and the next one turns to face you. A new press picks up from wherever it is.
  • onChange is called with the index the rail sets off for.

The detail

A tap on the front garment, or Enter on it, opens its detail over the whole screen, once it has stopped turning. The garment grows out of its place on the rail, and Front and Back turn it half round. View in the shop goes to the garment’s href, or shopHref when it has none. Close or Escape fades it out, and the garment on the rail turns back round. onOpen is called with the garment and its index.

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

The page is a shop window: a name, a cut and a colour are all a garment says.

  • Name: a word or two, Orchard, Low Tide. It is set once under the rail and large in the detail.
  • Cut and colour: description, or the label of kind (Hoodie, Crewneck, Zip jacket), then colorName, as Crewneck · Pale pink.
  • The shop: brand is the wordmark, the print on each garment, the caption, the Explore link and the detail’s foot; place follows it in the caption.
  • railLabel, On the rail, is the caption’s first words and the rail’s name for screen readers.
  • Three images per garment, front, side and back: transparent, the same size and aligned to the same hook and hem, or the turn jumps.
  • The menu button is drawn only: it opens nothing. Wire it to your own menu, or leave it out of a real page.

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

Into components/clothing-rail of any React project, with no setup:

Terminal
npx shadcn@latest add https://brunodelorence.com/r/clothing-rail.json

Either way it needs React 19.2 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

shop.tsx
import { ClothingRail } from './clothing-rail';import { ITEMS } from './data';const collection = ITEMS.filter((item) =>  ['Fern', 'Nightshift', 'Rosehip'].includes(item.name),);export function Shop() {  return (    <ClothingRail      items={collection}      defaultIndex={1}      brand="Delorence"      place="North Quay"      shopHref="/shop"      autoplay={false}      onOpen={(item) => console.log('Viewing', item.name)}    />  );}

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 small shop’s page, phone-shaped. Its garments hang on a chrome rail: the one in the middle faces you, its neighbours hang side on. Swipe or press the arrows and the front one turns away, the rail carries them all along, and the next turns round to face you with a swing on its hanger. Tap it and it grows into a detail where Front and Back turn it round.

  • The page is a column 360 units wide and 640 tall, and every size is in units of its width (a container query), so it is the same page on a 320 px phone and at 960; wider than 520 px, it stands in the middle at 400 px.
  • Each garment uses transparent 3D product renders with sculpted fleece, hanging folds, ribbed cuffs and a wooden hanger. The Delorence logo and a text wordmark are applied over the fabric; both can be customized with brand and logoSrc.
  • A garment is a box of three images, front, side and back: the front and back stand 22 units off its axis, the side 60. Turning the box a quarter about the hook brings the side round, so the sleeves sweep away while the profile comes in. Each face fades only near edge on, so it never shows as a sliver.
  • Moving along the rail plays in four steps, each picking up from where the last was if a new press comes in: the front garment turns side on (170 ms, easing in), the rail slides (260 ms, 110 ms more per extra garment), a 140 ms beat, and the new one turns to face you (320 ms, easing out).
  • The script writes only transforms, one frame at a time and only while something moves. Two springs swing the hangers: one pulls every garment against the rail’s speed, so they trail and swing back when it stops; the other kicks the front one as it turns.
  • The detail’s garment grows out of the rail’s: one 460 ms transform from the rail’s place and size to its own, while the sheet, which blurs the page behind it, fades in and the lines rise in turn. Front and Back turn the same box half round in 300 ms, and the underline slides with it.
  • The red strip at the foot is one compositor animation that scrolls two copies of its lines, paused while off screen.
  • Every colour is a light-dark() token on the root. At night the paper goes near-black, the chrome darkens and the garments keep their own colours. It follows the page’s color-scheme, or the colorScheme prop.
PropTypeDefaultDescription
itemsRailItem[]ten garmentsThe garments, in order: name, kind (hoodie, crewneck or zip), color, colorName and images (transparent front, side and back URLs). Optionally description, printColor (the logo and wordmark ink) and href. Align the three views to the same hook and hem.
defaultIndexnumber3The garment in front to begin with.
onChange(index: number) => void—Called with the index of the garment the rail moves to.
onOpen(item: RailItem, index: number) => void—Called when a garment’s detail opens.
brandstring'Delorence'The shop’s name: the header, the garment prints, the caption, the button and the detail’s footer.
logoSrcstringDelorence logoA transparent logo URL, used as an ink mask in the header and on the garments.
placestring'North Quay'Where the shop is, after its name in the caption.
railLabelstring'On the rail'The caption’s first words, and the rail’s name for screen readers.
marqueestring[]two linesThe lines that scroll along the red strip, between stars.
shopHrefstring—Where Shop, Explore and a garment without its own href lead.
autoplaybooleantrueWhile on screen and untouched, a demo browses, opens a garment, turns it round and closes it.
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.

Keyboard and focus

  • In the tab order: Menu, Shop, the front garment, Previous, Next and Explore. The garments’ images and the rail’s drawing are hidden from assistive technology.
  • The front garment is a button named with its name, cut, colour and place: Orchard, Crewneck · Pale pink. 4 of 10. Open the detail.
  • Left and Right arrow keys, Home and End move along the rail from anywhere on the page. At the ends Previous and Next are marked aria-disabled and stay focusable, so focus isn’t lost there.
  • Focus shows as a 2 px blue ring, 3.5:1 on the light paper and 4.8:1 on the dark (WCAG 2.4.7 and 1.4.11).

The detail

  • A modal dialog named by the garment and described by its cut and colour. Opened by the reader, focus moves to Close; Tab and Shift-Tab stay inside it, Escape closes it, and the page behind is inert.
  • When it closes with focus inside, focus goes back to the front garment.
  • Front and Back are tabs over one tabpanel: Left and Right arrows switch and select them, and the panel reads Orchard, back.

Announcements and contrast

Each move the reader makes is read out in a polite live region, as Fern, 5 of 10 (WCAG 4.1.3, Status messages). Every word on the page, the hint, the counts, the tabs and the strip included, holds at least 4.5:1 against the paper, the detail’s sheet or the red, in both schemes (WCAG 1.4.3).

Pointer and motion

  • Swiping is never the only way: Previous and Next do the same with a single press (WCAG 2.5.7, Dragging movements).
  • The controls are 34 to 46 units tall on a 360-unit page, and none takes presses over less than 24 × 24 px however small the page is drawn (WCAG 2.5.8).
  • With reduced motion on, garments move and turn at once, the strip stands still and the demo never plays. Otherwise the reader’s first press, key or focus inside it stops the demo and the strip for good (WCAG 2.2.2, Pause, Stop, Hide). Turn the demo off in a real app with autoplay={false}.

In this build

  • The rail is a region with the carousel role description. Only the front garment is in the tab order: a button named with its name, cut, colour and place (“Nightshift, Unisex hoodie · Charcoal. 6 of 10. Open the detail”). The product images and prints are decorative and aria-hidden.
  • Left and Right arrows (and Home and End) move along the rail, as do the Previous and Next buttons, which are disabled at the ends. Each move the reader makes is announced in a polite live region.
  • The detail is a modal dialog named by the garment: focus moves to Close, Tab stays inside it, Escape closes it, the page behind is inert, and focus returns to the garment. Front and Back are tabs with arrow-key movement, over a tabpanel.
  • Under reduced motion the garments move and turn at once, the strip stands still 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.

clothing-rail.tsx
// Copyright (c) 2026 Bruno Delorence. MIT License.'use client';import {  useCallback,  useEffect,  useEffectEvent,  useId,  useLayoutEffect,  useRef,  useState,  type KeyboardEvent as ReactKeyboardEvent,  type PointerEvent as ReactPointerEvent,} from 'react';import { ITEMS, KIND_LABEL, type RailItem } from './data';import { Garment } from './garments';import { createMotion, type Motion } from './rail-motion';import { useAutoplay } from './use-autoplay';import styles from './clothing-rail.module.css';export type { RailItem } from './data';/*
clothing-rail.module.css
/* Clothing rail (clothing-rail.tsx): a shop's page in a phone-shaped column, 360 units wide and   640 tall. Every size is in --u, a 360th of the column's width (a container query), so the page   is the same at any width; the column fills a narrow stage, and on one 520 px or wider stands in   its middle at 400 px, in a phone's bezel unless the device prop is 'none' ('phone' draws the   bezel at any width).   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 garments keep their own colours at night;   the paper, the ink and the chrome dim around them.   Memory. The column is one layout boundary. The garments move by transforms that the script   writes one frame at a time, and only while something moves; each turns as a small 3D box of   three product images. The marquee is one compositor animation, paused while off screen. */.root {  /* The page and the stage around the column. */  --paper: #f3f4ed;  --stage: #e6e7df;  /* The words: ink, the softer grey of the hint, the faint one of the caption and counts. Every     grey holds 4.5:1 on the paper and on the detail's sheet, in both schemes; so do the words on     the red strip and the shop link. */  --ink: #0b0c08;  --soft: #2a2b27;
garments.tsx
// Copyright (c) 2026 Bruno Delorence. MIT License.import type { CSSProperties, Ref } from 'react';import type { RailItem } from './data';import styles from './clothing-rail.module.css';/** Three transparent product renders share the same hook and rotate with the hanger. */export function Garment({  item,  brand,  logoSrc,  turnRef,  className = '',}: {  item: RailItem;  brand: string;  logoSrc: string;  turnRef?: Ref<HTMLDivElement>;  className?: string;}) {  return (    <div      ref={turnRef}      className={`${styles.turn} ${className}`}
rail-motion.ts
/* * The rail's motion: where each garment hangs, which way it faces, and how it swings, written * straight into transforms one frame at a time, and only while something moves. * * Moving to another garment plays in four steps, each picking up from wherever the last one was * when a new press comes in: *   away    the garment in front turns side on (170 ms, easing in); *   slide   the rail carries every garment along (260 ms for one step, 110 ms more per extra one); *   hold    a beat, all of them side on (140 ms); *   toward  the new one turns to face the reader (320 ms, easing out), with a kick on its hanger. * * - Positions: the front garment hangs in the middle, its neighbours under the rail's ends 142 *   units either side (the column is 360 units wide), and the rest 64 units apart beyond them. * - Garments off to the sides all face the same way, as on a real rail: turned a quarter, so the *   one that comes in turns the same way the one that leaves turned. * - The side face fades in from a third of the way round, so edge on it is never a bar. * - Swing: a spring per rail pulls every hanger towards an angle against the rail's speed, so the *   clothes trail behind as they move and swing back when it stops; the front one has a spring of *   its own, kicked as it turns. */export type MotionNodes = {  slots: (HTMLElement | null)[];  swings: (HTMLElement | null)[];
data.ts
// Copyright (c) 2026 Bruno Delorence. MIT License./** Transparent 3D product renders, aligned to the same hanger hook. */export type GarmentKind = 'hoodie' | 'crewneck' | 'zip';export type RailItem = {  name: string;  kind: GarmentKind;  /** Fabric colour, for the catalogue metadata. */  color: string;  colorName: string;  description?: string;  /** Transparent front, side and back images with matching framing. */  images: { front: string; side: string; back: string };  /** Ink used for the logo and the brand wordmark. */  printColor?: string;  href?: string;};export const KIND_LABEL: Record<GarmentKind, string> = {  hoodie: 'Hoodie',  crewneck: 'Crewneck',  zip: 'Zip jacket',};
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()`, on their first * press, key or focus, stops it for good (until the component mounts again). */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();