Skip to content

feat(ui): add docs header toggle to preview components in RTL - #910

Open
AbramovychYurii wants to merge 2 commits into
cosscom:mainfrom
AbramovychYurii:feat/rtl-toggle
Open

AbramovychYurii wants to merge 2 commits into
cosscom:mainfrom
AbramovychYurii:feat/rtl-toggle

Conversation

@AbramovychYurii

Copy link
Copy Markdown

Following up on my question in #892.

While fixing RTL stuff I kept switching dir from the console, but that doesn't change Base UI behavior like arrow keys or the drawer swipe, since those come from DirectionProvider. So I added a toggle next to the theme switch that does both and remembers the choice.

A lot of people build apps in RTL languages like Arabic, Hebrew, or Persian, and they can already wrap their app and coss ui in RTL, but not everything works right there yet. With the toggle, they can see how each component behaves in RTL right in the docs, before shipping it.

Should make RTL bugs a lot easier to catch.

Preview:

Screen.Recording.2026-10-22.at.14.43.47.mov

How it works

  • New button in the header between GitHub and the theme switch, the pilcrow icon flips with the direction
  • It sets <html dir> and wraps the site in Base UI's DirectionProvider
  • The choice is saved in localStorage (direction, like theme) and a tiny inline script restores it before paint, so there's no LTR flash on reload
  • Stays in sync across open tabs
  • The toggle lives in the coss ui header, so it covers every coss ui page: docs, particles and chat. It's passed through a new optional actions slot in SiteHeader

Also fixed

The toggle caught its first bug: tab and segmented control indicators stayed in the old spot after switching direction until you clicked, since they only re-measure on resize. They now remount when the direction changes.

I'll keep looking for more RTL bugs and fixing them as I go.

@vercel

vercel Bot commented Oct 22, 2026

Copy link
Copy Markdown

@AbramovychYurii is attempting to deploy a commit to the cal Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
vercel Bot temporarily deployed to Preview – coss-com-origin October 22, 2026 12:50 Inactive
@vercel

vercel Bot commented Oct 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
coss-com-origin Skipped Skipped Oct 22, 2026 12:50pm UTC

Request Review

This branch was previously deployed

1 inactive deployment
Preview – coss-com-origin — b727b1ef Deployed Oct 22, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant