Skip to content
Tutorials

Build an isometric bar chart from data attributes

Turn a plain list of numbers into columns of blocks.

Design tokens keep the whole team in step. We name colours by their role, such as face-top, face-left and face-right, rather than by hue. When we switched the site to a violet accent for a campaign, only the token values changed. Every illustration, button and chart followed without anyone opening a single component.

What you need

A code editor, a modern browser and about twenty minutes. No libraries or build step.

Handling motion

Stacking order is the part that trips people up. In a flat layout, later elements paint on top. In a tilted scene, a block that is further back must paint first, even if it appears later in the markup. Either sort your markup by depth or give each block a z-index derived from its row and column.

  1. Set the unit

    Define --unit: 2rem on the scene so every size derives from one value.

  2. Build the columns

    Read each value from a data-value attribute and set the block height with calc().

  3. Label the bars

    Keep labels flat and upright below the chart so they stay readable.

  4. Describe the chart

    Add a visually hidden table with the same numbers for screen readers.

The code

Performance is rarely a problem for one hero cube, but a scene with fifty transformed blocks is a different story. Each block may become its own compositing layer, and every layer costs memory. Open the Layers panel before you ship and count them. If the number surprises you, flatten the static parts into a single SVG.

Motion adds a lot to isometric scenes, and it is also the fastest way to make someone feel unwell. Wrap every animation in a prefers-reduced-motion query. For readers who ask for less motion we keep the scene still and use a small colour change on hover instead, which keeps the interface responsive without any movement.

Custom properties make isometric CSS far easier to maintain. Instead of hard-coding sizes, we define a single unit on the scene wrapper and multiply it everywhere else. Changing the unit rescales the whole illustration, keeps the proportions intact and means a phone layout needs one media query instead of twenty.

cube.cssCSS
.scene {	--unit: 2rem;	transform: rotateX(60deg) rotateZ(-45deg);	transform-style: preserve-3d;} .cube {	width: calc(var(--unit) * 3);	aspect-ratio: 1;	background: var(--face-top);}

Colours used

Keeping everything on the grid

Accessibility for decorative art is mostly about getting out of the way. If an illustration adds no information, hide it from assistive technology with aria-hidden on its wrapper. If it does carry meaning, such as a chart, give it a text alternative that says what the picture shows, not how it was built.

What you built

  • A cube with three shaded faces
  • A floor grid from gradients
  • A hover state that lifts the block
Share

Written by

Inês Duarte

Inês is Cubefold's colour and type lead. She believes every isometric scene needs exactly one warm accent, and not two.

All 16 posts by Inês Duarte

9 comments

  1. Alex Moreau

    Our designer drew the scene in Figma and I rebuilt it with your approach in an afternoon.

    Reply to Alex Moreau
    1. Pia Jensen

      Same here. Adding will-change on the wrapper fixed it for me.

      Reply to Pia Jensen
      1. Quinn Adler

        The templates are in the downloads section of the reference post.

        Reply to Quinn Adler
        1. Hana Sato

          Glad it helped. The values are in the colour ratios reference.

          Reply to Hana Sato
  2. Lena Vogel

    Works nicely in Firefox. Safari needed the prefixed transform-style for us.

    Reply to Lena Vogel
  3. Tess Walsh

    Tiny typo in the second code block: the unit is missing on the translate value.

    Reply to Tess Walsh
  4. Soren Dahl

    Love the palette. Could you share the exact lightness values?

    Reply to Soren Dahl
  5. Ivo Petrov

    The paper cube exercise sounds fun. Are the templates available somewhere?

    Reply to Ivo Petrov
  6. Dana Ortiz

    This finally made the order of rotations click for me. I had them the wrong way round for weeks.

    Reply to Dana Ortiz

Leave a comment

Your email address won’t be published. Required fields are marked.