demo D219
Locales, and it mirrors in React
The same grid in English, Japanese and Arabic, which sets the grid right to left
locale · direction: 'rtl'
This shows the same grid in English, Japanese and Arabic, with Arabic laying the whole grid out right to left. It proves the grid adapts to a locale end to end, mirroring its layout for right-to-left languages rather than just swapping words.
This is the React version. The grid mounts through the createLatticeGrid adapter, which takes its configuration as ordinary props and hands back the live grid through a ref. The grid below is the same one every other tab runs.
The configuration
<link rel="stylesheet" href="https://cdn.latticegrid.dev/lattice-grid@1.108.0/lattice-grid.min.css">
<script type="importmap">
{ "imports": { "@toclocoinc/lattice-grid": "https://cdn.latticegrid.dev/lattice-grid@1.108.0/lattice-grid.esm.min.js" } }
</script>
<div id="app"></div>
<script type="module">
import React from 'https://esm.sh/react@18';
import { createRoot } from 'https://esm.sh/react-dom@18/client';
import { createGrid } from 'https://cdn.latticegrid.dev/lattice-grid@1.108.0/lattice-grid.esm.min.js';
import 'https://cdn.latticegrid.dev/lattice-grid@1.108.0/locales/ja-JP.esm.min.js';
import 'https://cdn.latticegrid.dev/lattice-grid@1.108.0/locales/ar.esm.min.js';
import createLatticeGrid from 'https://cdn.latticegrid.dev/lattice-grid@1.108.0/modules/react.esm.min.js';
const LatticeGrid = createLatticeGrid({ React, createGrid });
// The same grid and the same rows in three locales. Only the chrome and the
// formatting change: numbers, currency and dates read the grid's locale, and
// Arabic sets direction 'rtl', which mirrors the whole grid, pin and all.
const locales = {
English: { locale: 'en-GB', direction: 'ltr', currency: 'GBP', titles: ['Product', 'Price', 'Updated', 'Share'] },
日本語: { locale: 'ja-JP', direction: 'ltr', currency: 'JPY', titles: ['製品', '価格', '更新日', 'シェア'] },
العربية: { locale: 'ar-EG', direction: 'rtl', currency: 'EGP', titles: ['المنتج', 'السعر', 'تاريخ التحديث', 'الحصة'] },
};
const rows = [/* e.g. [{ id: 1, product: 'Desk lamp', price: 42.5, updated: '2026-08-01', share: 0.18 }, ...] */];
function App() {
// One locale prop selects the language. Swap the value and the grid restyles
// in place, keeping its data, sort and selection.
const [name, setName] = React.useState('English');
const L = locales[name];
const columns = [
{ field: 'product', title: L.titles[0], layout: { pin: 'start', width: 180 } },
{ field: 'price', title: L.titles[1], type: 'number', format: { style: 'currency', currency: L.currency }, total: 'sum' },
{ field: 'updated', title: L.titles[2], type: 'date' },
{ field: 'share', title: L.titles[3], type: 'number', format: { style: 'percent' } },
];
return (
<>
<div style={{ display: 'flex', gap: '8px', marginBottom: '12px' }}>
{Object.keys(locales).map((n) => (
<button key={n} onClick={() => setName(n)} aria-pressed={n === name}>{n}</button>
))}
</div>
<LatticeGrid
rowKey="id"
locale={L.locale}
direction={L.direction}
columns={columns}
rows={rows}
style={{ height: '460px' }}
/>
</>
);
}
createRoot(document.getElementById('app')).render(<App />);
</script>