Use RTL layout and logical properties
Language and direction are separate attributes
Right-to-left (RTL) layout is necessary for languages whose main writing direction is right to left. The Unicode bidirectional algorithm arranges text runs, but it does not automatically make every layout appropriate for an RTL audience. HTML lang identifies the content language for tools such as speech synthesis; dir sets base direction. Set the actual language and direction on the root document when the whole application changes, and use scoped attributes for embedded content. In this chapter English prose remains left to right; an RTL test fixture uses isolated synthetic Hebrew characters encoded as Unicode escapes. Mirroring a layout is not a translation.
import React from 'react';export default function DirectionPanel({direction = 'ltr', children}) { const dir = direction === 'rtl' ? 'rtl' : 'ltr'; return <section dir={dir} className="desk-panel"> <div className="desk-row"><span className="desk-badge">ID-17</span> <div className="desk-text">{children}</div></div> </section>;}Render the same component with ltr and rtl to compare alignment. The first item moves to the inline-start edge as direction changes, but the DOM order remains the same. In the actual application assign dir from a supported locale configuration rather than guessing it from the first letter of a page. Do not label English text as another language solely to test layout. A direction prop is a test control here; the document language is still English.
Use logical CSS rather than duplicating left and right rules
.desk-panel { padding-inline: 1rem; text-align: start; }.desk-row { display: flex; align-items: flex-start; gap: .75rem; }.desk-badge { border-inline-start: .25rem solid #335c81; padding-inline-start: .5rem; flex: none; }.desk-text { min-inline-size: 0; overflow-wrap: anywhere; }.desk-panel { max-inline-size: 36rem; }.desk-panel button { margin-block-start: .5rem; }In horizontal LTR writing, border-inline-start is the left border; in RTL it is the right border. Padding follows it. Block spacing remains separate from inline spacing. Flex items can shrink when min-inline-size is zero, and overflow-wrap allows long identifiers to wrap. CSS logical properties follow writing mode as well as direction, so inline does not always mean horizontal. Import this CSS from the app entry or a bundler-supported stylesheet import. Test at a narrow viewport and with long messages. Mirror directional navigation arrows only when their meaning changes; do not mirror logos, playback symbols or text as a blanket rule.
Isolate mixed-direction fragments
import React from 'react';export const sampleName = '\u05D0\u05D1\u05D2'; // synthetic Hebrew letters, not a translationexport default function MixedLabel({name = sampleName, id = 'ID-17'}) { return <p>Ticket <bdi dir="ltr">{id}</bdi> — visitor <bdi dir="auto">{name}</bdi>.</p>;}The identifier retains its LTR base direction, and the unknown name is isolated from adjacent punctuation and text. bdi establishes directional isolation; dir=auto chooses base direction from the content (normally the first strong directional character). Numbers alone need not reveal the intended language. Use markup rather than manually reversing strings or scattering invisible direction overrides in stored text. The synthetic label is not a localized lesson or a meaningful person name. If actual localized text has known language metadata, specify lang appropriately. Keep IDs and code samples machine-readable in the original order. Practice: replace the sample with a long English name, then a short synthetic RTL string; verify both in a narrow layout.