Patterns

Right to left

The viewer sits at the end of <body>, outside your layout. When it opens, it copies the trigger's direction and the nearest lang onto itself, so a gallery inside dir="rtl" gets a right-to-left viewer even on a left-to-right page. There is no option to set.

Loading the live example…

rtl.tsx
import { itemLabel } from "@ogdakke/fluidbox";
import { Fluidbox } from "@ogdakke/fluidbox/react";
import "@ogdakke/fluidbox/filmstrip.css";
import { arabic, photos } from "./data";

export function Rtl() {
  return (
    // The viewer takes dir and lang from the trigger's surroundings.
    <div dir="rtl" lang="ar">
      <Fluidbox.Root items={photos} labels={arabic}>
        <div className="pattern-grid">
          {photos.map((photo) => (
            <Fluidbox.Trigger
              key={photo.src}
              item={photo}
              className="pattern-thumb"
            >
              <img src={photo.src} alt={itemLabel(photo)} />
            </Fluidbox.Trigger>
          ))}
        </div>
        <Fluidbox.Filmstrip />
      </Fluidbox.Root>
    </div>
  );
}
  • Forward is to the left. ArrowLeft and a swipe to the left go to the next item, Next sits on the left, and Close takes the top-left corner. The filmstrip starts on the right.
  • labels translates every word the viewer shows or announces. The example's arabic labels are in the example data. position is a function, so it can format numbers for the language.
  • lang on the viewer makes a screen reader read the labels in that language.
  • Languages and direction covers what flips, what doesn't, and wiring labels to an i18n library.