Skip to content
CSS Transforms

Create isometric shadows with pseudo-elements

Soft floor shadows that follow the block without extra markup.

Colour contrast still applies to illustrations that carry meaning. A bar chart drawn as blocks needs enough contrast between the bars and the floor, and labels on the faces need the same contrast as body text. Decorative scenes have more freedom, but we still avoid pale blocks on a pale background.

What you need

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

Shadows that sell the weight

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.

  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

Hover effects on isometric blocks work best when they follow the same rules as the static scene. Lift a block along its vertical axis, deepen its shadow on the floor, and leave the other blocks alone. Moving a block sideways, or changing its angle, breaks the projection and makes the scene feel unstable.

SVG is often the better choice for complex scenes. CSS cubes are fun to build and easy to animate, but a city block made of hundreds of divs is hard to change and heavy to render. We draw the static parts in SVG, keep the interactive blocks in CSS, and layer the two together.

Game artists have a name for the pixel-art version of isometric: two-to-one. Lines climb one pixel for every two across, which gives clean, stair-stepped edges instead of jagged ones. The angle is about 26.6 degrees rather than 30, and almost nobody notices, which is a nice reminder that looking right beats being exact.

functions.phpPHP
 

Colours used

Lessons from the workshop

Readers often ask whether isometric art is still a trend or already a cliché. Our answer is that the style is a tool, like a chart type. It is excellent for explaining structure and relationships, and it is a poor choice for emotion or narrative. Used for the right job, it never really goes out of date.

What you built

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

Written by

Theo Okafor

Theo writes about 3D transforms and rendering performance. He keeps a spreadsheet of every browser bug he has hit with preserve-3d.

All 18 posts by Theo Okafor

9 comments

  1. Hana Sato

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

    Reply to Hana Sato
  2. Tess Walsh

    The tip about naming faces instead of colours saved our design system a lot of pain.

    Reply to Tess Walsh
    1. Eli Novak

      Agreed, this is the part most tutorials skip.

      Reply to Eli Novak
  3. Lena Vogel

    Bookmarked. The table alone is worth it.

    Reply to Lena Vogel
    1. Theo OkaforAuthor

      Yes, container queries work well; we will cover them soon.

      Reply to Theo Okafor
  4. Quinn Adler

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

    Reply to Quinn Adler
  5. Mateo Rossi

    How would you handle text that needs to wrap on one of the faces?

    Reply to Mateo Rossi
  6. Gus Lindgren

    I teach an intro CSS class and I am going to use this as the final project.

    Reply to Gus Lindgren
    1. Pia Jensen

      Fixed now, thanks for spotting it.

      Reply to Pia Jensen

Leave a comment

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