Cómo funciona
Un dibujo técnico de una lámpara de mesa en seis piezas, todas sólidos de revolución sobre un mismo eje vertical, trazado como dibujo axonométrico en tonos neutros con el eje como línea de centro de trazo y punto. El control de separación desliza las piezas a lo largo del eje y las vuelve a juntar; el centro de la columna no se mueve y la pantalla se eleva más que el resto para que asome el difusor que tapa. Las llamadas numeradas de la derecha nombran cada pieza y la siguen al moverse; al elegir una, esa pieza se dibuja en el color de acento y la fila bajo la figura da su nombre y su tamaño.
Úsalo para
- Teach technical drawing: show how an exploded view keeps every part on its axis and in assembly order.
- Explain how a product goes together in a manual, a course or a product page, part by part.
Busca otra opción cuando
- For an assembly that is not built along one axis, or for a model loaded from a CAD file, use a 3D viewer: this figure draws one built-in lamp.
Uso
import React, { useState } from 'react'
import { LampAssemblyScale } from './LampAssemblyScale.jsx'
export function AssemblyLesson() {
const [apart, setApart] = useState(0.6)
const [part, setPart] = useState(4)
return (
<LampAssemblyScale
value={apart}
onChange={(next) => setApart(next)}
part={part}
onPartChange={(next) => setPart(next)}
labels={{ title: 'Exploded view of a table lamp' }}
/>
)
}Propiedades
| Propiedad | Tipo | Por defecto | Qué hace |
|---|---|---|---|
value | number | — | Controlled separation from 0 (assembled) to 1 (fully apart), rounded to two decimals. |
defaultValue | number | 0.6 | Starting separation when uncontrolled, and what Reset returns to. |
onChange | (separation, { reason }) => void | — | Called with the new separation and a reason: 'press', 'drag', 'tap', 'key', 'cancel' or 'reset'. |
part | number | — | Controlled index of the chosen part, 0 (base) to 5 (shade). The chosen part is drawn in the accent colour. |
defaultPart | number | 4 | Part chosen at first when uncontrolled (4 is the diffuser, which hides under the shade until the parts separate). |
onPartChange | (index, { reason, name }) => void | — | Called when a callout is chosen, with the part's index, the reason ('press', 'key' or 'reset') and its name. |
step | number | 0.05 | Separation step for the arrow keys. Shift with an arrow, or Page Up and Page Down, move four steps. |
labels | object | — | Replaces any built-in text: title, caption, parts (six names, base first), partsLabel, separation, separationText ('{value}'), size ('{d}', '{h}'), partText ('{n}', '{count}') and reset. |
locale | string | 'en' | Language tag for the percentage and the sizes. |
className | string | — | Extra class on the card, for example to set its width (30rem by default, never wider than its container). |
Accesibilidad
- The callouts are a radio group labelled Parts with one tab stop: arrow keys choose the next or previous part (Up goes up the lamp), Home and End the base and the shade.
- Separation is a slider: arrows move 5%, Shift with an arrow or Page Up and Page Down 20%, Home and End go to assembled and fully apart. Its value text reads the separation.
- The chosen part's name and size are a polite live region. Reset is marked unavailable while nothing has changed.
- Dragging uses pointer capture. On touch, a press on the slider's track changes nothing until the finger moves sideways or lifts, so vertical scrolling is not caught; a cancelled gesture restores the value it started from.
- Colour is not the only cue: every part has a number and a name, and the chosen one is repeated in words under the figure.
Movimiento
Tras una tecla, un toque o Restablecer, las piezas, las líneas y las llamadas se deslizan durante --ds-duration-base. Al arrastrar el control lo siguen directamente. Con movimiento reducido todo cambia al instante.
Añádelo a tu proyecto
Los miembros Pro copian un prompt y su agente de programación instala el código, igual que con los gratuitos.
LampAssemblyScale.jsxlamp-assembly-scale.csstokens.cssREADME.md
Los dos archivos se instalan juntos. La hoja de estilos lee las variables de tokens.css y lleva valores de reserva, así que también funciona sola.







