Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…

Read the release notes

dir

Sets the base text direction (ltr, rtl or auto). Needed for Arabic, Hebrew, Persian and Urdu; VB mirrors direction-specific UI through :dir(rtl).

Overview

The dir attribute sets the base direction of an element's text: left to right, right to left, or worked out from the content. Right-to-left languages such as Arabic, Hebrew, Persian and Urdu need it; without it punctuation lands at the wrong end and mixed text reorders. Direction is inherited, so set it on <html> for the page and on any element whose direction differs.

Applies to: every element (it is a global attribute). <bdi> defaults to auto, and <bdo> requires ltr or rtl.

Values

ValueMeaning
ltrLeft to right.
rtlRight to left.
autoThe browser picks the direction from the first strong directional character in the content. For text inputs and textareas it looks at the value.
Absent, "" or an unknown valueInherited from the parent. On <html> with no value, ltr.

Examples

An RTL page

Set direction and language together on the root.

Text of unknown direction

Wrap user-supplied names, labels and numbers in <bdi>. Without isolation, an Arabic or Hebrew name in an English sentence can pull the following words and numbers into its direction: "User إيمان left 3 comments" can display with the "3" in the wrong place.

For a whole block of user content, use dir="auto" on its container:

Overriding the algorithm

<bdo> forces characters into one order regardless of their own direction. It is rarely needed; use it to show text exactly as stored, such as a part number.

Styling by direction: :dir(), not [dir]

The :dir(rtl) pseudo-class matches every element whose resolved direction is right to left, including elements that inherit it and dir="auto" elements that resolve to RTL. The attribute selector [dir="rtl"] only matches the element that carries the attribute.

Better still, write direction-neutral CSS with logical properties (margin-inline-start, padding-inline-end, inset-inline-start, text-align: start, float: inline-end) so nothing needs flipping.

In Vanilla Breeze

  • Logical properties throughout. Spacing, borders, alignment and positioning follow the inline direction, so layouts mirror with no extra CSS.
  • Mirroring with :dir(rtl). Where a logical property is not enough, VB flips direction-specific details with :dir(rtl) rules, for example:
    • breadcrumb separators, nav.breadcrumb and <bread-crumb> (src/native-elements/nav/styles.css, src/web-components/bread-crumb/styles.css)
    • the <summary> disclosure marker (src/native-elements/details/styles.css)
    • side sheets, dialog[data-position="start|end"] (src/native-elements/dialog/styles.css)
    • the range fill and the switch knob (src/native-elements/input/range.css, input/switch.css)
    • ul[data-marker="arrow"] markers (src/native-elements/lists/styles.css)
    • table edge and row-highlight bars, drawn with physical box-shadows (src/native-elements/table/styles.css), shapes, callouts and speech bubbles (src/shapes/), data-float (src/utils/float.css)
    • slide view transitions: data-vt-class="slide-forward" moves content toward the start of the line, which is the left in LTR and the right in RTL (src/utils/view-transitions.css)
  • Icons opt in. Icons are not mirrored automatically, because checkmarks, clocks and logos must not flip. Add data-flip-rtl to directional glyphs: <icon-wc name="arrow-right" data-flip-rtl> (src/web-components/icon-wc/styles.js). See icons.
  • Code stays left to right. pre blocks that contain code or samp are forced to direction: ltr inside RTL pages, unless the pre has its own dir (src/native-elements/code/styles.css).
  • Keyboard arrows follow direction. Components with arrow-key navigation, such as <tab-set>, splitters and carousels, swap Left and Right in RTL.
  • No [dir] rules on purpose. The browser already gives [dir] elements bidi isolation, and <bdi> / <bdo> their behaviour. Re-declaring them weakened isolation, so VB leaves them alone (src/native-elements/i18n/styles.css, section 5).
  • Script helpers. isRTL(locale) in src/lib/i18n.js reports whether a language is written right to left.

Accessibility

  • Pair dir with lang. dir sets the layout direction; lang tells screen readers which voice and pronunciation to use.
  • Use the attribute, not CSS direction. The CSS specification asks authors not to set direction for document text. The attribute is part of the content: it drives :dir(), bidi isolation and form submission through dirname, and it survives without CSS.
  • Mirror meaning, not everything. Arrows that mean "next" flip; media controls, clocks and numbers do not.

Browser support

The dir attribute is supported everywhere. The :dir() pseudo-class is Baseline widely available since 2026 (Chrome 120, Firefox 49, Safari 16.4).

Gotchas

  • dir="auto" looks only at the first strong character. A message that starts with an English brand name and continues in Arabic resolves to LTR.
  • Physical CSS does not mirror. margin-left, left: 0 and text-align: left stay on the left in RTL. Use the logical forms.
  • Background gradients and transforms are physical. linear-gradient(to right, …) and translateX() need a :dir(rtl) override, as VB does for the range fill and side sheets.
  • Submitting direction. The text direction of a field is not sent with the form unless you add dirname.

Related

Which to choose

  • dir="rtl" on <html> or a section — content you know is right to left.
  • dir="auto" — a block or field of user content in an unknown language.
  • <bdi> — an inline name or value of unknown direction inside a sentence.
  • <bdo> — forcing a character order; rarely right.
  • :dir(rtl) in CSS — the few styles that logical properties cannot express.
↑