Getting Started
NexubProvider sets the locale, text direction and built-in strings for every @nexub/react component. It is optional: without it, components use English strings, left-to-right layout and the user’s own locale for number and date formatting.
import { NexubProvider, type NexubMessages } from '@nexub/react';
const ar: Partial<NexubMessages> = {
close: 'إغلاق',
undo: 'تراجع',
goToPage: (page) => `الانتقال إلى الصفحة ${page}`,
};
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="ar" dir="rtl">
<body>
<NexubProvider locale="ar" messages={ar}>
{children}
</NexubProvider>
</body>
</html>
);
}| Prop | Default | What it does |
|---|---|---|
locale | 'en' | BCP 47 locale for Intl formatting in Amount, MoneyInput, NumberTicker, DatePicker and DateRangePicker. The locale prop on Amount, MoneyInput and NumberTicker still wins. |
dir | from locale | 'rtl' for Arabic, Hebrew, Persian and Urdu (ar, he, fa, ur, with any region), otherwise 'ltr'. Set it to override. |
messages | English | A Partial<NexubMessages> merged over the defaults, so you only pass what you translate. Explicit props still win: <Autocomplete placeholder="…" /> beats searchPlaceholder. |
The provider wraps Radix’s DirectionProvider, so menus, sliders, tabs and other Radix primitives follow dir for keyboard arrows and placement. It does not touch <html>: set lang and dir there yourself, where your app renders it, so the page, screen readers and the CSS rtl: variants agree with the provider.
useLocale() returns the active { locale, dir }, and useNexubMessages() the merged strings, for your own components.
Components use logical properties (ms-, pe-, start, border-s), so padding, borders and alignment flip with dir. Directional icons, such as the chevrons in Pagination, Breadcrumb and menus, mirror under dir="rtl"; the Switch thumb and Toast slide-in reverse too.
Drawer’s side stays physical: side="left" is the left edge in both directions. Pick the side from dir if you want the drawer to follow reading order.
Every user-facing default string in @nexub/react. Function keys take a value and return the string, so plurals and word order can follow the language.
| Key | Default |
|---|---|
close | 'Close' |
dismissAlert | 'Dismiss alert' |
dismissBanner | 'Dismiss banner' |
remove | 'Remove' |
removeFilter | 'Remove filter' |
removeFile | (fileName) => `Remove ${fileName}` |
uploadFiles | 'Upload files' |
clickToUpload | 'Click to upload' |
orDragAndDrop | 'or drag and drop' |
clearSearch | 'Clear search' |
showPassword | 'Show password' |
hidePassword | 'Hide password' |
increment | 'Increment' |
decrement | 'Decrement' |
loading | 'Loading…' |
pagination | 'Pagination' |
previousPage | 'Go to previous page' |
nextPage | 'Go to next page' |
goToPage | (page) => `Go to page ${page}` |
breadcrumb | 'breadcrumb' |
breadcrumbMore | 'More' |
moreCount | (count) => `${count} more` |
rating | 'Rating' |
ratingStars | (stars) => `${stars} star(s)` |
mainNavigation | 'Main' |
sidebar | 'Sidebar' |
searchPlaceholder | 'Search…' |
noResults | 'No results found.' |
pickDate | 'Pick a date' |
pickDateRange | 'Pick a date range' |
commandPalette | 'Command palette' |
notifications | 'Notifications ({hotkey})' — Radix replaces {hotkey} |
undo | 'Undo' |
promptLabel | 'Message' |
sendMessage | 'Send message' |
stopGenerating | 'Stop generating' |
promptHint | 'Press Enter to send, Shift+Enter for a new line' |
thinking | 'Thinking' |
youSaid | 'You said' |
assistantSaid | 'Assistant said' |
failedToSend | 'Failed to send' |
retry | 'Retry' |
copy | 'Copy' |
copied | 'Copied' |
goodResponse | 'Good response' |
badResponse | 'Bad response' |
regenerate | 'Regenerate' |
sources | 'Sources' |
source | (n) => `Source ${n}` |
jumpToLatest | 'Jump to latest' |
conversation | 'Conversation' |