Search documentation

Search for a page or heading...

tablecn
0

The table on Arabic, Hebrew or Persian pages. Columns, pinning, resizing and menus follow the reading direction.

Try it: the first column is on the right. Scroll the table sideways, drag a column's left edge to widen it, drag a header to move it, open a column's ⋯ menu and its Color submenu, or add a Date filter and open its calendar.

Set it up

Three things tell the table and its menus which way the page reads:

The page

Set dir on <html> (or on the element around the table), as for any right-to-left page:

app/layout.tsx
<html lang="ar" dir="rtl">

The table's layout follows it: the first column, pinned columns and their shadows, the toolbar and the pagination.

The table

Pass dir to useDataTable, so resizing follows the pointer:

components/orders-table.tsx
const table = useDataTable({
  data,
  columns,
  getRowId: (order) => order.id,
  dir: "rtl", 
})

Your primitive library

Menus, selects, popovers and the filter's calendars read the direction from their library, not from the page. They open outside the table, at the end of <body>, so they take it from this provider even when only part of the page is right-to-left. Wrap your app with it:

app/providers.tsx
import { Direction } from "radix-ui"

<Direction.Provider dir="rtl">{children}</Direction.Provider>

Without it, a column's Color submenu opens on the wrong side, the filter panel reads left-to-right, and the arrow keys move the wrong way in menus.

If your app switches direction with the language, derive all three from the same value.

What follows the direction

PartLeft-to-rightRight-to-left
Columnsfirst column on the leftfirst column on the right
Pinned columns"start" is the left edge"start" is the right edge, and the shadow flips
Resizingdrag the right edge; → widensdrag the left edge; ← widens
Moving a column← / → move it the way the arrow pointsthe same: the arrow is the direction it moves on screen
Pagination‹ previous, › nextthe arrows flip
Menus and submenusopen to the rightopen to the left (with the provider above)
Filter panel and pickers"Where" on the left, lined up with the Filter button's left edge"Where" on the right, lined up with its right edge
Calendarsweekdays from the left, previous on the leftweekdays from the right, previous on the right
Header and cell textaligned leftaligned right

Everything is laid out with logical properties (start / end), so your own meta and classes should use them too: ps-2 rather than pl-2, text-start rather than text-left.

Translate

Right-to-left pages usually need their own texts too. The table ships English and Vietnamese; for another language, pass your messages to every component. See Translate the UI.

Good to know

  • Numbers and dates keep their own order inside a cell: $5.00 and 2026-09-28 read left to right, as the browser renders them in any page.
  • Your shadcn components (the dropdown menu's submenu arrow, the calendar's month arrows) are yours, from shadcn/ui: they flip as far as your copies do. Add rtl:rotate-180 to an arrow icon that points the wrong way.