Right to left

The components follow the direction of the page: set it once, on <html>, and everything flips. Only an app that mixes directions — a right-to-left box inside a left-to-right page, or the reverse — needs one more thing: CDK's Dir directive on that box.

One direction

An app in Arabic, Hebrew or Persian: the direction goes on the document. Nothing else to do — the components read it (through CDK's Directionality), and the popups, rendered at the end of the page, inherit it.

index.html
<html lang="ar" dir="rtl">

With our i18n entry, it is done for you: the locale's direction goes on <html> when the app starts.

Mixed directions

A dir="rtl" box in a left-to-right page: CSS flips its layout on its own, but what is decided in script — which side inline-start is, where a popup opens, which arrow key goes to the next item — reads CDK's Directionality, the document's by default. Import Dir in the component holding the box: on any element with a dir attribute, it gives that direction to the components inside.

quote.ts
import { Dir } from '@angular/cdk/bidi';import { LOCALE_ID } from '@angular/core';
@Component({  selector: 'app-quote',  imports: [Dir, ScTooltipProvider, ScTooltipTrigger /* … */],  // Its dates and numbers in Arabic too: every part inside reads LOCALE_ID.  providers: [{ provide: LOCALE_ID, useValue: 'ar' }],  template: `    <div dir="rtl" lang="ar">      <div scTooltipProvider side="inline-start">…</div>    </div>  `,})export class Quote {}

Both boxes below are right to left, and their tooltips open on inline-start. Focus the buttons: with Dir, the tooltip opens on the right; without it, on the left, as in the page around it.

With Dir

Without Dir

Good to know

  • Our right-to-left examples import Dir: they are right-to-left boxes in a left-to-right page. Copied into an app that is right to left on <html>, it can go.
  • Sides and alignments are logical: side="inline-start" and alignment="end" flip with the direction; left and right stay put.
  • Set lang with dir: screen readers pronounce the text in that language.
  • Popups render at the end of the page, outside the box. They get its direction through Dir, not its lang: write dir="rtl" lang="ar" again on the content you put in a portal (a select's popup, a dialog, a preview card).
  • Dates, numbers and the week's first day follow LOCALE_ID: provide it on the section's component, as above — every part inside reads it, in its overlays too. The parts have no locale input.
  • Charts are not mirrored by default, as in Recharts: their legend and tooltip follow the direction, their plot doesn't. To mirror them — the categories from the right, the values on the right, pies and rings from 9 o'clock clockwise, treemaps and sankeys from the right, the arrows the way they're drawn — set charts: { followDirection: true } in provideSemanticComponents (a bilingual app: mirrored in Arabic only), or an axis's own reversed and orientation — which win.