Skip to content
Typography

Draw isometric text with transforms

Set a word on the side of a block and keep it selectable.

Shadows on the floor sell the idea that a block has weight. A blurred ellipse, skewed to match the grid and placed slightly offset from the light, is usually enough. Real shadows would change with the height of the block, and adding that detail makes towers and stairs look much more convincing.

What you need

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

Putting it together

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. Draw the floor

    Create a wrapper with transform: rotateX(60deg) rotateZ(-45deg). This tilts the whole scene into isometric space.

  2. Place a cube

    Add a square child and give it three faces with pseudo-elements. Each face gets one of the three shading colours.

  3. Lift it on hover

    Translate the cube along its Z axis on hover and deepen the floor shadow at the same time.

The code

We prototype every scene on paper first. A sheet of triangle-grid paper, a soft pencil and ten minutes are enough to find out whether a composition works. It is far cheaper to erase a pencil line than to rewrite a dozen nested transforms, and the sketch doubles as documentation when someone asks why a block sits where it does.

sort-tiles.jsJS
const sorted = tiles.toSorted((a, b) => (a.x + a.y) - (b.x + b.y));for (const tile of sorted) {	scene.append(tile.element);}

<div class="scene" aria-hidden="true">	<div class="cube"></div></div>

Colours used

Start with the floor

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.

What you built

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

Written by

Mara Lindqvist

Mara draws isometric city blocks in CSS and edits the Isometric Basics column. She once rebuilt a subway map using nothing but borders.

All 13 posts by Mara Lindqvist

12 comments

  1. Nina Ahlberg

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

    Reply to Nina Ahlberg
  2. Chen Wei

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

    Reply to Chen Wei
    1. Omar Haddad

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

      Reply to Omar Haddad
      1. June Park

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

        Reply to June Park
  3. Bea Kowalski

    Any plans for a video version of this one?

    Reply to Bea Kowalski
  4. Alex Moreau

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

    Reply to Alex Moreau
  5. Soren Dahl

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

    Reply to Soren Dahl
  6. Farah Aziz

    Has anyone tried this with container queries? Feels like a good fit.

    Reply to Farah Aziz
  7. Eli Novak

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

    Reply to Eli Novak
    1. Mara LindqvistAuthor

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

      Reply to Mara Lindqvist
      1. Quinn Adler

        Fixed now, thanks for spotting it.

        Reply to Quinn Adler
  8. Mateo Rossi

    Is there a way to do the shadow without a pseudo-element? Our CMS strips empty spans.

    Reply to Mateo Rossi

Leave a comment

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