Nasimunreleased, after 0.12.0
Get started

Rules

The six rules for a screen built on Nasim, and the reason for each.

A screen that keeps these six rules stays right to left, follows the theme and the product's colours, and keeps one copy of what must be one.

1. Import from @nyxon/nasim

Screens import UI from @nyxon/nasim only, never from @heroui/react or react-aria-components. An app lists @heroui/styles for its stylesheet and nothing more.

Why. Nasim wraps what HeroUI leaves in English or turns the wrong way in a right-to-left page (its spinner and close button labels, its tabs, its calendar), and keeps HeroUI's own versions of those behind it. A direct import skips the Persian wrapper, and a second import path is how a second copy of React Aria, with its own locale, gets into an app.

2. Copy comes as props, from the screen's strings

Nasim's own words (what a close or a retry button says) live inside Nasim. Every other word on a screen is the app's: the screen reads it from its own strings module and passes it to the component as a prop. No Latin text in JSX, and no literal aria-label, placeholder, title or alt in a screen.

Why. The words of a product change in one place, a label and the text beside it cannot disagree, and a name read by a screen reader is checked like any other copy. Keep Persian copy short and actionable (what happened, what to do next), and keep the zero-width non-joiners the script needs («می‌شود», «پیش‌فرض»).

3. Tokens, not colours

Colours, radii and fonts come from tokens: bg-surface, text-muted, border-border, bg-accent, rounded-field. No hex values in feature code, and no dark: utilities.

Why. The tokens already switch with the theme and follow a product's palette, and their pairs are measured for contrast in both themes. A hex value or a dark: utility does neither. Do not write text in accent, success or warning: as plain colours they are fills, about 2:1 on a light surface for the two statuses and only 3:1 guaranteed for a tenant's accent. Coloured text uses the soft pair (text-accent-soft-foreground on bg-accent-soft), which holds 4.5:1.

4. Logical layout

Use logical properties for layout: ms-*, pe-*, text-start, inset-inline-*. Direction-bound icons get rtl:rotate-180. Technical values (ids, links, addresses) get dir="ltr" and font-mono.

The exception is the safe areas, which are physical: a notch is on the left or the right of the screen, not at its start or end. Use px-safe, px-page or pl-*/pr-* for them, never ps-*/pe-*.

Why. A logical layout mirrors with the document's direction by itself; a physical one is drawn backwards in a right-to-left page.

5. One theme controller

The theme is NasimProvider's. Never call HeroUI's own useTheme; read and set the theme with Nasim's useTheme.

Why. The controller writes the class and data-theme on <html>, remembers the choice and hands it to the server through a cookie. A second controller writes the same attributes and the two fight.

6. Variants with tv()

Write variants with tv() from tailwind-variants, never as long class strings in a screen.

Why. A variant table says which classes belong to which state in one place, and merges conflicting classes the way Nasim's own parts do.

On this page