How it works
A textbook figure of the law of reflection. A lamp in the accent colour sends a faint fan of rays across a room; the rays that reach the flat mirror bounce off it (dashed). The ray from the lamp to the mirror's centre is drawn strong: at the mirror the figure draws the normal (dashed) and two arcs, θᵢ between the incoming ray and the normal and θᵣ between the normal and the reflected ray, and the reflected ray runs on to the wall it reaches. Three zones line the right part of the ceiling; the target is outlined in the accent and turns green when the ray lands in it. Drag the mirror's centre to move it, drag an end to turn it, press empty space to place it there, or use the arrow keys and the tilt slider. A row under the figure says where the ray lands and reads θᵢ = θᵣ.
Use it for
- Teach the law of reflection: learners see that whatever they do to the mirror, the two angles from the normal stay equal.
- Give a small aiming task, such as sending light to a sensor or a window, where the answer comes from reasoning about angles rather than trial and error.
Look elsewhere when
- For curved mirrors, refraction or several bounces: this figure has one flat mirror and follows one reflection.
Usage
import React, { useState } from 'react'
import { ShowcaseBouncePanel } from './ShowcaseBouncePanel.jsx'
export function ReflectionLesson() {
const [target, setTarget] = useState('B')
return (
<ShowcaseBouncePanel
target={target}
onTargetChange={setTarget}
defaultMirror={{ x: 46, y: 85, tilt: 0 }}
onMirrorChange={(mirror, { hit }) => hit && console.log('On target', mirror)}
labels={{ title: 'Bounce the light into the target' }}
/>
)
}Props
| Prop | Type | Default | What it does |
|---|---|---|---|
mirror | { x: number, y: number, tilt: number } | — | Controlled mirror: centre x and y in percent of the room (y down) and tilt in whole degrees from −90 to 90, positive when the right end is higher. The mirror is kept inside the room and clear of the lamp. |
defaultMirror | { x: number, y: number, tilt: number } | { x: 46, y: 85, tilt: 0 } | Starting mirror when uncontrolled, and what Reset returns to in both modes. |
onMirrorChange | (mirror, details) => void | — | Called with the new mirror and { reason ('press', 'drag', 'tap', 'key', 'cancel' or 'reset'), incidence (degrees), zone ('A', 'B', 'C' or null), hit (true when the zone is the target) }. |
target | 'A' | 'B' | 'C' | — | Controlled target zone on the ceiling. |
defaultTarget | 'A' | 'B' | 'C' | 'B' | Starting target zone when uncontrolled. |
onTargetChange | (zone) => void | — | Called when a target button is pressed. Choosing a target leaves the mirror where it is. |
labels | object | — | Replaces any built-in text: title, formula, lamp, incidence, reflection, angles ('{angle}'), mirror, movable, mirrorText ('{x}', '{y}'), help, tilt, tiltText ('{tilt}', '{angle}'), target, zoneNames (three), hit ('{zone}'), lands ('{zone}'), miss and reset. |
locale | string | 'en' | Language tag for the numbers. |
className | string | — | Extra class on the card, for example to set its width (30rem by default, never wider than its container). |
Accessibility
- The mirror's centre is a focusable movable button: the arrow keys move it, Shift with an arrow moves it four times as far. Its name gives the position.
- The tilt is a slider: arrows turn the mirror by one degree, Shift with an arrow or Page Up and Page Down by ten, Home and End go to −90° and +90°. Its value text reads the tilt and the angle of incidence.
- Where the ray lands is a polite live region, read when it changes. The target buttons are toggle buttons; Reset is a button marked unavailable while nothing has changed.
- Dragging uses pointer capture. A finger on the mirror's centre or an end drags at once; on empty space a finger changes nothing until it moves or lifts, so a vertical scroll is not caught, and a cancelled gesture restores the mirror it started from.
- Colour is not the only key: a hit also shows a check mark and the words of the status.
Motion
After a key, a tap or Reset, the mirror and its rays glide to the new place for --ds-duration-base, turning the short way. While dragging they follow the pointer directly. With reduced motion every change lands at once.
Add it to your project
Pro members copy a prompt and their coding agent installs the source, the same way as the free components.
ShowcaseBouncePanel.jsxshowcase-bounce-panel.csstokens.cssREADME.md
Both files install together. The stylesheet reads the design tokens in tokens.css and carries fallbacks, so it also works alone.







