Two logical properties and 110 physical ones, so I set dir=rtl on all 106 of our pages
Nakodo is an English-only product with 106 public pages. Nobody working on it has ever written margin-inline-start, there is no locale switcher, and <html lang="en"> has no dir attribute on it.
So the question is not "does our RTL support work", it is "what would it cost if we ever needed it", and that is a question you can answer in an afternoon with one line in a console. Open any page on nakodo.app and run this:
document.documentElement.dir = "rtl";
The page flips. Most of it flips correctly. The parts that do not are the point of this post, and they are a much shorter list than I expected.
What the stylesheet actually contains
The site ships 154,842 bytes of CSS in two files. Counting declarations whose name contains left or right:
- 18
padding-left - 18
left - 14
right - 14
padding-right - 12
margin-left - 5
margin-right - 5
border-top-left-radius - 5
border-top-right-radius - 4
border-bottom-left-radius - 4
border-bottom-right-radius - 3
border-left-style/ 3border-left-width - 2
border-right-style/ 2border-right-width - 1
border-left-color
110 declarations that mean a physical side of the screen. Against that, the one-sided logical properties appear exactly twice: one padding-inline-start and one margin-inline-end. There are zero direction declarations, zero [dir= selectors and the string rtl does not appear anywhere in the CSS.
That sounds worse than it is, because a lot of the flipping is already done for us. Tailwind 4 emits logical properties for the symmetric utilities, and physical ones for the sided utilities:
.mx-auto { margin-inline: auto }
.px-5 { padding-inline: calc(var(--spacing) * 5) }
.inset-x-0 { inset-inline: 0 }
.ml-auto { margin-left: auto }
.pl-7 { padding-left: calc(var(--spacing) * 7) }
.pr-4 { padding-right: calc(var(--spacing) * 4) }
.right-2 { right: calc(var(--spacing) * 2) }
.text-right { text-align: right }
margin-inline appears 10 times in the shipped file, padding-inline 20 times, inset-inline 7. Every one of those is a place where somebody wrote the symmetric utility out of habit and got direction independence without asking for it. The 110 physical declarations are the places where the design genuinely wanted one side.
Measuring the flip instead of eyeballing it
Screenshots of an RTL page tell you something is wrong but not how much. A box that mirrors correctly ends up at viewportWidth - originalRight, so you can record every rectangle, flip the document, record them again, and compare each one against its own mirror position.
const all = [...document.querySelectorAll("body *")];
const base = all.map((e) => e.getBoundingClientRect());
document.documentElement.setAttribute("dir", "rtl");
const after = all.map((e) => e.getBoundingClientRect());
document.documentElement.removeAttribute("dir");
let off = 0;
for (let i = 0; i < all.length; i++) {
const mirror = innerWidth - base[i].right;
if (Math.abs(after[i].left - mirror) > 1.5) off++;
}
Nothing is reloaded between the two reads, so the element list is identical and the index is a stable identity. The whole run is 106 page loads and one evaluate each.
The result over 84,233 elements:
| count | |
|---|---|
| Elements in body across 106 pages | 84,233 |
| Elements whose left edge moves at all | 36,340 |
| Elements that land exactly on their mirror | 33,357 |
| SVG nodes that do not mirror | 43,921 |
| Static inline elements reflowed by bidi | 2,570 |
| Block-level boxes off their mirror | 2,126 |
| Pages that gain horizontal overflow | 0 |
The last row is the one I would have bet against. document.scrollWidth is identical before and after on all 106 pages. Nothing wraps differently, nothing escapes the viewport that was not already escaping it, and the 180 decorative elements that hang outside the viewport on the home page hang outside it by the same amount in both directions.
The 43,921 SVG nodes are not a bug either. The drawings on this site are inline SVG, and SVG has its own coordinate system that dir does not touch, so the artwork stays as drawn. That is what you want for a bird and not what you want for an arrow, and we have no arrows.
The 2,126 real offenders work out at a median of 19 a page, from a minimum of 9 to a maximum of 50 on the home page. 93.3 per cent of them come from ten class strings, and there are only 32 distinct ones in total. Repeated chrome is most of the damage.
The ten strings
- 1029
li.pl-1 - 106
div.ml-auto.flex.items-center.gap-1 - 106
a.group/button.inline-flex.shrink-0(inside it) - 106
div.absolute.-bottom-12.-left-72 - 106
div.absolute.right-20.bottom-0.left-[calc(max(0px,(100%-72rem)/2)+3rem)] - 106
span.ml-[0.06em].inline-block.size-[0.24em].rounded-full...
li.pl-1 is every bullet in every content page, from one line in the block renderer:
<li key={i} className="pl-1">
A seven-pixel indent that stays on the left when the text moves to the right. One character fixes it (ps-1), and it is 1,029 of the 2,126.
The header is the only thing a visitor would actually notice. The nav is a flex row with the buttons pushed over by ml-auto:
<div className="ml-auto flex items-center gap-1 sm:gap-2">
margin-left: auto eats the free space on the left, which is exactly what you want in a left-to-right row and exactly wrong in a right-to-left one. The button group sits at x=1179 in LTR on a 1500px viewport. Its mirror position would be 206. In RTL it lands at 580, floating in the middle of the bar with 580 pixels of nothing to its left. That is one ms-auto away from being correct, and it is the single change I would make if this were ever more than an audit.
The two absolute divs are the drawn landscape in the footer, positioned with physical left and right because they are a picture, not content. They keep their composition, which for a landscape is defensible and for a layout is not.
My favourite is the last one. Our wordmark ends in a drawn dot, and the dot is a span with a ml-[0.06em] nudge:
<span className="ml-[0.06em] inline-block size-[0.24em] rounded-full border border-mark-outline bg-mark" />
In RTL the logo reads as a dot followed by the name. The brand mark flips itself on a page that has no translation on it.
The part that is not our CSS
Set dir="rtl" and the hero headline reads Find partners .who say yes . The full stop jumps to the left of the line, and so does the one in "No tracking cookies." The URL field's https:// prefix renders as //:https. None of that is a CSS problem. It is the Unicode bidirectional algorithm doing its job: a run of Latin text in an RTL paragraph keeps its own direction, but the neutral characters at the edges, punctuation and slashes, take the direction of the paragraph.
A product that genuinely shipped Arabic would mark those runs with dir="ltr" or <bdi> on the element that holds them. We have zero [dir] elements and zero bdi or bdo elements on the whole site, which is the correct number for a site with one language and the wrong number for a site with two.
What this is worth knowing
The reason to run this audit on a monolingual site is that the answer tells you what kind of debt you are carrying. There are two shapes it could have had. The bad shape is structural: pages that overflow, grids that collapse, absolute positioning that puts content off screen. The cheap shape is cosmetic: indents and gaps on the wrong side, one flex row misaligned.
We got the cheap shape, and I think the reason is that almost nothing in this codebase positions anything by hand. The layout is flow, flex and grid with symmetric padding. 2,992 elements across the 106 pages have asymmetric physical padding and 350 have asymmetric physical margins, and 2,518 compute text-align: left against 54 that compute text-align: right. Because those all arrive from component classes rather than one-off fixes, the damage repeats instead of spreading: 32 distinct class strings, ten of which are 93 per cent of it.
Things I am taking away from this:
- Run the one-liner on your own site. It costs nothing and it is the only cheap way to find out whether your direction debt is structural or cosmetic.
- Compare against the mirror position, not against "did it move". 36,340 elements moved. 33,357 of them moved correctly. Counting movement would have told me the site was broken everywhere.
- Separate the SVG. 43,921 of the 46,000-odd non-mirroring nodes are drawing internals. Measuring them as failures buries the 2,126 that matter under them.
- Symmetric utilities are free direction independence. Every
px-andmx-in the codebase is already logical. The debt is concentrated in the handful of places where somebody needed one side.
See it for yourself: open nakodo.app , run document.documentElement.dir = "rtl" and watch the header buttons land in the middle of the bar. Then try a content page such as how to find influencers and look at the bullet indents, or the pricing page , which has the most physical padding of any page on the site.
Comments
No comments yet. Start the discussion.