# Nexub Design System Nexub DS is a token-driven React design system for SaaS products. The visual language is **Calm Depth**: tonal surfaces, one accent per view, spring motion, honest numbers. **Liquid Glass** is an optional material for the floating control layer. **Marketing mode** (`data-mode="marketing"`) is the livelier look for marketing sites, on the same tokens. Reference files (read only what the task needs): - [references/components.md](references/components.md): every component and pattern, grouped by category. Start here. - `references/components/.md`: props, examples, when to use and accessibility for one component. Read it before using a component you have not used yet in this session. - [references/tokens.md](references/tokens.md): color roles, type roles, spacing, shape, elevation, motion, z-index. - [references/react-native.md](references/react-native.md): **mobile apps** (Expo / React Native). Use `@nexub/react-native` and `@nexub/react-native/patterns` there, never `@nexub/react`. ## 1. Check the setup first Look for `@nexub/react` in `package.json`. If it is missing, set it up: ```bash npm install @nexub/react @nexub/patterns @nexub/themes @nexub/tokens @nexub/icons ``` ```ts // app entry or global CSS, once import '@nexub/themes/base'; // resets + token CSS variables import '@nexub/themes/light'; import '@nexub/themes/glass'; // only if you use Liquid Glass ``` ```css /* Tailwind 4 (Tailwind 3 is not supported from 4.0): no config file. Load the theme CSS here, in the base layer, instead of from JS */ @layer theme, base, components, utilities; @import "@nexub/themes/base" layer(base); @import "@nexub/themes/light" layer(base); @import "tailwindcss"; @import "@nexub/tokens/tailwind.css"; @source "../node_modules/@nexub/react/dist"; @source "../node_modules/@nexub/patterns/dist"; ``` **Next.js App Router:** presentational components (Heading, Text, Container, Section, Stack, Badge, EyebrowChip, Logo, Float, Marquee and every `@nexub/marketing` section except `MarketingNav`, `PricingTable` and `FAQ`) are server components. Import per component (`@nexub/react/Button`, `@nexub/marketing/Hero`, `cn` from `@nexub/react/cn`) or set `experimental.optimizePackageImports: ['@nexub/react', '@nexub/marketing', '@nexub/icons']`, or the page ships every client component. Compound components (`Accordion.Root`, `TopNav.Root`) only work inside a `'use client'` file. To use `next/font`, import `@nexub/themes/core` (no fonts, no page backdrop) instead of `base` and name the font variables `--font-family-sans` and `--font-family-display`. With Tailwind, never also import `@nexub/react/styles.css`. Wrap the app in `` from `@nexub/react`. In server-rendered apps (Next.js), put `` in `` and add `suppressHydrationWarning` to ``. Product brands: set `data-product="leap" | "bookub" | "payub" | "founderub"` on the root. This remaps the `tertiary` role. Since 10.1: `@nexub/themes/products` adds every app key (`people`, `contracts`, `forms`, `commerce`, `money`, `capital`, `mind`, `go`, `command-hub`, `runner`, and the aliases `book-hub`, `payhub`, `founder-hub`), and `@nexub/themes/divisions` adds `data-division="os" | "commerce" | "fintech" | "intelligence" | "autonomous"`. Marketing sections take `division`; `Card accent` takes any app or division key. On nexub.com use `MarketingNav` items with `columns` for the grouped mega-menu. ## 2. How to build a screen 1. **Start from a pattern.** Check the Patterns sections of `references/components.md` before you compose anything by hand. 2. **Then use components.** Use `@nexub/react` for every control, overlay, layout primitive and piece of typography. Never hand-roll a button, input, dialog, menu or table that the library already has. 3. **Then use tokens, only for the glue.** Use Tailwind utilities from the preset or v4 theme (`bg-surface-container-low`, `text-on-surface-variant`, `p-4`, `gap-6`, `rounded-shape-container`, `text-title-md`) or `var(--…)`. 4. **Never hardcode design values.** That means no hex or rgb colors, no Tailwind palette colors (`bg-blue-500`, `text-gray-600`), no arbitrary px values (`p-[13px]`), no ad-hoc shadows or gradients. Starting points for typical SaaS screens: | Screen | Build with | | --- | --- | | App frame | `AppShell` (`AppShell.Root/Header/Body/Sidebar/Main`) + `Sidebar` or `NavigationRail` + `AppHeader` or `TopNav` | | Dashboard | `PageHeader` + a `Grid` of `StatCard` + `BarChart` / `LineChart` + `DataTable` or `Table` + `ActivityFeed` | | Charts | `BarChart` (compare categories), `LineChart` (trend over time), `DonutChart` (parts of a whole, six slices at most), `Sparkline` (trend inside a stat or table cell). Pass `title`, `data`, `index` and `series`; colours come from the chart palette, never hex | | List / detail | `ListDetail` + `FilterBar` + `EmptyState` | | Settings | `SettingsLayout` / `SettingsRow` + `SettingsSection` + `FormField` | | Sign in / sign up | `AuthCard` + `FormField` + `PasswordInput` | | Pricing / billing | `PlanCard` + `SegmentedControl` (monthly / yearly) + `Amount` | | Onboarding | `Stepper` + `CheckList` | | Search / commands | `CommandPalette` + `KeyboardShortcut` | | Empty, loading, error | `EmptyState`, `Skeleton`, `ErrorState`, `Toast` | | Expressive moment (onboarding, hero, success) | `@nexub/themes/vivid` + `data-expression="vivid"` on that area, `Aurora` behind the hero. One expressive moment per screen; keep dense tables and forms Calm | | White-label / customer brand | `` (native: ``), plus `createSeedStylesheet(seed)` from `@nexub/tokens/seed` rendered on the server so there is no flash. Never hand-pick brand hex for roles; try colours at nexub.design/foundations/theme-builder | | Marketing / landing page | `@nexub/marketing` under `data-mode="marketing"`: `MarketingNav`, `Hero`, `LogoStrip`, `StatBand`, `FeatureSplit`, `HowItWorks`, `ProductGrid`, `TestimonialGrid`, `PricingTable`, `FAQ`, `CTABand`, `MarketingFooter` | Money: use `Amount` and `MoneyInput`. They use tabular figures, the currency's own minor unit and a true minus sign. Icons: import from `@nexub/icons`, not `lucide-react` directly. ## 3. Calm Depth principles 1. **Content leads, chrome recedes.** Navigation is quieter than content. Remove a divider before you add one; let spacing and tone separate regions. Do: a tonal sidebar with no border, where the active item is a soft pill. Don't: a saturated brand-blue sidebar item, or a hard line around every region. 2. **Hierarchy through tone and layout, not decoration.** Surfaces step `surface` → `surface-container-*` → `surface-elevated`. Shadows are only for things that float. Product UI has no gradients, no colored icon tiles and no gradient eyebrow chips (those belong to marketing mode only). 3. **One accent, spent deliberately.** Each view gets one filled (primary) button. Everything else is `tonal`, `outlined` or `text`. Never put two filled buttons side by side. 4. **Physical, interruptible motion.** Use the spring tokens (`ease-spatial-default duration-spatial-default`), not raw durations. Exits are faster than entrances. Honor `prefers-reduced-motion`. 5. **Honest numbers and states.** Use tabular figures in data. Hover, pressed, selected and disabled are explicit component states. Never fake a state with opacity. 6. **Accessible by construction.** Every role pair meets WCAG 2.2 AA in light, dark and high contrast, as long as you pair a role with its `on-` role. Keep visible focus, labelled controls (`FormField` + `Label`) and keyboard support. Use `VisuallyHidden` for icon-only labels. ## 4. Liquid Glass rules - Glass is for the floating control layer only: top bars, floating toolbars, popovers, menus, sheets, dialogs. Card glass is only for surfaces over imagery or media. - Turn it on through props: ``, ``, ` )} ); } ``` ## Accessibility - A region named by its message. Sticky at the bottom of its scrolling parent, so put it last in the form. - Pair with `useUnsavedChanges(dirty)` to warn before leaving the page. Related: [form](form.md), [data-table](data-table.md) --- # Alert Dialog Confirmation dialog that requires an explicit user action before proceeding. - Package: `@nexub/react` · Category: Overlays · Status: stable - Import: `import { AlertDialog } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/alert-dialog ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `AlertDialog.Root` | `compound` | | Root provider component that manages open state. | | `AlertDialog.Trigger` | `compound` | | Element that opens the dialog on interaction. | | `AlertDialog.Portal` | `compound` | | Portals the overlay and content into the document body. | | `AlertDialog.Overlay` | `compound` | | Dimmed backdrop rendered behind the content. | | `AlertDialog.Content` | `compound` | | The dialog panel containing title, description, and actions. | | `AlertDialog.Title` | `compound` | | Accessible title announced to screen readers. | | `AlertDialog.Description` | `compound` | | Supporting description text for the dialog. | | `AlertDialog.Action` | `compound` | | Confirms the destructive or affirmative action and closes the dialog. | | `AlertDialog.Cancel` | `compound` | | Cancels the action and closes the dialog. | | `AlertDialog.Confirm text` | `string` | | Type-to-confirm (5.6): the Action stays disabled until this text is typed. For irreversible actions on named resources. | | `AlertDialog.Prompt` | `component` | | 11.2: asks for one line of text in place of `window.prompt`: `title`, `label`, `required` (default true), `minLength`, `maxLength`, `validate`, `multiline`, `tone`, and `onSubmit` (busy while its promise runs; a rejection shows its message and keeps the dialog open). | | `usePrompt()` | `[prompt, element]` | | 11.2: render `element` once; `await prompt(options)` resolves to the trimmed answer, or `null` when cancelled. | ## Example: Default ```tsx import * as React from 'react'; import { Button, AlertDialog } from '@nexub/react'; export default function Example() { const [open, setOpen] = React.useState(false); return ( <> Are you absolutely sure? This action cannot be undone. This will permanently delete your account and remove all your data.
); } ``` ## Example: Type to confirm Deleting a workspace asks for its name first. ```tsx 'use client'; import { AlertDialog, Button } from '@nexub/react'; export default function Example() { return ( Delete acme-prod? All projects, members and billing history go with it. This can’t be undone. Cancel Delete workspace ); } ``` ## Example: Ask for a reason usePrompt replaces window.prompt, with limits and a busy state. ```tsx import * as React from 'react'; import { Button, usePrompt } from '@nexub/react'; export default function Example() { const [prompt, promptElement] = usePrompt(); const [reason, setReason] = React.useState(null); return (

Reason: {reason ?? '—'}

{promptElement}
); } ``` --- # Alert Inline contextual message with optional title, icon, and dismiss action. - Package: `@nexub/react` · Category: Feedback · Status: stable - Import: `import { Alert } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/alert ## When to use - Communicating system status, errors, or success after an action - Showing inline validation feedback inside a form - Warning the user about a potentially risky operation - Providing contextual information relevant to the current page ## When not to use - Transient messages — use Toast for ephemeral notifications - Blocking the user for a required decision — use AlertDialog - Marketing or promotional messaging - Replacing empty states — use EmptyState instead ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `tone` | `'neutral' \| 'info' \| 'success' \| 'warning' \| 'danger'` | `'neutral'` | Semantic colour tone of the alert. | | `title` | `ReactNode` | | Bold title rendered at the top of the alert. 11.5: any content (a link, a name in bold); was a string. | | `icon` | `ReactNode` | | Custom icon rendered to the left of the content. | | `action` | `ReactNode` | | Action element (e.g. a button) rendered beside the content. | | `onClose` | `() => void` | | When provided, renders a close button that calls this handler. | ## Example: Default ```tsx import { Alert } from '@nexub/react'; export default function Example() { return Your trial expires in 3 days.; } ``` ## Example: Tones ```tsx import { Alert } from '@nexub/react'; export default function Example() { return (
Informational message. Operation completed successfully. Something needs your attention. Something went wrong.
); } ``` ## Example: Dismissible ```tsx import { Alert } from '@nexub/react'; export default function Example() { return (
{}}>Your changes have been saved.
); } ``` --- # Amount Honest money: Intl formatting, tabular numerals, the currency’s minor unit and a true minus sign. - Package: `@nexub/react` · Category: Data Display · Status: beta - Import: `import { Amount } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/amount ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `value` (required) | `number` | | The amount. | | `currency` (required) | `string` | | ISO 4217 code, e.g. "USD". | | `locale` | `string` | | BCP 47 locale. Defaults to the user's. | | `size` | `'sm' \| 'md' \| 'lg' \| 'display'` | `'md'` | `display` is a hero figure with a quieter symbol and minor units. | | `tone` | `'neutral' \| 'auto'` | `'neutral'` | `auto` colours gains success and losses error. | | `signDisplay` | `Intl signDisplay` | | e.g. 'exceptZero' to show + on gains. | | `animate` | `boolean` | `false` | Roll the digits to new values (NumberTicker). The first render never animates. | ## Example: Display ```tsx import { Amount } from '@nexub/react'; export default function Example() { return ; } ``` ## Example: Gains and losses ```tsx import { Amount } from '@nexub/react'; export default function Example() { return (
); } ``` Related: [money-input](money-input.md), [number-ticker](number-ticker.md) --- # App Shell Full-height application frame: a header row over a body with a sidebar slot and a scrolling main region. - Package: `@nexub/react` · Category: Layout · Status: stable - Import: `import { AppShell } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/app-shell ## When to use - The outer frame of a product or dashboard: header, side navigation, content ## When not to use - Marketing or content pages: use `Section` and `Container` - A single panel inside a page: use `Grid` or `Flex` ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `AppShell.Root` | `compound` | | Viewport-height grid (`h-screen`): header row, then the body. Override the height with `className` when it is not the whole page. | | `AppShell.Header` | `compound` | | First row, e.g. a `TopNav.Root`. | | `AppShell.Body` | `compound` | | Second row: lays out the sidebar and main side by side. | | `AppShell.Sidebar` | `compound` | | Fixed-width column that scrolls on its own, e.g. a `Sidebar.Root`. | | `AppShell.Main` | `compound` | | The `
` landmark: takes the remaining width, scrolls on its own, padded by default. | | `...props` | `React.HTMLAttributes` | | Every part forwards its ref and HTML attributes. | ## Example: Header, sidebar and main ```tsx import { AppShell, Logo, Sidebar, Text, TopNav } from '@nexub/react'; import { BarChart3, Home, Settings } from '@nexub/icons'; export default function Example() { return ( } active>Overview }>Reports }>Settings Page content scrolls here, under a fixed header and sidebar. ); } ``` Related: [top-nav](top-nav.md), [sidebar](sidebar.md), [page-header](page-header.md) --- # Approval Card The agent asks before it acts: what will happen, then Approve or Deny. - Package: `@nexub/react` · Category: AI · Status: beta - Import: `import { ApprovalCard } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/approval-card ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `title` (required) | `string` | | What the agent wants to do. | | `onApprove / onDeny` | `() => void` | | Called once with the choice. | ## Example: Before sending ```tsx 'use client'; import { ApprovalCard } from '@nexub/react'; export default function Example() { return ( Invoices INV-1042, INV-1051 and INV-1063, $4,120 in total, to ap@acme.example. ); } ``` ## Accessibility - The outcome is announced in a polite live region and replaces the buttons. Related: [message-bubble](message-bubble.md), [thinking-indicator](thinking-indicator.md) --- # Aspect Ratio Keeps its content at a fixed width-to-height ratio, for images, video and embeds. - Package: `@nexub/react` · Category: Layout · Status: stable - Import: `import { AspectRatio } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/aspect-ratio ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `ratio` | `number` | | Width divided by height, e.g. `16 / 9` or `1`. Common ratios (1, 16/9, 4/3, 3/2, 21/9, 9/16, 3/4, 2/3) use a class and are strict-CSP safe; any other ratio sets an inline `aspect-ratio` style. | | `children` | `ReactNode` | | Fills the box; give an image `h-full w-full object-cover`. | ## Example: Image ```tsx import { AspectRatio } from '@nexub/react'; export default function Example() { return (
16 : 9
); } ``` ## Example: Ratios ```tsx import { AspectRatio } from '@nexub/react'; const ratios = [ { ratio: 1, label: '1 : 1' }, { ratio: 4 / 3, label: '4 : 3' }, { ratio: 3 / 4, label: '3 : 4' }, ]; export default function Example() { return (
{ratios.map(({ ratio, label }) => (
{label}
))}
); } ``` Related: [media-card](media-card.md), [box](box.md) --- # Aurora A decorative background of slow-drifting colour fields from the accent roles. Subtle by default, richer under data-expression="vivid". - Package: `@nexub/react` · Category: Inline Primitives · Status: beta - Import: `import { Aurora } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/aurora ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `className` | `string` | | Shape it to its container, e.g. `rounded-shape-container`. The parent needs `position: relative` and `isolate` so the aurora stays behind the content. | ## Example: Behind a hero ```tsx import { Aurora, Button, EyebrowChip } from '@nexub/react'; export default function Example() { return (
New

Your money, at a glance

The colour follows your brand, theme and dark mode.

); } ``` ## Accessibility - Decorative: the whole layer is `aria-hidden`. - The fields stop drifting under reduced motion and the layer is hidden in forced-colours mode. Related: [text-gradient](text-gradient.md) --- # Autocomplete Type-to-search input with matching options dropdown. - Package: `@nexub/react` · Category: Form Controls · Status: stable - Import: `import { Autocomplete } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/autocomplete ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `options` (required) | `{ value: string; label: string }[]` | | Array of options available for selection. | | `value` | `string` | | The controlled selected value. | | `onValueChange` | `(value: string) => void` | | Callback fired when the selected value changes. | | `placeholder` | `string` | | Placeholder text shown in the input when empty. | | `emptyText` | `string` | | Text shown when no options match the current search query. | | `loading` | `boolean` | | Skeleton rows while options are being fetched (5.2); "Loading" is announced. | | `inputValue` | `string` | | Controlled input text (5.1). | | `onInputChange` | `(text: string) => void` | | Called as the user types, so you can fetch options (5.1). When set, options are shown as given, without built-in filtering. | | `onCreate` | `(text: string) => void` | | Adds a "Create “text”" option when the text matches no option (5.2). | | `aria-label` | `string` | | Accessible name of the field when it has no visible label. | | `label` | `ReactNode` | | 11.2: a visible label above the field. | | `clearOnSelect` | `boolean` | | 11.2: "add" mode: the text empties after a pick. | | `onClear` | `() => void` | | 11.2: called from the clear button or when the text is deleted; shows the clear button. | | `options[].description / disabled` | `string / boolean` | | 11.2: a second line (also searched), and options that can't be picked. | ## Example: Default ```tsx import { Autocomplete } from '@nexub/react'; export default function Example() { return (
); } ``` ## Example: With loading state ```tsx import { Autocomplete } from '@nexub/react'; export default function Example() { return (
); } ``` ## Example: Custom empty text ```tsx import { Autocomplete } from '@nexub/react'; export default function Example() { return (
); } ``` ## Example: Fetch as you type `onInputChange`: the app filters, the list shows skeleton rows while loading. ```tsx 'use client'; import * as React from 'react'; import { Autocomplete } from '@nexub/react'; const all = ['Amsterdam', 'Berlin', 'Lisbon', 'London', 'Madrid', 'Paris', 'Singapore', 'Tokyo']; // Fetch-as-you-type: onInputChange turns built-in filtering off. export default function Example() { const [query, setQuery] = React.useState(''); const [loading, setLoading] = React.useState(false); const [options, setOptions] = React.useState(all.map((c) => ({ value: c, label: c }))); React.useEffect(() => { setLoading(true); const t = setTimeout(() => { const q = query.toLowerCase(); setOptions(all.filter((c) => c.toLowerCase().includes(q)).map((c) => ({ value: c, label: c }))); setLoading(false); }, 300); return () => clearTimeout(t); }, [query]); return (
); } ``` ## Example: Add mode with a label ```tsx import * as React from 'react'; import { Autocomplete } from '@nexub/react'; const people = [ { value: 'u1', label: 'Aisha Rahman', description: 'aisha@nexub.test' }, { value: 'u2', label: 'Ben Ong', description: 'ben@nexub.test' }, { value: 'u3', label: 'Chen Wei', description: 'On leave', disabled: true }, { value: 'u4', label: 'Dana Lee', description: 'dana@nexub.test' }, ]; export default function Example() { const [added, setAdded] = React.useState([]); return (
!added.includes(p.value))} onValueChange={(v) => setAdded((a) => [...a, v])} />

Reviewers: {added.map((v) => people.find((p) => p.value === v)?.label).join(', ') || '—'}

); } ``` --- # Avatar Group Stacked group of avatars with overflow count. - Package: `@nexub/react` · Category: Avatar · Status: stable - Import: `import { AvatarGroup } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/avatar-group ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `max` | `number` | `4` | Maximum number of avatars shown before an overflow count is rendered. | | `size` | `'xs' \| 'sm' \| 'md' \| 'lg'` | | Controls avatar dimensions for all children. | | `spacing` | `'tight' \| 'normal'` | `'normal'` | Controls the overlap amount between stacked avatars. | ## Example: Default ```tsx import { AvatarGroup, Avatar } from '@nexub/react'; export default function Example() { return ( ); } ``` --- # Avatar Displays a user's profile picture with initials fallback. - Package: `@nexub/react` · Category: Avatar · Status: stable - Import: `import { Avatar } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/avatar ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `src` | `string` | | URL of the profile image. | | `name` | `string` | | Full name used to generate initials when no image is provided. | | `size` | `'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl'` | `'md'` | Controls avatar dimensions. | | `badge` | `boolean` | | Shows a status badge on the avatar. | | `badgeColor` | `string` | | Colour of the status badge. | | `fallback` | `ReactNode` | | Custom fallback rendered when the image fails to load and no name is provided. | ## Example: Default ```tsx import { Avatar } from '@nexub/react'; export default function Example() { return ; } ``` ## Example: Sizes ```tsx import { Avatar } from '@nexub/react'; export default function Example() { return (
{(['xs', 'sm', 'md', 'lg', 'xl'] as const).map((s) => ( ))}
); } ``` ## Example: With image ```tsx import { Avatar } from '@nexub/react'; export default function Example() { return ; } ``` ## Example: With badge ```tsx import { Avatar } from '@nexub/react'; export default function Example() { return (
); } ``` --- # Badge Small status indicator or label. Communicates state, category, or count. - Package: `@nexub/react` · Category: Labels & Badges · Status: stable - Import: `import { Badge } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/badge ## When to use - Labelling a status, category, or tag on an item - Showing a count or numeric indicator alongside an element - Highlighting new, featured, or updated content - Communicating a stage in a workflow (draft, published, archived) ## When not to use - Interactive filtering — use FilterChip or Chip instead - Long text labels that exceed 2–3 words - Critical alerts requiring user action — use Alert or Toast - Replacing a button — badges are non-interactive by design ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `variant` | `'solid' \| 'soft' \| 'outline'` | `'solid'` | Visual fill style. | | `tone` | `'success' \| 'danger' \| 'warning' \| 'info' \| 'neutral'` | `'neutral'` | Semantic color tone. | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Badge size. | | `leadingIcon` | `React.ReactNode` | | Icon or dot rendered before the label. | ## Example: Tones ```tsx import { Badge } from '@nexub/react'; export default function Example() { return (
Active Error Warning Info Draft
); } ``` ## Example: Variants ```tsx import { Badge } from '@nexub/react'; export default function Example() { return (
Solid Soft Outline
); } ``` ## Example: With leading dot ```tsx import { Badge } from '@nexub/react'; export default function Example() { return (
{(['success', 'danger', 'warning'] as const).map((t) => ( }> {t === 'success' ? 'Online' : t === 'danger' ? 'Offline' : 'Away'} ))}
); } ``` ## Accessibility - Roles: status (when conveying live state) - `—`: Badges are non-interactive and have no keyboard handlers. - Skipped in tab order. Decorative — never trap focus on a Badge. - Reads as inline text. For live status changes, wrap in an element with `role="status"` and `aria-live="polite"`. - For interactive equivalents (filtering, dismissing) reach for `Chip` or `FilterChip`. Related: [chip](chip.md) --- # Bar Chart Compare values across categories, grouped or stacked. Server-rendered SVG on the chart palette. - Package: `@nexub/react` · Category: Data Display · Status: beta - Import: `import { BarChart } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/bar-chart ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `title` (required) | `string` | | Accessible name of the chart and caption of its data table. | | `data` (required) | `T[]` | | One row per category, in order. | | `index` (required) | `keyof T` | | Key of the category label in each row (the x axis). | | `series` (required) | `ChartSeries[]` | | `{ key, label?, color? }` per series. `color` is 1–8 from the categorical chart palette; defaults to the series position. | | `valueFormat` | `(value: number) => string` | | Formats axis labels, hover text and the data table. | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Plot height: 8, 12 or 16rem. | | `legend` | `boolean` | | Show the legend. Defaults to on for more than one series. | | `stacked` | `boolean` | `false` | One bar per category with the series stacked. | | `series[].color` | `1–8 \| 'good' \| 'warning' \| 'danger' \| 'neutral'` | | 11.3: a palette colour or a semantic tone. | | `series[].valueFormat` | `(value: number) => string` | | 11.3: formats this series in the tooltip and table (one currency per series). | | `integerTicks` | `boolean` | | 11.3: gridlines on whole numbers only (counts). Also 11.3: a `null` or missing value is drawn as a gap (no bar, a break in the line) and listed as "—", not counted as 0. | | `tableView` | `boolean \| string` | | 11.3: a visible "Show as table" disclosure with the same data. Works without JS. | | `orientation` | `'vertical' \| 'horizontal'` | `'vertical'` | 11.3: categories down the side for long names and ranked lists. | | `variant / totalKey` | `'default' \| 'waterfall' / keyof T` | | 11.3: a waterfall of the first series from a running total; `totalKey` marks rows drawn from zero. | | `colorOf` | `(row, series, index) => colour \| tone \| undefined` | | 11.3: a colour per bar (e.g. over budget in danger). | ## Example: Grouped ```tsx import { BarChart } from '@nexub/react'; const data = [ { month: 'May', thisYear: 42, lastYear: 35 }, { month: 'Jun', thisYear: 48, lastYear: 37 }, { month: 'Jul', thisYear: 45, lastYear: 40 }, { month: 'Aug', thisYear: 56, lastYear: 41 }, { month: 'Sep', thisYear: 61, lastYear: 47 }, { month: 'Oct', thisYear: 68, lastYear: 50 }, ]; export default function Example() { return ( `$${v}k`} /> ); } ``` ## Example: Stacked ```tsx import { BarChart } from '@nexub/react'; const data = [ { quarter: 'Q1', web: 120, ios: 80, android: 60 }, { quarter: 'Q2', web: 140, ios: 95, android: 72 }, { quarter: 'Q3', web: 150, ios: 110, android: 90 }, { quarter: 'Q4', web: 170, ios: 128, android: 101 }, ]; export default function Example() { return ( ); } ``` ## Example: Interactive A crosshair and tooltip, keyboard point navigation, a toggle legend and `onPointClick`. ```tsx import * as React from 'react'; import { BarChart } from '@nexub/react'; type Row = { quarter: string; web: number; ios: number; android: number }; const data: Row[] = [ { quarter: 'Q1', web: 120, ios: 80, android: 60 }, { quarter: 'Q2', web: 140, ios: 95, android: 72 }, { quarter: 'Q3', web: 150, ios: 110, android: 90 }, { quarter: 'Q4', web: 170, ios: 128, android: 101 }, ]; export default function Example() { const [picked, setPicked] = React.useState('Click a bar, or focus the chart and press Enter.'); const pick = (point: { datum: Row; series?: { label?: string }; value?: number }) => setPicked(`${point.datum.quarter}${point.series ? `, ${point.series.label}: ${point.value}` : ''}`); return (

{picked}

); } ``` ## Example: Waterfall Rises in the good tone, falls in danger, totals from zero. ```tsx import { BarChart } from '@nexub/react'; const cash = [ { step: 'Opening', v: 120000, total: true }, { step: 'Sales', v: 64000, total: false }, { step: 'Payroll', v: -52000, total: false }, { step: 'Refunds', v: -6000, total: false }, { step: 'Closing', v: 126000, total: true }, ]; const usd = (v: number) => new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', notation: 'compact' }).format(v); export default function Example() { return ; } ``` ## Example: Horizontal and per-bar tones ```tsx import { BarChart } from '@nexub/react'; const products = [ { product: 'Enterprise plan (annual)', revenue: 48200 }, { product: 'Team plan', revenue: 31900 }, { product: 'Starter', revenue: 12800 }, ]; const spend = [ { month: 'Jan', spend: 82 }, { month: 'Feb', spend: 97 }, { month: 'Mar', spend: 118 }, ]; export default function Example() { return (
(row.spend > 100 ? 'danger' : undefined)} />
); } ``` ## Accessibility - The chart is a `figure` named by `title`. The drawing is hidden from assistive tech; a visually hidden table carries every value. - Colour is never the only cue: the legend and table name each series. Past six series, label directly or group the rest as "Other". Related: [line-chart](line-chart.md), [donut-chart](donut-chart.md), [sparkline](sparkline.md) --- # Box Generic container primitive with style token props. - Package: `@nexub/react` · Category: Layout · Status: stable - Import: `import { Box } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/box ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `asChild` | `boolean` | | Merges props onto the immediate child element (Radix Slot). | ## Example: Default ```tsx import { Box, Text } from '@nexub/react'; export default function Example() { return ( Content inside a Box ); } ``` ## Example: Nested ```tsx import { Box, Heading, Text } from '@nexub/react'; export default function Example() { return ( Section title Nested box content ); } ``` --- # Breadcrumb Hierarchical navigation trail showing page location. - Package: `@nexub/react` · Category: Navigation · Status: stable - Import: `import { Breadcrumb } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/breadcrumb ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `Breadcrumb.Root aria-label` | `string` | `'breadcrumb'` | Accessible label for the nav landmark. | | `Breadcrumb.Link href` | `string` | | URL the breadcrumb link navigates to. | | `Breadcrumb.Link asChild` | `boolean` | `false` | Merges props onto the immediate child element, useful for router Link components. | | `Breadcrumb.Trail items` (required) | `{ label: ReactNode; href?: string }[]` | | The whole trail from data (5.1), root first; the last item is the current page. | | `Breadcrumb.Trail maxItems` | `number` | `4` | Longer trails keep the first item and the last `maxItems - 1`, and move the rest into a "More" menu. | | `Breadcrumb.Separator children` | `React.ReactNode` | | Custom separator element. Defaults to a chevron icon. | | `Breadcrumb.Ellipsis aria-label` | `string` | `'More'` | Accessible label for the ellipsis element used to collapse long trails. | | `Breadcrumb.Section` | `component` | | 11.5: a plain section in the trail, neither a link nor the current page. In `Breadcrumb.Trail`, an item before the last with no `href` renders as one. | ## Example: Default ```tsx import { Breadcrumb } from '@nexub/react'; export default function Example() { return ( Home Components Button ); } ``` ## Example: With ellipsis ```tsx import { Breadcrumb } from '@nexub/react'; export default function Example() { return ( Home Navigation Breadcrumb ); } ``` ## Example: Auto-collapse Breadcrumb.Trail moves the middle of a long path into a menu. ```tsx import { Breadcrumb } from '@nexub/react'; export default function Example() { return ( ); } ``` --- # Button Group Groups related buttons together with optional attachment and orientation. - Package: `@nexub/react` · Category: Actions · Status: stable - Import: `import { ButtonGroup } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/button-group ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `orientation` | `'horizontal' \| 'vertical'` | `'horizontal'` | Lays out child buttons horizontally or vertically. | | `attached` | `boolean` | `false` | Removes gap and merges borders between adjacent buttons. | ## Example: Default ```tsx import { ButtonGroup, Button } from '@nexub/react'; export default function Example() { return ( ); } ``` ## Example: Attached ```tsx import { ButtonGroup, Button } from '@nexub/react'; export default function Example() { return ( ); } ``` ## Example: Vertical ```tsx import { ButtonGroup, Button } from '@nexub/react'; export default function Example() { return ( ); } ``` --- # Button Triggers an action or event. Supports multiple variants, sizes, and semantic tones. - Package: `@nexub/react` · Category: Actions · Status: stable - Import: `import { Button } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/button ## When to use - Triggering a primary or secondary action (submit, save, confirm) - Navigating users to another page or step in a flow - Opening a dialog, drawer, or modal overlay - Destructive actions that need a visible, labelled control ## When not to use - Inline text navigation — use a Link instead - Icon-only controls — use IconButton for touch target compliance - Selecting among multiple options — use ToggleGroup or SegmentedControl - Passive information display with no action ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `variant` | `'filled' \| 'tonal' \| 'outlined' \| 'text' \| 'glass' \| 'hero' \| 'subtle' \| 'link' \| 'destructive' \| 'accent'` | `'primary'` | Visual style of the button. `hero` is the marketing-mode main button (gradient, glow, spring lift): a filled button outside `data-mode="marketing"`; one per screen. Deprecated in 8.4, removed in 9.0: the legacy aliases primary (filled), secondary (tonal), outline (outlined) and ghost (text) still work; `npx nexub-migrate --rules button-aliases --write` renames them. | | `size` | `'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl'` | `'md'` | Control height and padding. | | `status` | `'idle' \| 'loading' \| 'success' \| 'error'` | `'idle'` | Async feedback (beta, 1.7.0). `loading` shows a spinner and blocks clicks but keeps focus; `success` draws a check; `error` shakes once. The label stays in flow, so the width holds. | | `loading` | `boolean` | `false` | Alias for `status="loading"`. | | `loadingLabel` | `string` | `'Loading'` | Announced when `status` becomes `loading`. | | `successLabel` | `string` | `'Done'` | Announced on `success`. When set, it also replaces the visible label (with a check) instead of showing the check alone. | | `errorLabel` | `string` | `'Something went wrong'` | Announced on `error`. | | `disabled` | `boolean` | `false` | Disables the button. | | `magnetic` | `boolean` | `false` | 4.3: drifts a few pixels toward the pointer on hover. For one key action per screen. Off for touch and reduced motion. | | `fullWidth` | `boolean` | `false` | Stretches the button to fill its container. | | `leadingIcon` | `React.ReactNode` | | Icon rendered before the label. | | `trailingIcon` | `React.ReactNode` | | Icon rendered after the label. | | `tone` | `'neutral' \| 'info' \| 'success' \| 'warning' \| 'danger'` | | Semantic colour tone — overrides the variant colour with a semantic palette. | | `asChild` | `boolean` | `false` | Merges props onto the immediate child element (Radix Slot). `status` and `loading` have no effect with `asChild`. | ## Example: Default ```tsx import { Button } from '@nexub/react'; export default function Example() { return ; } ``` ## Example: Variants ```tsx import { Button } from '@nexub/react'; export default function Example() { return (
); } ``` ## Example: Sizes ```tsx import { Button } from '@nexub/react'; export default function Example() { return (
); } ``` ## Example: States ```tsx import { Button } from '@nexub/react'; export default function Example() { return (
); } ``` ## Example: Async Drive `status` from the request. Each click here moves to the next status. ```tsx import * as React from 'react'; import { type ButtonStatus, Button } from '@nexub/react'; const NEXT_STATUS: Record = { idle: 'loading', loading: 'success', success: 'error', error: 'idle' }; export default function Example() { const [status, setStatus] = React.useState('idle'); // Clicks are ignored while loading, so loading moves on by itself. React.useEffect(() => { if (status !== 'loading') return; const t = setTimeout(() => setStatus('success'), 1200); return () => clearTimeout(t); }, [status]); return (
status: {status}
); } ``` ## Example: Hero (marketing mode) Inside `data-mode="marketing"` with `@nexub/themes/marketing` loaded. The focus ring sits outside the gradient. ```tsx import { Button } from '@nexub/react'; import { ArrowRight } from '@nexub/icons'; export default function Example() { return (
); } ``` ## Example: Magnetic `magnetic` (4.3): drifts toward the pointer. Use it for one key action per screen. ```tsx import { Button } from '@nexub/react'; export default function Example() { return ; } ``` ## Accessibility - Roles: button - `Space`: Activates the focused button. - `Enter`: Activates the focused button. - `Tab`: Moves focus to the button in document order. - Receives focus in document order; `disabled` removes it from the tab sequence. - Visible focus ring uses `--color-border-focus` and meets WCAG 2.4.7 contrast. - Announces the visible label plus the implicit "button" role. - While loading the button sets `aria-busy` and `aria-disabled` (not `disabled`), so focus stays on it and clicks are ignored. - A button with `status` or `loading` renders a polite `role="status"` region next to it that announces `loadingLabel`, `successLabel` or `errorLabel` as the status changes. - Pair icon-only triggers with `IconButton` for a 44×44 touch target. Related: [icon-button](icon-button.md), [button-group](button-group.md), [link](link.md) --- # Card Surface container for grouping related content. Supports flat, surface, and interactive variants. - Package: `@nexub/react` · Category: Layout · Status: stable - Import: `import { Card } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/card ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `variant` | `'flat' \| 'surface' \| 'interactive' \| 'showcase'` | `'flat'` | `interactive` lifts 2px on hover (spatial spring, elevation 1 → 2), sinks to 0.99 on press and adds a state layer. Use it for cards that are links or buttons. `showcase` is the marketing-mode card (24px corners, soft shadow, hover lift); a flat card outside `data-mode="marketing"`. | | `accent` | `ProductKey \| DivisionKey` | | With `variant="showcase"`: an app- or division-coloured top edge and tint in marketing mode. An app key sets `data-product`, a division key `data-division`. Keys beyond leap, bookub, payub and founderub need `@nexub/themes/products` or `@nexub/themes/divisions`. Only for product-specific content. | | `effect` | `'none' \| 'sheen' \| 'tilt'` | `'none'` | Opt-in. `sheen` is a soft light that follows the pointer, with a brighter rim near the edge. `tilt` (4.3) also leans the card toward the pointer in 3D. Off for touch, reduced motion and reduced transparency. | | `tone` | `ToneValue` | `undefined` | Applies a semantic left-border accent. | | `asChild` | `boolean` | `false` | Merges props onto the immediate child element. | | `surface` | `'solid' \| 'glass'` | `'solid'` | Liquid-glass material treatment — see Foundations → Materials. | | `CardLink` | `AnchorHTMLAttributes & { asChild?: boolean }` | | Put it around the card title to make the whole card one link. Its ::after covers the card and the card shows the focus ring. Give other controls inside the card `relative z-[1]`. Use `asChild` for a router link. | ## Example: Default ```tsx import { Card, Text } from '@nexub/react'; export default function Example() { return (
Card title
Cards group related content on a raised surface.
); } ``` ## Example: Variants ```tsx import { Card, Text } from '@nexub/react'; export default function Example() { return (
Flat Surface Interactive
); } ``` ## Example: Card link The whole card is one link named by its title. The button sits above the link with `relative z-[1]`. ```tsx import * as React from 'react'; import { Card, Heading, CardLink, Text, Button } from '@nexub/react'; export default function Example() { const [starred, setStarred] = React.useState(false); return (
Atlas Updated 2 hours ago
); } ``` ## Example: Sheen Move the pointer over the card. ```tsx import { Card, Heading, Text } from '@nexub/react'; export default function Example() { return (
Pro Everything in Team, plus audit logs.
); } ``` ## Example: Showcase (marketing mode) Product accents on showcase cards, inside `data-mode="marketing"`. ```tsx import { Card } from '@nexub/react'; const products = [ { accent: 'payub', name: 'Payub', line: 'Payroll and HR' }, { accent: 'bookub', name: 'Bookub', line: 'Bookkeeping' }, ] as const; export default function Example() { return (
{products.map((p) => (

{p.name}

{p.line}

))}
); } ``` ## Example: Tilt `effect="tilt"` (4.3): the card leans toward the pointer and the sheen catches the light. Hover with a mouse. ```tsx import { Card } from '@nexub/react'; export default function Example() { return (
{['Revenue', 'Customers'].map((t) => (

{t}

{t === 'Revenue' ? '$68,420' : '1,204'}

))}
); } ``` ## Accessibility - Roles: region (when used as a landmark) - `Tab`: Focuses interactive children. The card itself is never focusable; with a CardLink, the link is. - With a CardLink inside, the focus ring is drawn on the card, not around the title. - Prefer CardLink over wrapping the whole card in ``: the link’s accessible name stays the title instead of every word on the card. - Group related content with a heading inside the Card so AT users can navigate by heading level. Related: [media-card](media-card.md), [radio-card](radio-card.md), [alert](alert.md) --- # Celebrate A short confetti burst for a real win, such as a first payment or finishing onboarding. - Package: `@nexub/react` · Category: Feedback · Status: beta - Import: `import { Celebrate } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/celebrate ## When to use - A rare, real win the user worked for: first payment received, onboarding finished, a goal reached. ## When not to use - Routine saves or every success; use the Button success state or a Toast. - As the only feedback: say what happened in text too. ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `active` (required) | `boolean` | | Bursts each time this goes from false to true. | | `count` | `number` | `28` | Number of pieces. | ## Example: On a win ```tsx 'use client'; import * as React from 'react'; import { Button, Celebrate } from '@nexub/react'; export default function Example() { const [paid, setPaid] = React.useState(false); return (

{paid ? 'Payment sent. Your first one!' : ''}

); } ``` ## Accessibility - Decorative (`aria-hidden`). Announce the win in text, for example in a Toast or a status message. - Hidden under reduced motion. Related: [toast](toast.md), [button](button.md) --- # Chart Toggle A legend whose entries switch series on and off, wrapped around any chart. - Package: `@nexub/react` · Category: Data Display · Status: beta - Import: `import { ChartToggle } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/chart-toggle ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `series` (required) | `ChartSeries[]` | | The same series the chart takes. | | `children` (required) | `(visible: ChartSeries[]) => ReactNode` | | Renders the chart with the series that are on. Colours stay stable. | | `label` | `string` | `'Series'` | Accessible name for the group of toggles. | ## Example: Toggle series ```tsx 'use client'; import { ChartToggle, LineChart } from '@nexub/react'; const data = [ { m: 'May', web: 120, ios: 80, android: 60 }, { m: 'Jun', web: 140, ios: 95, android: 72 }, { m: 'Jul', web: 150, ios: 110, android: 90 }, { m: 'Aug', web: 170, ios: 128, android: 101 }, ]; const series = [{ key: 'web', label: 'Web' }, { key: 'ios', label: 'iOS' }, { key: 'android', label: 'Android' }]; export default function Example() { return ( {(visible) => } ); } ``` ## Accessibility - `Tab / Space`: Move between series and switch one on or off. - Each series is a toggle button with `aria-pressed`. The last visible series cannot be switched off. Related: [bar-chart](bar-chart.md), [line-chart](line-chart.md) --- # Chart Zoom Zoom any chart to part of its range with a two-thumb slider. - Package: `@nexub/react` · Category: Data Display · Status: beta - Import: `import { ChartZoom } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/chart-zoom ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `data` (required) | `T[]` | | The full data. | | `index` (required) | `keyof T` | | The category key; its values label the range. | | `children` (required) | `(slice: T[]) => ReactNode` | | Render the chart for the visible slice. | | `defaultRange` | `[start, end]` | | Starting indexes; the whole range by default. | | `minSpan` | `number` | `2` | Fewest categories shown. | ## Example: Zoom a year of revenue ```tsx 'use client'; import { ChartZoom, LineChart } from '@nexub/react'; const data = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'].map((month, i) => ({ month, revenue: 120 + i * 14 + (i % 3) * 9, })); export default function Example() { return ( {(slice) => ( )} ); } ``` ## Accessibility - `Arrow keys / Home / End`: Move the focused thumb. - Thumbs read "Zoom start: Mar" and "Zoom end: Sep". Charts themselves stay server components; only this wrapper runs on the client. Related: [line-chart](line-chart.md), [bar-chart](bar-chart.md), [chart-toggle](chart-toggle.md) --- # Check List A list with a success tick before each item, for features, plan inclusions and requirements met. - Package: `@nexub/react` · Category: Data Display · Status: stable - Import: `import { CheckList } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/check-list ## When to use - Listing what a plan or feature includes - Confirming requirements that are already met ## When not to use - Tasks the user can tick off: use `Checkbox` - Steps with progress or failures: use `PlanTracker` or `Stepper` ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `items` | `(string \| { label: ReactNode; status?: CheckListStatus })[]` | | Plain-text items. Shorthand for one `CheckListItem` each. 11.3: an object entry sets a status. | | `children` | `ReactNode` | | `CheckListItem`s, for items with markup. Rendered after `items`. | | `CheckListItem children` (required) | `ReactNode` | | The item text. The tick is decorative (hidden from screen readers). | | `CheckListItem status` | `'done' \| 'pending'` | | 11.3: `done` draws the tick, `pending` an empty ring with muted text. Either is read after the text ("Done" / "Pending"). Unset draws the tick with nothing read, as before. | | `CheckListItem statusLabel` | `string` | | 11.3: the words read for `status`, for other languages. | ## Example: From items ```tsx import { CheckList } from '@nexub/react'; export default function Example() { return ; } ``` ## Example: With CheckListItem ```tsx import { CheckList, CheckListItem } from '@nexub/react'; export default function Example() { return ( At least 12 characters One number (0–9) Not used on another account ); } ``` ## Example: Done and pending Setup steps with a status each. ```tsx import { CheckList } from '@nexub/react'; export default function Example() { return ( ); } ``` Related: [plan-tracker](plan-tracker.md) --- # Checkbox Card A checkbox drawn as a whole card: title, description and optional icon. Pick any number. - Package: `@nexub/react` · Category: Form Controls · Status: beta - Import: `import { CheckboxCard } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/checkbox-card ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `title` (required) | `ReactNode` | | The card’s accessible name. | | `description` | `ReactNode` | | Secondary text, exposed as the accessible description. | | `icon` | `ReactNode` | | Leading icon. Turns primary when checked. | | `checked / defaultChecked` | `boolean` | | Controlled or initial state. No indeterminate state. | | `onCheckedChange` | `(checked: boolean) => void` | | Called with a plain boolean. | | `children` | `ReactNode` | | Extra content under the description. Keep it non-interactive. | | `disabled` | `boolean` | `false` | Disables the card. | ## Example: Features Lay checkbox cards out with any grid; there is no group component. ```tsx import { CheckboxCard } from '@nexub/react'; import { Bell, Shield, Zap } from '@nexub/icons'; export default function Example() { return (
Add-ons } title="Alerts" description="Email and push notifications." defaultChecked /> } title="Audit log" description="Keep a year of activity." /> } title="Automations" description="Run rules on new records." />
); } ``` ## Example: Disabled ```tsx import { CheckboxCard } from '@nexub/react'; export default function Example() { return (
); } ``` ## Accessibility - Roles: checkbox - `Tab`: Moves focus to the card. - `Space`: Toggles the card. - The title is the accessible name and the description is the accessible description. - Wrap related cards in a `fieldset` with a `legend` so the set has a name. Related: [checkbox](checkbox.md), [radio-card](radio-card.md), [card](card.md) --- # Checkbox Field A Checkbox with its label, description, aside and error; CheckboxGroupField puts several under one question. - Package: `@nexub/react` · Category: Form Controls · Status: alpha - Import: `import { CheckboxField } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/checkbox-field ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `label` (required) | `ReactNode` | | Names the box; clicking it toggles. | | `description / error` | `ReactNode` | | Help under the label and the error under the row. | | `aside` | `ReactNode` | | At the row end: a price, a count. | | `checked` | `boolean \| 'indeterminate'` | | As Checkbox; `indeterminate` for a parent of a partly picked list. | | `CheckboxGroupField options` | `{ value, label, description?, disabled? }[]` | | The choices, with `value` / `onValueChange` (string[]), `orientation`, `required`, `name` and one `error` for the group. | ## Example: Field ```tsx import { CheckboxField } from '@nexub/react'; export default function Example() { return (
); } ``` ## Example: Group ```tsx import * as React from 'react'; import { CheckboxGroupField } from '@nexub/react'; export default function Example() { const [value, setValue] = React.useState(['email']); return ( ); } ``` ## Accessibility - CheckboxGroupField is a `fieldset` named by its legend; its error describes the group and marks every box invalid. Related: [checkbox](checkbox.md), [switch-field](switch-field.md), [checkbox-card](checkbox-card.md), [fieldset](fieldset.md) --- # Checkbox Binary checkbox input built on Radix UI. - Package: `@nexub/react` · Category: Form Controls · Status: stable - Import: `import { Checkbox } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/checkbox ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `checked` | `boolean` | | The controlled checked state. | | `defaultChecked` | `boolean` | | The initial checked state when uncontrolled. | | `disabled` | `boolean` | | Disables the checkbox when true. | | `required` | `boolean` | | Marks the checkbox as required in a form. | | `onCheckedChange` | `(checked: boolean) => void` | | Callback fired when the checked state changes. | ## Example: Default ```tsx import { Checkbox } from '@nexub/react'; export default function Example() { return ; } ``` ## Example: With label ```tsx import { Checkbox, Label } from '@nexub/react'; export default function Example() { return (
); } ``` ## Example: States ```tsx import { Checkbox, Label } from '@nexub/react'; export default function Example() { return (
); } ``` ## Example: Sizes, invalid and read-only size follows the shared sm / md / lg scale. invalid draws the error border and sets aria-invalid. readOnly stays focusable but cannot change. ```tsx import { Checkbox, Label } from '@nexub/react'; export default function Example() { return (
); } ``` --- # Chip Compact label chip, optionally dismissible. - Package: `@nexub/react` · Category: Labels & Badges · Status: stable - Import: `import { Chip } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/chip ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `onRemove` | `() => void` | | When provided, renders a dismiss button that calls this handler. | | `removeLabel` | `string` | `'Remove'` | Accessible name of the dismiss button (5.2), e.g. "Remove Bug". Use it when several chips sit together. | | `size` | `'sm' \| 'md'` | | Controls chip size. | ## Example: Default ```tsx import { Chip } from '@nexub/react'; export default function Example() { return (
{['Design', 'Engineering', 'Product'].map((c) => {c})}
); } ``` ## Example: Dismissible ```tsx import * as React from 'react'; import { Chip } from '@nexub/react'; export default function Example() { const [chips, setChips] = React.useState(['Design', 'Engineering', 'Product']); return (
{chips.map((c) => ( setChips((prev) => prev.filter((x) => x !== c))}>{c} ))}
); } ``` --- # Citation Numbered source markers for running text, with a hover preview, plus SourceChip and SourceList for the sources under a reply. - Package: `@nexub/react` · Category: AI · Status: beta - Import: `import { Citation } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/citation ## When to use - Assistant answers built from retrieved documents or web results. - SourceList under the reply, so sources are reachable without hovering. ## When not to use - Ordinary links in prose: use Link. - Footnotes in static content, where a numbered list at the end of the page is enough. ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `index` (required) | `number` | | Citation: 1-based number shown in the marker. | | `source` (required) | `CitationSource` | | Citation and SourceChip: `{ title, url, domain?, snippet?, favicon? }`. | | `source.url` (required) | `string` | | Linked only if it is http or https. Anything else (javascript:, data:, relative) renders as plain text. | | `source.domain` | `string` | | Shown instead of the URL’s hostname. | | `source.snippet` | `string` | | Quoted text shown in the hover preview. | | `source.favicon` | `string` | | http(s) image URL. Falls back to the domain’s first letter. | | `SourceList sources` (required) | `CitationSource[]` | | Rendered as SourceChips under a "Sources" heading. Scrolls sideways when narrow, wraps from 480px. | | `messages` | `Partial` | | Citation and SourceList: overrides for `sources` and `source(index)`. | | `safeUrl(url)` | `(url?: string) => string \| undefined` | | The same http(s) check, exported for your own links. | ## Example: Cited answer Hover or focus a number to preview its source. ```tsx import { Citation, SourceList, type CitationSource } from '@nexub/react'; const CITATION_SOURCES: CitationSource[] = [ { title: 'Choosing a heat pump', url: 'https://example.com/guides/heat-pumps', snippet: 'Air-source pumps suit most homes with a garden or outside wall.' }, { title: 'Grants for home heating', url: 'https://example.org/grants', domain: 'example.org' }, { title: 'Running costs compared', url: 'https://example.net/costs' }, ]; export default function Example() { return (

Most homes can use an air-source heat pump. Grants cover part of the cost, and running costs are close to gas .

); } ``` ## Accessibility - Roles: link (marker and chips), region (SourceList, named by its heading) - `Tab`: Focuses a marker and opens its preview. - `Enter`: Opens the source in a new tab. - Markers are named "Source 1: ", not just the number. - The hover preview repeats the marker’s information; nothing in it is only available on hover. - Links open in a new tab with `rel="noopener noreferrer"`; favicons load with `referrerPolicy="no-referrer"`. Related: [message-bubble](message-bubble.md), [hover-card](hover-card.md), [link](link.md) --- # Code Inline code span for technical terms and short code snippets. - Package: `@nexub/react` · Category: Inline Primitives · Status: stable - Import: `import { CodeInline } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/code-inline ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `...props` | `React.HTMLAttributes<HTMLElement>` | | All standard span/code HTML attributes are forwarded. | ## Example: Default ```tsx import { Code } from '@nexub/react'; export default function Example() { return ( <div className="flex gap-2 flex-wrap"> <Code>npm install</Code> <Code>useTheme()</Code> <Code>@nexub/react</Code> </div> ); } ``` ## Example: In prose ```tsx import { Text, Code } from '@nexub/react'; export default function Example() { return ( <Text> Use the <Code>useTheme()</Code> hook to access the current theme from any component. </Text> ); } ``` --- # Collapsible Toggle visibility of content with smooth animation. - Package: `@nexub/react` · Category: Disclosure · Status: stable - Import: `import { Collapsible } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/collapsible ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `Collapsible.Root open` | `boolean` | | Controlled open state. | | `Collapsible.Root defaultOpen` | `boolean` | `false` | Whether the collapsible is open by default (uncontrolled). | | `Collapsible.Root onOpenChange` | `(open: boolean) => void` | | Callback fired when the open state changes. | | `Collapsible.Root disabled` | `boolean` | `false` | Prevents the user from toggling the collapsible. | | `Collapsible.Trigger asChild` | `boolean` | `false` | Merges props onto the immediate child element (Radix Slot). | | `Collapsible.Content forceMount` | `boolean` | `false` | Keeps the content mounted in the DOM even when closed. | | `variant` | `'unstyled' \| 'default'` | `'unstyled'` | 11.5 (Collapsible.Trigger): `default` is a styled full-width row with a chevron that turns when open. | ## Example: Default ```tsx import * as React from 'react'; import { Collapsible, Button } from '@nexub/react'; export default function Example() { const [open, setOpen] = React.useState(false); return ( <Collapsible.Root open={open} onOpenChange={setOpen}> <Collapsible.Trigger asChild> <Button variant="outlined">{open ? 'Hide details' : 'Show details'}</Button> </Collapsible.Trigger> <Collapsible.Content> <div className="pt-3 text-on-surface-variant text-body-sm"> Hidden content revealed on toggle. This section can hold any content. </div> </Collapsible.Content> </Collapsible.Root> ); } ``` ## Example: Controlled ```tsx import * as React from 'react'; import { Collapsible, Button, Switch, Label } from '@nexub/react'; export default function Example() { const [open2, setOpen2] = React.useState(false); return ( <Collapsible.Root open={open2} onOpenChange={setOpen2}> <div className="flex items-center gap-2"> <span className="font-medium text-on-surface text-body-sm">Advanced settings</span> <Collapsible.Trigger asChild> <Button variant="text" size="sm">{open2 ? 'Collapse' : 'Expand'}</Button> </Collapsible.Trigger> </div> <Collapsible.Content> <div className="pt-3 flex flex-col gap-3"> {[ { id: 'notif', label: 'Enable notifications' }, { id: 'autosave', label: 'Auto-save drafts' }, { id: 'tooltips', label: 'Show tooltips' }, ].map(({ id, label }) => ( <div key={id} className="flex items-center gap-2"> <Switch id={id} /> <Label htmlFor={id}>{label}</Label> </div> ))} </div> </Collapsible.Content> </Collapsible.Root> ); } ``` --- # Color Picker Pick a colour from swatches or type a hex, with an optional contrast hint against a background. - Package: `@nexub/react` · Category: Form Controls · Status: alpha - Import: `import { ColorPicker } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/color-picker ## When to use - Brand, label or theme colours from a small palette. - A text or accent colour that must stay readable on a known background (`contrastAgainst`). ## When not to use - Free-form colour mixing (hue, saturation, alpha): not covered. - A few named options where the colour is incidental: use Select or RadioGroup. ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `value / defaultValue` | `string` | `'#000000'` | The colour as `#rrggbb`. | | `onValueChange` | `(hex: string) => void` | | Called with a lowercase `#rrggbb`. | | `swatches` | `Array<string \| { value: string; label?: string }>` | | The colours offered. A `label` is read out instead of the hex. Defaults to neutrals and hues. | | `contrastAgainst` | `string` | | A background hex: shows the WCAG 2.x contrast ratio and whether it passes AA for text (4.5:1). | | `disabled / readOnly / invalid` | `boolean` | | Field states. Read-only stays focusable but does not open. | | `name` | `string` | | A hidden input posts the value with a plain form. | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Height of the trigger. | | `sheet` | `boolean \| 'auto'` | `'auto'` | The popover as a bottom sheet below 768px. | ## Example: Default ```tsx import * as React from 'react'; import { ColorPicker } from '@nexub/react'; export default function Example() { const [color, setColor] = React.useState('#2563eb'); return <ColorPicker aria-label="Label colour" value={color} onValueChange={setColor} />; } ``` ## Example: Contrast hint ```tsx import * as React from 'react'; import { ColorPicker } from '@nexub/react'; export default function Example() { const [color, setColor] = React.useState('#777777'); return <ColorPicker aria-label="Text colour" value={color} onValueChange={setColor} contrastAgainst="#ffffff" />; } ``` ## Example: Named swatches ```tsx import * as React from 'react'; import { ColorPicker } from '@nexub/react'; const swatches = [ { value: '#16a34a', label: 'Done' }, { value: '#d97706', label: 'In review' }, { value: '#dc2626', label: 'Blocked' }, { value: '#64748b', label: 'Backlog' }, ]; export default function Example() { return <ColorPicker aria-label="Status colour" swatches={swatches} defaultValue="#16a34a" />; } ``` ## Accessibility - `Enter / Space`: Opens the popover with focus on the picked swatch. - `Arrow keys`: Move between swatches and pick (six per row). - `Home / End`: First and last swatch. - `Tab`: Moves to the hex field. Enter or leaving it applies the hex. - `Escape`: Closes the popover. - The trigger is a `combobox` named by `aria-label`; its text is the hex. - Swatches are a `radiogroup` with one tab stop. An invalid hex keeps the last colour and marks the field invalid. - The contrast hint is announced politely when it changes. Related: [combobox-field](combobox-field.md), [input](input.md), [popover](popover.md) --- # Combobox Field A labelled, searchable single choice that looks like a Select. For lists longer than about ten options. - Package: `@nexub/react` · Category: Form Controls · Status: alpha - Import: `import { ComboboxField } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/combobox-field ## When to use - One choice from a long list: people, countries, companies, codes. - A list the server searches (`onSearch` with `loading`). ## When not to use - Ten options or fewer: use Select. - Several choices: use MultiSelect. - Free text with suggestions: use Autocomplete. ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `label` (required) | `ReactNode` | | The field label. `ComboboxPicker` is the same control without it (name it with `aria-label`). | | `options` (required) | `ComboboxOption[]` | | `{ value, label, description?, keywords?, disabled?, group? }`. `description` is a second line; `keywords` and `description` are searched too; `group` lists the option under a heading. | | `value / defaultValue` | `string \| null` | | The picked value, `null` for none. | | `onValueChange` | `(value: string \| null) => void` | | Called with the picked value, or `null` from the none option. | | `noneOption` | `string` | | A first option that clears the value, e.g. "No manager". | | `onSearch / loading` | `(text: string) => void / boolean` | | Server search: the list is not filtered here while `onSearch` is set. | | `selectedOption` | `ComboboxOption` | | Labels the value when it is not in `options` (before an async search has run). | | `description / error` | `ReactNode` | | Help and the inline error under the field. `error` marks it invalid. | | `name` | `string` | | A hidden input posts the value with a plain form. Inside `Form`, also picks up the form error. | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Height of the field. | | `sheet` | `boolean \| 'auto'` | `'auto'` | The list as a bottom sheet below 768px. | ## Example: Default ```tsx import * as React from 'react'; import { ComboboxField } from '@nexub/react'; const countries = ['Australia', 'India', 'Indonesia', 'Malaysia', 'New Zealand', 'Philippines', 'Singapore', 'Thailand', 'United Kingdom', 'United States', 'Vietnam'].map((label) => ({ value: label.toLowerCase().replace(/ /g, '-'), label, })); export default function Example() { const [value, setValue] = React.useState<string | null>('singapore'); return ( <div className="w-full max-w-sm"> <ComboboxField label="Country" description="Where the company is registered" options={countries} value={value} onValueChange={setValue} /> </div> ); } ``` ## Example: Groups and a none option ```tsx import { ComboboxField } from '@nexub/react'; const people = [ { value: 'u1', label: 'Aisha Rahman', description: 'Finance lead', keywords: ['aisha@nexub.test'], group: 'Finance' }, { value: 'u2', label: 'Ben Ong', description: 'Accountant', group: 'Finance' }, { value: 'u3', label: 'Chen Wei', description: 'Account executive', group: 'Sales' }, { value: 'u4', label: 'Dana Lee', description: 'On leave', group: 'Sales', disabled: true }, ]; export default function Example() { return ( <div className="w-full max-w-sm"> <ComboboxField label="Manager" noneOption="No manager" options={people} error="Pick who approves leave" /> </div> ); } ``` ## Example: Server search ```tsx import * as React from 'react'; import { ComboboxField, type ComboboxOption } from '@nexub/react'; const companies: ComboboxOption[] = ['Acme Corp', 'Apex Labs', 'Nexub Pte Ltd', 'Zeta Holdings'].map((label, i) => ({ value: `c${i}`, label })); export default function Example() { const [options, setOptions] = React.useState<ComboboxOption[]>([]); const [loading, setLoading] = React.useState(false); const [value, setValue] = React.useState<string | null>('c2'); const timer = React.useRef<ReturnType<typeof setTimeout> | undefined>(undefined); return ( <div className="w-full max-w-sm"> <ComboboxField label="Company" options={options} loading={loading} value={value} onValueChange={setValue} selectedOption={companies.find((o) => o.value === value)} onSearch={(text) => { clearTimeout(timer.current); setLoading(true); timer.current = setTimeout(() => { setOptions(companies.filter((o) => o.label.toLowerCase().includes(text.toLowerCase()))); setLoading(false); }, 300); }} /> </div> ); } ``` ## Accessibility - `Enter / Space / Arrow Down`: Opens the list with focus in the search box. - `Arrow Up / Arrow Down`: Moves through the options. - `Enter`: Picks the highlighted option and closes. - `Escape`: Closes without changing the value. - The trigger is a `combobox` named by the label; the picked option is its text. - Description and error are linked with `aria-describedby`. Related: [select](select.md), [combobox](combobox.md), [autocomplete](autocomplete.md), [form-field](form-field.md) --- # Combobox Command-palette style searchable dropdown built on cmdk. - Package: `@nexub/react` · Category: Form Controls · Status: stable - Import: `import { Combobox } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/combobox ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `Combobox.Root` | `compound` | | Root cmdk command container. | | `Combobox.Input` | `compound` | | Search input that filters the list. | | `Combobox.List` | `compound` | | Scrollable list container for groups and items. | | `Combobox.Group` | `compound` | | Labeled group of items within the list. | | `Combobox.Item` | `compound` | | Individual selectable option. | | `Combobox.Empty` | `compound` | | Content shown when no items match the search query. | | `Combobox.Separator` | `compound` | | Visual separator between groups or items. | ## Example: Default ```tsx import { Combobox } from '@nexub/react'; export default function Example() { return ( <Combobox.Root className="w-65"> <Combobox.Input placeholder="Search…" /> <Combobox.List> <Combobox.Empty>No results found.</Combobox.Empty> <Combobox.Group heading="Frameworks"> <Combobox.Item value="react">React</Combobox.Item> <Combobox.Item value="vue">Vue</Combobox.Item> <Combobox.Item value="angular">Angular</Combobox.Item> <Combobox.Item value="svelte">Svelte</Combobox.Item> </Combobox.Group> </Combobox.List> </Combobox.Root> ); } ``` --- # Command List A search box over a filtered, grouped list you move through with the keyboard. Inline: put it in a Dialog, Sheet, Drawer or page. - Package: `@nexub/react` · Category: Navigation · Status: alpha - Import: `import { CommandList } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/command-list ## When to use - Picking one item from a long list inside a dialog or sheet: move to folder, assign to, jump to. - A search the server answers (`onSearch` with `loading`). ## When not to use - An app-wide launcher opened with Cmd+K: use CommandPalette. - A form field that shows the picked value: use ComboboxField. - Ten choices or fewer: use a RadioGroup or Select. ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `items` (required) | `CommandListItem[]` | | `{ value, label, description?, keywords?, icon?, group?, disabled?, shortcut? }`. `description` and `keywords` are searched too; `group` lists the item under a heading; `shortcut` shows keys at the end of the row. | | `onSelect` | `(value: string, item: CommandListItem) => void` | | Called when an item is picked with Enter or a click. | | `label` | `string` | `'Search'` | Accessible name of the search box and list. | | `placeholder` | `string` | `'Search…'` | The search box placeholder. | | `emptyText` | `ReactNode` | `'No results found.'` | Shown when the search finds nothing. | | `onSearch / loading` | `(text: string) => void / boolean` | | Server search: while `onSearch` is set the list is not filtered here. `loading` shows a busy row. | | `autoFocus` | `boolean` | `true` | Focus the search box on mount. | | `maxHeight` | `string` | `'20rem'` | The list scrolls past this height (any CSS length). | ## Example: Default ```tsx import * as React from 'react'; import { CommandList } from '@nexub/react'; const items = [ { value: 'invoice', label: 'New invoice', group: 'Create', keywords: ['bill'] }, { value: 'customer', label: 'New customer', group: 'Create' }, { value: 'reports', label: 'Reports', description: 'Revenue, cash flow and tax', group: 'Go to' }, { value: 'settings', label: 'Settings', group: 'Go to', shortcut: ['⌘', ','] }, ]; export default function Example() { const [picked, setPicked] = React.useState(''); return ( <div className="flex w-full max-w-sm flex-col gap-2"> <div className="rounded-shape-container border border-outline-variant"> <CommandList items={items} onSelect={setPicked} autoFocus={false} /> </div> <p className="text-body-sm text-on-surface-muted">Picked: {picked || '—'}</p> </div> ); } ``` ## Example: In a dialog ```tsx import * as React from 'react'; import { Button, CommandList, Dialog } from '@nexub/react'; const spaces = ['Finance', 'Marketing', 'Operations', 'People', 'Product', 'Sales'].map((s) => ({ value: s.toLowerCase(), label: s })); export default function Example() { const [open, setOpen] = React.useState(false); const [space, setSpace] = React.useState('Finance'); return ( <Dialog.Root open={open} onOpenChange={setOpen}> <Dialog.Trigger asChild> <Button variant="outlined">Move to {space}…</Button> </Dialog.Trigger> <Dialog.Content> <Dialog.Title>Move to space</Dialog.Title> <div className="mt-4"> <CommandList label="Spaces" items={spaces} onSelect={(_, item) => { setSpace(item.label); setOpen(false); }} /> </div> </Dialog.Content> </Dialog.Root> ); } ``` ## Example: Server search ```tsx import * as React from 'react'; import { CommandList, type CommandListItem } from '@nexub/react'; const all = ['Acme Corp', 'Apex Labs', 'Blue Harbor', 'Cobalt Systems', 'Delta Freight', 'Evergreen Foods']; export default function Example() { const [items, setItems] = React.useState<CommandListItem[]>([]); const [loading, setLoading] = React.useState(false); const timer = React.useRef<ReturnType<typeof setTimeout>>(undefined); return ( <div className="w-full max-w-sm rounded-shape-container border border-outline-variant"> <CommandList label="Companies" autoFocus={false} items={items} loading={loading} onSearch={(text) => { clearTimeout(timer.current); setLoading(true); timer.current = setTimeout(() => { const q = text.toLowerCase(); setItems(all.filter((c) => c.toLowerCase().includes(q)).map((c) => ({ value: c, label: c }))); setLoading(false); }, 400); }} /> </div> ); } ``` ## Accessibility - `Arrow Up / Arrow Down`: Moves the highlight; wraps at the ends. - `Home / End`: Moves to the first or last item. - `Enter`: Picks the highlighted item. - Focus stays in the search box, a `combobox` that points at the highlighted `option` with `aria-activedescendant`. - Group headings name their groups; disabled items are skipped and marked `aria-disabled`. - While loading, the list has `aria-busy`. Related: [command-palette](command-palette.md), [combobox](combobox.md), [combobox-field](combobox-field.md), [dialog](dialog.md), [drawer](drawer.md) --- # Command Palette A searchable command menu in a modal dialog (cmdk), with nested pages, recents and an optional Cmd+K shortcut. - Package: `@nexub/react` · Category: Navigation · Status: stable - Import: `import { CommandPalette } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/command-palette ## When to use - Power users jumping to pages or running actions by name - A global Cmd+K entry point in an app ## When not to use - Filtering a single list on the page: use `SearchInput` or `Combobox` - The only way to reach an action: keep it in the visible UI too ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `open / onOpenChange` | `boolean / (open: boolean) => void` | | Controlled open state. | | `defaultOpen` | `boolean` | | Uncontrolled initial open state. | | `shortcut` | `string` | | A letter that toggles the palette with Cmd (macOS) or Ctrl anywhere on the page, e.g. `'k'`. | | `label` | `string` | | Accessible name of the dialog. Defaults to the localised "Command palette". | | `shouldFilter` | `boolean` | | Set `false` when the items are already filtered, e.g. async search results. | | `loading` | `boolean` | | Shows a loading row and hides `Empty`. | | `pages / defaultPages / onPagesChange` | `string[]` | | The open page stack (ids of `CommandPalette.Page`), deepest last. Empty = the root page. | | `recentKey / recentLimit` | `string / number` | | Opt-in recents: the last picks on the root page are kept in localStorage under this key and shown while the query is empty. | | `scrollLock` | `'class' \| 'style'` | | `'class'` (strict-CSP safe) or Radix's style-tag lock. | | `CommandPalette.Input / List / Empty / Group / Separator` | `compound` | | Search field, results list, no-results row, a headed group (`heading`), and a decorative divider. | | `CommandPaletteItem page` | `string` | | Opens the `CommandPalette.Page` with this id when selected. Other props are cmdk `Command.Item` props (`onSelect`, `value`, `keywords`, `disabled`). | | `CommandPalettePage id / title` | `string` | | Content shown only while this page is on top. No `id` = the root page; `title` shows in the input breadcrumb. Backspace on an empty query goes back. | ## Example: Default ```tsx import * as React from 'react'; import { Button, CommandPalette } from '@nexub/react'; export default function Example() { const [open, setOpen] = React.useState(false); return ( <> <Button variant="outlined" onClick={() => setOpen(true)}>Open command palette</Button> <CommandPalette.Root open={open} onOpenChange={setOpen}> <CommandPalette.Input placeholder="Type a command or search…" /> <CommandPalette.List> <CommandPalette.Empty>No results found.</CommandPalette.Empty> <CommandPalette.Group heading="Go to"> <CommandPalette.Item onSelect={() => setOpen(false)}>Dashboard</CommandPalette.Item> <CommandPalette.Item onSelect={() => setOpen(false)}>Reports</CommandPalette.Item> <CommandPalette.Item onSelect={() => setOpen(false)}>Settings</CommandPalette.Item> </CommandPalette.Group> <CommandPalette.Separator /> <CommandPalette.Group heading="Actions"> <CommandPalette.Item onSelect={() => setOpen(false)}>Create project</CommandPalette.Item> <CommandPalette.Item onSelect={() => setOpen(false)}>Invite a teammate</CommandPalette.Item> </CommandPalette.Group> </CommandPalette.List> </CommandPalette.Root> </> ); } ``` ## Example: Nested pages ```tsx import * as React from 'react'; import { Button, CommandPalette } from '@nexub/react'; export default function Example() { const [open, setOpen] = React.useState(false); return ( <> <Button variant="outlined" onClick={() => setOpen(true)}>Switch project</Button> <CommandPalette.Root open={open} onOpenChange={setOpen}> <CommandPalette.Input placeholder="Search…" /> <CommandPalette.List> <CommandPalette.Empty>No results found.</CommandPalette.Empty> <CommandPalette.Page> <CommandPalette.Item page="projects">Projects…</CommandPalette.Item> <CommandPalette.Item onSelect={() => setOpen(false)}>Export report</CommandPalette.Item> </CommandPalette.Page> <CommandPalette.Page id="projects" title="Projects"> <CommandPalette.Item onSelect={() => setOpen(false)}>Billing service</CommandPalette.Item> <CommandPalette.Item onSelect={() => setOpen(false)}>Mobile app</CommandPalette.Item> </CommandPalette.Page> </CommandPalette.List> </CommandPalette.Root> </> ); } ``` ## Accessibility - Roles: dialog, combobox, listbox, option - `Cmd/Ctrl + shortcut`: Toggles the palette when `shortcut` is set. - `Arrow Up / Down`: Moves through items (wraps). - `Enter`: Runs the highlighted item. - `Backspace`: On an empty query, goes back a page. - `Escape`: Closes the palette. - Focus moves to the input on open and returns to the previously focused element on close. Related: [keyboard-shortcut](keyboard-shortcut.md), [dialog](dialog.md), [search-input](search-input.md) --- # Comparison Bar Two values on one split bar, with the numbers always shown as text. - Package: `@nexub/react` · Category: Data Display · Status: alpha - Import: `import { ComparisonBar } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/comparison-bar ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `label` (required) | `string` | | What is compared. | | `left` (required) | `{ label: string; value: number; color?: CategoryColor }` | | The side at the inline start. | | `right` (required) | `{ label: string; value: number; color?: CategoryColor }` | | The side at the inline end. | | `valueFormat` | `(value: number) => string` | | Formats both values, on screen and in the text alternative. | | `size` | `'sm' \| 'md'` | `'md'` | Bar height and type size. | | `showValues` | `boolean` | `true` | The two values and the label above the bar. | | `showLabels` | `boolean` | `true` | The two side labels under the bar. Turn off for all but one bar in a group. | | `highlight` | `'higher' \| 'none'` | `'higher'` | The larger side takes the accent and the other is muted. A side with a `color` keeps it. | | `aria-label` | `string` | | Replaces the text alternative built from the props. | ## Example: Default ```tsx import { ComparisonBar } from '@nexub/react'; export default function Example() { return ( <div className="w-full max-w-sm"> <ComparisonBar label="Goals" left={{ label: 'Team A', value: 3 }} right={{ label: 'Team B', value: 1 }} /> </div> ); } ``` ## Example: A group of comparisons ```tsx import { ComparisonBar } from '@nexub/react'; const percent = (n: number) => `${n}%`; const stats: [string, number, number, ((n: number) => string)?][] = [ ['Possession', 58, 42, percent], ['Shots', 14, 9], ['Shots on target', 6, 6], ['Corners', 3, 7], ]; export default function Example() { return ( <div className="flex w-full max-w-sm flex-col gap-4"> {stats.map(([label, a, b, format], i) => ( <ComparisonBar key={label} label={label} left={{ label: 'Team A', value: a, color: 'blue' }} right={{ label: 'Team B', value: b, color: 'amber' }} valueFormat={format} showLabels={i === stats.length - 1} /> ))} </div> ); } ``` Related: [progress](progress.md), [description-list](description-list.md) --- # Container Centres content at a maximum width with responsive side padding. - Package: `@nexub/react` · Category: Layout · Status: stable - Import: `import { Container } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/container ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `size` | `'sm' \| 'md' \| 'lg' \| 'xl' \| '2xl' \| 'nexub' \| 'marketing' \| 'prose'` | | Maximum width, from the `--container-*` tokens. `prose` is 65ch for reading. | | `paddingX` | `boolean` | | Responsive horizontal padding (16, 24, 32 px). | | `asChild` | `boolean` | | Apply the container classes to the child element (e.g. `<main>`) instead of a `<div>`. | ## Example: Default ```tsx import { Container, Text } from '@nexub/react'; export default function Example() { return ( <div className="w-full bg-surface-container-low py-4"> <Container size="sm" className="rounded-shape-container bg-surface py-4"> <Text size="body-sm">Centred at up to 640 px, with responsive side padding.</Text> </Container> </div> ); } ``` ## Example: Prose width ```tsx import { Container, Heading, Text } from '@nexub/react'; export default function Example() { return ( <Container size="prose" paddingX={false}> <Heading level={3}>Release notes</Heading> <Text size="body-sm" tone="secondary" className="mt-2"> The prose size caps lines at about 65 characters, a comfortable measure for reading long text. </Text> </Container> ); } ``` Related: [section](section.md), [box](box.md), [stack](stack.md) --- # Context Menu A menu that opens at the pointer on right-click (or long-press), built on Radix. - Package: `@nexub/react` · Category: Overlays · Status: stable - Import: `import { ContextMenu } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/context-menu ## When to use - Shortcuts to actions on an item: rename, duplicate, delete ## When not to use - The only way to reach an action: right-click is hard to discover and needs a visible alternative, such as a `DropdownMenu` ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `ContextMenu.Root` | `compound` | | Holds the open state (`onOpenChange`, `modal`). | | `ContextMenu.Trigger` | `compound` | | The area that opens the menu on right-click. Use `asChild` to make your element the area. | | `ContextMenu.Portal / Content` | `compound` | | Renders the floating menu in a portal. | | `ContextMenu.Item` | `compound` | | An action (`onSelect`, `disabled`). | | `ContextMenu.CheckboxItem / RadioGroup / RadioItem` | `compound` | | Toggle and single-choice items (`checked`, `onCheckedChange`; `value`, `onValueChange`). | | `ContextMenu.Label / Group / Separator` | `compound` | | Section heading, grouping and divider. | | `ContextMenu.Sub / SubTrigger / SubContent` | `compound` | | A nested submenu. | ## Example: Default ```tsx import { ContextMenu } from '@nexub/react'; export default function Example() { return ( <ContextMenu.Root> <ContextMenu.Trigger className="flex h-32 w-64 select-none items-center justify-center rounded-shape-container border-2 border-dashed border-outline-variant text-body-sm text-on-surface-muted"> Right-click here </ContextMenu.Trigger> <ContextMenu.Portal> <ContextMenu.Content> <ContextMenu.Item>Rename</ContextMenu.Item> <ContextMenu.Item>Duplicate</ContextMenu.Item> <ContextMenu.Item>Copy link</ContextMenu.Item> <ContextMenu.Separator /> <ContextMenu.Item>Move to trash</ContextMenu.Item> </ContextMenu.Content> </ContextMenu.Portal> </ContextMenu.Root> ); } ``` ## Accessibility - Roles: menu, menuitem, menuitemcheckbox, menuitemradio - `Shift + F10 / Menu key`: Opens the menu from the focused trigger. - `Arrow Up / Down`: Moves between items. - `Enter / Space`: Activates the item. - `Escape`: Closes the menu. Related: [dropdown-menu](dropdown-menu.md), [menubar](menubar.md) --- # Countdown Time left to a deadline, as a chip or inline text. Stays right after the tab was in the background. - Package: `@nexub/react` · Category: Feedback · Status: alpha - Import: `import { Countdown } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/countdown ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `to` (required) | `number \| Date` | | The deadline: a Date or milliseconds since the epoch. Not a duration. | | `format` | `'m:ss' \| 'h:mm:ss' \| 'auto'` | `'auto'` | `auto` shows hours only from one hour up. | | `variant` | `'chip' \| 'inline'` | `'chip'` | A small badge, or plain text in the surrounding font. | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Size of the chip. | | `tone` | `'auto' \| 'neutral' \| 'warning' \| 'danger'` | `'auto'` | `auto` turns warning under `warnAt` and danger under `dangerAt`. | | `warnAt / dangerAt` | `number` | `60 / 10` | Thresholds for `tone="auto"`, in seconds. | | `onExpire` | `() => void` | | Called once when the deadline is reached. | | `now` | `() => number` | `Date.now` | The clock. Inject one for tests and static previews. | ## Example: Hold timer ```tsx import * as React from 'react'; import { Button, Countdown } from '@nexub/react'; export default function Example() { // The deadline is set after mount, so the server and the first paint agree. The chip is // always rendered (0 until then), so nothing moves when the time arrives. const [deadline, setDeadline] = React.useState(0); const [expired, setExpired] = React.useState(false); const start = () => { setExpired(false); setDeadline(Date.now() + 75_000); }; React.useEffect(start, []); return ( <div className="flex flex-wrap items-center gap-3"> <span className="text-body-md text-on-surface">{expired ? 'The hold has ended' : 'Held for you'}</span> <Countdown to={deadline} onExpire={() => deadline > 0 && setExpired(true)} /> <Button size="sm" variant="outlined" onClick={start}> Restart </Button> </div> ); } ``` ## Example: Resend button with useCountdown ```tsx import * as React from 'react'; import { Button, useCountdown } from '@nexub/react'; export default function Example() { // 0 until the first click: nothing reads the clock while rendering. const [deadline, setDeadline] = React.useState(0); const { seconds, expired } = useCountdown(deadline); const waiting = deadline > 0 && !expired; return ( <Button variant="outlined" disabled={waiting} onClick={() => setDeadline(Date.now() + 30_000)}> {waiting ? <span className="tabular-nums">Resend code in 0:{String(seconds).padStart(2, '0')}</span> : 'Send code'} </Button> ); } ``` ## Accessibility - The digits are a `timer` that is not read on every tick. A separate polite region speaks each whole minute, then at 30, 10 and 5 seconds, and when time is up. - The server and the first paint show a placeholder of the same width; the time appears after mount, so there is no hydration mismatch. - `useCountdown(to, { now, onExpire })` returns `{ remainingMs, seconds, expired, ready }` for custom displays. Related: [badge](badge.md), [otp-input](otp-input.md), [progress](progress.md) --- # Country Badge A pill with a country flag and its name or code. - Package: `@nexub/react` · Category: Labels & Badges · Status: stable - Import: `import { CountryBadge } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/country-badge ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `code` | `string` | | ISO 3166-1 alpha-2 country code, e.g. `SG`. | | `label` | `string` | | Text after the flag. Defaults to `code`. | | `size` | `'sm' \| 'md' \| 'lg'` | | Size of the pill and flag. | ## Example: Default ```tsx import { CountryBadge } from '@nexub/react'; export default function Example() { return ( <div className="flex flex-wrap gap-2"> <CountryBadge code="SG" label="Singapore" /> <CountryBadge code="DE" label="Germany" /> <CountryBadge code="BR" label="Brazil" /> </div> ); } ``` ## Example: Sizes ```tsx import { CountryBadge } from '@nexub/react'; export default function Example() { return ( <div className="flex flex-wrap items-center gap-2"> <CountryBadge code="JP" size="sm" /> <CountryBadge code="JP" size="md" /> <CountryBadge code="JP" size="lg" /> </div> ); } ``` Related: [flag](flag.md), [badge](badge.md) --- # Currency Select A searchable ISO 4217 currency picker built from Intl: code, name and symbol. Also sits next to a MoneyInput. - Package: `@nexub/react` · Category: Form Controls · Status: alpha - Import: `import { CurrencySelect } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/currency-select ## When to use - Picking the currency of a price, an invoice or an account. - Letting people change the currency next to an amount (`MoneyInput currencySlot`). ## When not to use - Two or three fixed currencies: use SegmentedControl or Select. - Showing an amount: use Amount. ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `value / defaultValue` | `string \| null` | | The ISO 4217 code, e.g. `"USD"`. | | `onValueChange` | `(code: string \| null) => void` | | Called with the picked code. | | `currencies` | `string[]` | | Only these codes, in this order. Default: every code the browser knows (`Intl.supportedValuesOf`). | | `priority / priorityLabel / restLabel` | `string[] / string / string` | | Codes listed first; with `priorityLabel`, under that heading and the rest under `restLabel`. | | `locale` | `string` | | BCP 47 locale for names and symbols. Defaults to the user's. | | `name` | `string` | | A hidden input posts the code with a plain form. | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Height of the field. | | `sheet` | `boolean \| 'auto'` | `'auto'` | The list as a bottom sheet below 768px. | ## Example: Default ```tsx import * as React from 'react'; import { CurrencySelect } from '@nexub/react'; export default function Example() { const [currency, setCurrency] = React.useState<string | null>('EUR'); return ( <div className="w-full max-w-xs"> <CurrencySelect aria-label="Currency" value={currency} onValueChange={setCurrency} /> </div> ); } ``` ## Example: Labelled field `CurrencyField` adds `label`, `description` and `error`, as ComboboxField. ```tsx import * as React from 'react'; import { CurrencyField } from '@nexub/react'; export default function Example() { const [currency, setCurrency] = React.useState<string | null>('USD'); return ( <div className="w-full max-w-sm"> <CurrencyField label="Billing currency" description="Invoices are issued in this currency" priority={['USD', 'EUR', 'GBP', 'MYR', 'SGD']} priorityLabel="Common" restLabel="All currencies" value={currency} onValueChange={setCurrency} /> </div> ); } ``` ## Example: Next to an amount MoneyInput `currencySlot` puts the picker before the amount. ```tsx import * as React from 'react'; import { CurrencySelect, MoneyInput } from '@nexub/react'; export default function Example() { const [currency, setCurrency] = React.useState('EUR'); const [amount, setAmount] = React.useState<number | null>(1250); return ( <div className="w-full max-w-md"> <MoneyInput aria-label="Amount" currency={currency} value={amount} onValueChange={setAmount} currencySlot={<CurrencySelect aria-label="Currency" value={currency} onValueChange={(c) => c && setCurrency(c)} />} /> </div> ); } ``` ## Accessibility - `Enter / Space / Arrow Down`: Opens the list with focus in the search box. - `Type`: Finds by code, name or symbol. - `Enter`: Picks the highlighted currency. - Built on ComboboxField: the trigger is a `combobox` named by the label. - `currencyOptions(locale)` returns the same list for your own ComboboxField. Related: [combobox-field](combobox-field.md), [money-input](money-input.md), [amount](amount.md) --- # Data Table Feature-rich data table with sorting and row selection powered by TanStack Table. - Package: `@nexub/react` · Category: Data Display · Status: stable - Import: `import { DataTable } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/data-table ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `columns` (required) | `DataTableColumn<TData>[]` | | TanStack Table column definitions (`DataTableColumn` is exported from @nexub/react). Set `meta: { align: 'end' }` for numeric columns; headers, sort buttons and cells follow it. | | `data` (required) | `TData[]` | | Array of row data objects to render. | | `getSubRows` | `(row, index) => TData[] \| undefined` | | Nested rows (a tree table). The first column gets an expand toggle (`aria-expanded`) and indents each level; sorting sorts within each level. | | `expanded / defaultExpanded / onExpandedChange` | `ExpandedState` | | Expanded rows by row id (see `getRowId`), or `true` for all. | | `onRowOrderChange` | `(data: TData[]) => void` | | Adds a handle column: drag rows, or Alt+ArrowUp/Down on a handle. Hidden while a column is sorted. | | `getRowLabel` | `(row) => string` | | Names a row in "Move ‹label›" and the move announcements. | | `caption` | `ReactNode` | | Names the table for assistive tech (and its scroll region). Shown below the table; add `captionHidden` to keep it screen-reader only. | | `enableSorting` | `boolean` | `false` | Click a header to sort; Shift+click adds more columns, numbered 1, 2… (5.3). | | `enableRowSelection` | `boolean` | `false` | Turns on row selection state. | | `selectionColumn` | `boolean` | `true` | With `enableRowSelection`: a checkbox column, select-page in its header, and "Select all N" across pages (on by default from 6.0). `false` keeps selection without the column. | | `rowSelection / onRowSelectionChange` | `Record<string, boolean>` | | Controlled selection keyed by row id (5.3). | | `getRowId` | `(row: TData, index: number) => string` | | Stable row ids for selection; defaults to the row index (5.3). | | `bulkActions` | `(rows: TData[], clear: () => void) => ReactNode` | | A floating bar while rows are selected, with the count, your actions and a clear button (5.3). | | `density / defaultDensity / onDensityChange` | `'comfortable' \| 'compact'` | `'comfortable'` | Row height (5.3). | | `columnVisibility / onColumnVisibilityChange` | `Record<string, boolean>` | | Which columns show, keyed by column id (5.3). | | `viewOptions` | `boolean` | `false` | A "View" menu above the table for density and column visibility (5.3). | | `toolbar` | `ReactNode` | | Content at the start of the row above the table, e.g. filters (5.3). | | `enableColumnResizing` | `boolean` | `false` | Drag a header edge to resize (5.4). The handle is focusable: Arrow keys resize by 16px, double-click resets. | | `columnSizing / onColumnSizingChange` | `Record<string, number>` | | Column widths in px, keyed by column id (5.4). | | `enableColumnReordering` | `boolean` | `false` | Drag headers to reorder, or Alt+Arrow on a focused header; the move is announced (5.4). | | `columnOrder / onColumnOrderChange` | `string[]` | | Column ids in display order (5.4). | | `columnPinning / onColumnPinningChange` | `{ left?: string[]; right?: string[] }` | | Columns that stay in view while the rest scroll sideways (5.4). The selection column pins with them. | | `maxHeight` | `number \| string` | | Caps the height: rows scroll and the header sticks (5.4). | | `grid` | `boolean` | `false` | ARIA grid keyboard model for tables whose cells hold actions (5.8): the table is one tab stop; Arrow keys move between cells and the controls in them, Home/End to the row ends, Ctrl+Home/End to the corners. | | `DataTableVirtual` | `import from '@nexub/react/DataTableVirtual'` | | Same props plus `maxHeight` (required), `estimateRowHeight` and `overscan`: renders only the rows in view, for thousands of rows. Needs `@tanstack/react-virtual` installed (5.4). No pagination. | | `pagination.pageSize` | `number` | `20` | Rows per page; pagination is on when `pagination` is set. | ## Example: Default ```tsx import { DataTable } from '@nexub/react'; export default function Example() { const data = [ { name: 'Alice Brown', email: 'alice@example.com', plan: 'Pro', status: 'Active' }, { name: 'Bob Carter', email: 'bob@example.com', plan: 'Free', status: 'Pending' }, { name: 'Carol Davis', email: 'carol@example.com', plan: 'Pro', status: 'Inactive' }, { name: 'Dave Evans', email: 'dave@example.com', plan: 'Enterprise', status: 'Active' }, ]; const columns = [ { accessorKey: 'name', header: 'Name' }, { accessorKey: 'email', header: 'Email' }, { accessorKey: 'plan', header: 'Plan' }, { accessorKey: 'status', header: 'Status' }, ]; return ( <div className="w-full max-w-150"> <DataTable columns={columns} data={data} /> </div> ); } ``` ## Example: With sorting ```tsx import { DataTable } from '@nexub/react'; export default function Example() { const data = [ { name: 'Alice Brown', email: 'alice@example.com', plan: 'Pro', status: 'Active' }, { name: 'Bob Carter', email: 'bob@example.com', plan: 'Free', status: 'Pending' }, { name: 'Carol Davis', email: 'carol@example.com', plan: 'Pro', status: 'Inactive' }, { name: 'Dave Evans', email: 'dave@example.com', plan: 'Enterprise', status: 'Active' }, ]; const columns = [ { accessorKey: 'name', header: 'Name' }, { accessorKey: 'email', header: 'Email' }, { accessorKey: 'plan', header: 'Plan' }, { accessorKey: 'status', header: 'Status' }, ]; return ( <div className="w-full max-w-150"> <DataTable columns={columns} data={data} enableSorting /> </div> ); } ``` ## Example: Selection, bulk actions and view menu Select rows with the checkbox column; the bar at the bottom acts on them. The View menu switches density and hides columns. ```tsx 'use client'; import * as React from 'react'; import { Button, DataTable, type DataTableColumn } from '@nexub/react'; interface Invoice { id: string; customer: string; status: string; amount: number; } const invoices: Invoice[] = [ { id: 'INV-2041', customer: 'Acme', status: 'Overdue', amount: 1200 }, { id: 'INV-2042', customer: 'Globex', status: 'Paid', amount: 860 }, { id: 'INV-2043', customer: 'Initech', status: 'Draft', amount: 430 }, { id: 'INV-2044', customer: 'Umbrella', status: 'Overdue', amount: 2150 }, { id: 'INV-2045', customer: 'Hooli', status: 'Paid', amount: 990 }, ]; const columns: DataTableColumn<Invoice>[] = [ { accessorKey: 'id', header: 'Invoice' }, { accessorKey: 'customer', header: 'Customer' }, { accessorKey: 'status', header: 'Status' }, { accessorKey: 'amount', header: 'Amount', meta: { align: 'end' } }, ]; export default function Example() { const [selection, setSelection] = React.useState<Record<string, boolean>>({ 'INV-2041': true, 'INV-2044': true }); return ( <div className="w-full max-w-160"> <DataTable caption="Invoices" captionHidden columns={columns} data={invoices} getRowId={(r) => r.id} enableSorting enableRowSelection rowSelection={selection} onRowSelectionChange={setSelection} viewOptions bulkActions={(rows, clear) => ( <> <Button size="sm" variant="outlined" onClick={clear}> Send reminders ({rows.length}) </Button> <Button size="sm" variant="destructive" onClick={clear}> Void </Button> </> )} /> </div> ); } ``` ## Example: Resize, reorder and pin Drag header edges to resize and headers to reorder (or Alt+Arrow). Invoice stays pinned while the rest scroll; the header sticks within `maxHeight`. ```tsx 'use client'; import { DataTable, type DataTableColumn } from '@nexub/react'; interface Invoice { id: string; customer: string; region: string; owner: string; status: string; amount: number; } const invoices: Invoice[] = Array.from({ length: 30 }, (_, i) => ({ id: `INV-${2041 + i}`, customer: ['Acme', 'Globex', 'Initech', 'Umbrella', 'Hooli'][i % 5]!, region: ['EMEA', 'APAC', 'Americas'][i % 3]!, owner: ['Ana', 'Ben', 'Chen', 'Dev'][i % 4]!, status: ['Paid', 'Overdue', 'Draft'][i % 3]!, amount: 400 + ((i * 137) % 2000), })); const columns: DataTableColumn<Invoice>[] = [ { accessorKey: 'id', header: 'Invoice', size: 120 }, { accessorKey: 'customer', header: 'Customer', size: 160 }, { accessorKey: 'region', header: 'Region', size: 140 }, { accessorKey: 'owner', header: 'Owner', size: 140 }, { accessorKey: 'status', header: 'Status', size: 140 }, { accessorKey: 'amount', header: 'Amount', size: 120, meta: { align: 'end' } }, ]; export default function Example() { return ( <div className="w-full max-w-160"> <DataTable caption="Invoices" captionHidden columns={columns} data={invoices} enableColumnResizing enableColumnReordering columnPinning={{ left: ['id'] }} maxHeight={320} /> </div> ); } ``` ## Example: 10,000 rows (DataTableVirtual) `import { DataTableVirtual } from '@nexub/react/DataTableVirtual'` and install `@tanstack/react-virtual`. Only the rows in view are rendered. ```tsx 'use client'; import type { DataTableColumn } from '@nexub/react'; import { DataTableVirtual } from '@nexub/react/DataTableVirtual'; interface Event { id: number; name: string; user: string; at: string; } const events: Event[] = Array.from({ length: 10_000 }, (_, i) => ({ id: i + 1, name: ['sign_in', 'export', 'invite', 'upgrade'][i % 4]!, user: `user${(i * 7919) % 997}@example.com`, at: new Date(Date.UTC(2026, 10, 1) + i * 60_000).toISOString().slice(0, 16).replace('T', ' '), })); const columns: DataTableColumn<Event>[] = [ { accessorKey: 'id', header: '#', meta: { align: 'end' } }, { accessorKey: 'name', header: 'Event' }, { accessorKey: 'user', header: 'User' }, { accessorKey: 'at', header: 'Time (UTC)' }, ]; export default function Example() { return ( <div className="w-full max-w-160"> <DataTableVirtual caption="Audit log" captionHidden columns={columns} data={events} maxHeight={360} enableSorting /> </div> ); } ``` ## Example: Tree rows `getSubRows` nests rows: the first column gets an expand toggle and indents each level. With pages, a parent and its children stay on one page. ```tsx 'use client'; import { DataTable, type DataTableColumn } from '@nexub/react'; type Account = { name: string; owner: string; arr: number; children?: Account[] }; const data: Account[] = [ { name: 'Acme Group', owner: 'Ada', arr: 420000, children: [ { name: 'Acme EU', owner: 'Grace', arr: 180000, children: [{ name: 'Acme Berlin', owner: 'Grace', arr: 60000 }] }, { name: 'Acme US', owner: 'Alan', arr: 240000 }, ], }, { name: 'Globex', owner: 'Linus', arr: 95000 }, ]; const columns: DataTableColumn<Account>[] = [ { accessorKey: 'name', header: 'Account' }, { accessorKey: 'owner', header: 'Owner' }, { accessorKey: 'arr', header: 'ARR', meta: { align: 'end' }, cell: ({ getValue }) => new Intl.NumberFormat('en', { style: 'currency', currency: 'USD', maximumFractionDigits: 0 }).format(getValue<number>()), }, ]; export default function Example() { return ( <DataTable caption="Accounts by region" captionHidden columns={columns} data={data} getSubRows={(row) => row.children} getRowId={(row) => row.name} defaultExpanded={{ 'Acme Group': true }} /> ); } ``` ## Example: Export CSV `toCSV(rows, columns)` quotes and escapes per RFC 4180 and neutralises cells that start like a spreadsheet formula. Pass what the person sees. ```tsx 'use client'; import { Button, DataTable, toCSV, type DataTableColumn } from '@nexub/react'; type Invoice = { id: string; customer: string; amount: number }; const data: Invoice[] = [ { id: 'INV-1042', customer: 'Acme, Inc.', amount: 1200 }, { id: 'INV-1043', customer: 'Globex', amount: 860 }, ]; const columns: DataTableColumn<Invoice>[] = [ { accessorKey: 'id', header: 'Invoice' }, { accessorKey: 'customer', header: 'Customer' }, { accessorKey: 'amount', header: 'Amount', meta: { align: 'end' } }, ]; function download() { const csv = toCSV(data, [ { header: 'Invoice', value: 'id' }, { header: 'Customer', value: 'customer' }, { header: 'Amount', value: 'amount' }, ]); const url = URL.createObjectURL(new Blob([csv], { type: 'text/csv;charset=utf-8' })); const a = Object.assign(document.createElement('a'), { href: url, download: 'invoices.csv' }); a.click(); URL.revokeObjectURL(url); } export default function Example() { return ( <DataTable caption="Invoices" captionHidden columns={columns} data={data} toolbar={<Button variant="outlined" size="sm" onClick={download}>Export CSV</Button>} /> ); } ``` ## Example: Footer and column filters `footer` on a column adds a totals row; a render function gets the table, so a sum can follow the filtered rows. `meta.filter` (`text`, `select` or `number-range`) adds a filter button to the header. Control it with `columnFilters` / `onColumnFiltersChange`; `manualFiltering` leaves the rows to the server. ```tsx import { DataTable, type DataTableColumn } from '@nexub/react'; type Invoice = { id: string; customer: string; status: string; amount: number }; const data: Invoice[] = [ { id: 'INV-1042', customer: 'Acme', status: 'Paid', amount: 1200 }, { id: 'INV-1043', customer: 'Globex', status: 'Due', amount: 860 }, { id: 'INV-1044', customer: 'Initech', status: 'Paid', amount: 430 }, { id: 'INV-1045', customer: 'Umbrella', status: 'Overdue', amount: 2150 }, ]; const money = (n: number) => new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', maximumFractionDigits: 0 }).format(n); const columns: DataTableColumn<Invoice>[] = [ { accessorKey: 'customer', header: 'Customer', footer: 'Total', meta: { filter: 'text' } }, { accessorKey: 'status', header: 'Status', meta: { filter: 'select' } }, { accessorKey: 'amount', header: 'Amount', cell: ({ getValue }) => money(getValue<number>()), // The filtered rows, so the total follows the filters. footer: ({ table }) => money(table.getFilteredRowModel().rows.reduce((sum, r) => sum + r.original.amount, 0)), meta: { align: 'end', filter: 'number-range' }, }, ]; export default function Example() { return <DataTable caption="Invoices" captionHidden columns={columns} data={data} />; } ``` ## Accessibility - Roles: table (default), grid (with `grid`), columnheader with aria-sort when sortable - `Tab`: Without `grid`: every control in the table is a tab stop. With `grid`: the table is one tab stop and remembers the last cell. - `Arrow keys`: With `grid`: move between cells, and between the controls inside a cell. Mirrored in RTL. - `Home / End`: With `grid`: first or last cell in the row. Ctrl+Home / Ctrl+End: first or last cell in the grid. - `Space`: Toggles a focused row checkbox. - `Alt+Arrow`: Moves a focused header when `enableColumnReordering` is on. - With `grid`, focus goes to a cell’s first control, or to the cell itself when it has none. - Name the table with `caption` (or `aria-label`); `captionHidden` keeps it for screen readers only. - Sorting, selection counts and column moves are announced from a polite live region. - DataTableVirtual sets aria-rowcount and aria-rowindex so readers report the full row count. - Use `grid` when rows hold actions (edit, menus); plain tables of text read better as a table. --- # Date Picker Element `<nx-date-picker>`: a typed date field and a calendar as a form-associated web component, for server-rendered pages without React. The value is `YYYY-MM-DD`. - Package: `@nexub/elements` · Category: Web Components · Status: alpha - Load: `<script type="module" src="https://cdn.jsdelivr.net/npm/@nexub/elements/dist/define.js"></script>` - Install: `npm install @nexub/elements`. No build step: the script tag above registers `<nx-date-picker>`. With a bundler, `import '@nexub/elements/define';` once does the same. - Web only: It is a web component for HTML pages; native apps use DatePicker’s twin in `@nexub/react-native`, `DateTimeField` (the platform picker). - Docs: https://nexub-ds-docs.pages.dev/components/date-picker-element ## When to use - A date, month or year on a page with no React: server-rendered HTML, a plain `<form method="post">`. - Where `<input type="date">` would do, but the calendar must match Nexub in every browser and the value must never shift across time zones. ## When not to use - In a React app: use DatePicker from `@nexub/react`. - A range (from and to): use DateRangePicker in React, or two fields. - A date and a time: use DateTimePicker in React. ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `name` | `string` | | The form field name: a `<form>` posts the value under it. | | `value` | `string` | | The starting value: `YYYY-MM-DD`, `YYYY-MM` or `YYYY` by `granularity`; what `form.reset()` goes back to. The `value` property is the current value. In React, server rendering writes `value` as this attribute; in a client-only render pass `defaultValue`. | | `granularity` | `'day' \| 'month' \| 'year'` | | `day` (default), `month` or `year`: the calendar shows days, months or years, and the value has that precision. | | `min` | `string` | | Earliest value, same format. Earlier cells are disabled; a typed earlier date is invalid (`rangeUnderflow`). | | `max` | `string` | | Latest value (`rangeOverflow`). | | `required` | `boolean` | | Empty is invalid (`valueMissing`). | | `disabled` | `boolean` | | Not editable, not posted; the calendar button is disabled. | | `readonly` | `boolean` | | Posted but not editable; the calendar doesn’t open. | | `locale` | `string` | | BCP 47 locale for month and weekday names, the week start and the typed format. Defaults to the nearest `lang`. | | `size` | `'sm' \| 'md' \| 'lg'` | | `sm`, `md` (default) or `lg`: the control heights of `@nexub/react`. | | `aria-label` | `string` | | Names the field when it has no `<label for>`. | | `change event` | `Event` | | When the value changes: a day picked, or a typed date committed on blur or Enter. | | `show() / close()` | `() => void` | | Open the calendar (focused on the selected date, or today) and close it; `open` is true while it is. | ## Example: Default Type a date or open the calendar. Rendered here in React 19; on a server-rendered page it is the same tag. ```tsx 'use client'; import * as React from 'react'; // Registers <nx-number-input> and <nx-date-picker>. On a page without a bundler, use // <script type="module" src="…/@nexub/elements/dist/define.js"></script> instead. import '@nexub/elements/define'; export default function Example() { const ref = React.useRef<HTMLElementTagNameMap['nx-date-picker']>(null); const [value, setValue] = React.useState('2026-03-14'); React.useEffect(() => { const el = ref.current; if (!el) return; const onChange = () => setValue(el.value); el.addEventListener('change', onChange); return () => el.removeEventListener('change', onChange); }, []); return ( <div lang="en-US" className="flex w-full max-w-xs flex-col gap-2"> <label htmlFor="start" className="text-label-lg text-on-surface"> Start date </label> <nx-date-picker ref={ref} id="start" name="start" min="2026-01-01" max="2026-12-31" value="2026-03-14" /> <p className="text-body-sm text-on-surface-muted">Value: {value || 'empty'}</p> </div> ); } ``` ## Example: Months, in a form `granularity="month"` posts `YYYY-MM`; `required` and `min` block the submit until the value is valid. ```tsx 'use client'; import * as React from 'react'; import { Button } from '@nexub/react'; import '@nexub/elements/define'; export default function Example() { const [posted, setPosted] = React.useState<string | null>(null); return ( <form lang="en-US" className="flex w-full max-w-xs flex-col gap-3" onSubmit={(e) => { e.preventDefault(); setPosted(JSON.stringify(Object.fromEntries(new FormData(e.currentTarget)))); }} onReset={() => setPosted(null)} > <div className="flex flex-col gap-1"> <label htmlFor="billing-month" className="text-label-lg text-on-surface"> First billing month </label> <nx-date-picker id="billing-month" name="month" granularity="month" min="2026-04" required /> </div> <div className="flex gap-2"> <Button type="submit">Save</Button> <Button type="reset" variant="outlined"> Reset </Button> </div> <p className="text-body-sm text-on-surface-muted">Posted: {posted ?? 'nothing yet'}</p> </form> ); } ``` ## Accessibility - Roles: textbox (the typed field) and a button with `aria-haspopup="dialog"` and `aria-expanded`, dialog (modal), named "Pick a date", "Pick a month" or "Pick a year", grid with gridcell buttons for days (`aria-selected`, `aria-current="date"` on today); a group of toggle buttons (`aria-pressed`) for months and years - `Enter (in the field)`: Commits the typed date and submits the form. - `Arrow keys`: Move a day (a week up or down); in the month and year grids, one cell (three up or down). Mirrored in RTL. - `PageUp / PageDown`: Previous or next month; with Shift, year. In the month and year grids, the previous or next page. - `Home / End`: Start or end of the week (the row). - `Enter / Space`: Picks the focused cell and closes the calendar. - `Escape`: Closes the calendar without picking. - Opening moves focus to the selected date (or today, kept inside `min` and `max`); the grid is one tab stop. - Closing, by picking, Escape or a click outside, returns focus to the field. - Below 48rem the calendar is a bottom sheet. - The field is named from the host’s `<label for>` (or a wrapping `<label>`, or `aria-label`), copied into the shadow root. - The month or year heading is a polite live region, so paging is announced. - `aria-required` and `aria-invalid` follow the field; a typed date that can’t be read stays as typed and is invalid, with a message that shows the expected format. - The value is a plain string, never a `Date`, so it never moves a day across time zones. - Shadow DOM: page CSS can’t break the inside. Style it with the theme variables, or `::part(field)`, `::part(input)`, `::part(button)` and `::part(calendar)`. - Motion only under `prefers-reduced-motion: no-preference`; forced colours redraw it with system colours. Related: [date-picker](date-picker.md), [number-input-element](number-input-element.md), [form](form.md) --- # Date Picker Calendar date picker with text input. `granularity` picks a whole month or year. - Package: `@nexub/react` · Category: Form & Input · Status: stable - Import: `import { DatePicker } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/date-picker ## When to use - One date, month or year, typed or picked from a calendar. ## When not to use - On a page without React (server-rendered HTML, a plain `<form>`): use `<nx-date-picker>` from `@nexub/elements`, the same calendar as a web component. - A range: use DateRangePicker. A date and a time: use DateTimePicker. ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `granularity` | `'day' \| 'month' \| 'year'` | `'day'` | `'month'` and `'year'` show a grid of months or years; the value is then a string, `'YYYY-MM'` or `'YYYY'`. | | `value` | `Date \| undefined` | | Controlled selected date value. | | `onValueChange` | `(date: Date \| undefined) => void` | | Called with the picked date. | | `locale` | `Locale (date-fns)` | | Month and weekday names, week start and the trigger format. Defaults to the NexubProvider `dateLocale`; the calendar also follows the provider `dir`, so arrows flip in RTL. | | `placeholder` | `string` | `'Pick a date'` | Placeholder text displayed in the input when no date is selected. | | `disabled` | `boolean` | `false` | Disables the date picker input and calendar. | | `minDate` | `Date` | | Earliest selectable date. Dates before this are greyed out. | | `maxDate` | `Date` | | Latest selectable date. Dates after this are greyed out. | | `aria-label` | `string` | | Field name for screen readers; the selected value is appended. | | `id` | `string` | | Id for the trigger button, e.g. to pair with a <label htmlFor>. | ## Example: Default ```tsx import { DatePicker } from '@nexub/react'; export default function Example() { return <DatePicker placeholder="Select a date…" />; } ``` ## Example: With value ```tsx import { DatePicker } from '@nexub/react'; export default function Example() { return <DatePicker value={new Date('2026-01-15')} onValueChange={() => {}} />; } ``` ## Example: With constraints ```tsx import { DatePicker } from '@nexub/react'; export default function Example() { return ( <DatePicker aria-label="Schedule for" placeholder="Select a future date…" minDate={new Date()} maxDate={new Date(Date.now() + 90 * 24 * 60 * 60 * 1000)} /> ); } ``` ## Example: Month and year Pay periods and tax years: `'2026-11'` and `'2026'`. ```tsx import * as React from 'react'; import { DatePicker } from '@nexub/react'; export default function Example() { const [month, setMonth] = React.useState<string | undefined>('2026-11'); const [year, setYear] = React.useState<string | undefined>(); return ( <div className="flex w-full max-w-xs flex-col gap-3"> <DatePicker granularity="month" aria-label="Pay period" value={month} onValueChange={setMonth} /> <DatePicker granularity="year" aria-label="Tax year" value={year} onValueChange={setYear} /> </div> ); } ``` Related: [date-picker-element](date-picker-element.md), [date-range-picker](date-range-picker.md), [date-time-picker](date-time-picker.md) --- # Date Range Picker Dual-calendar date range selector. - Package: `@nexub/react` · Category: Form & Input · Status: stable - Import: `import { DateRangePicker } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/date-range-picker ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `value` | `{ from: Date \| undefined; to: Date \| undefined }` | | Controlled date range value. | | `onChange` | `(range: { from: Date \| undefined; to: Date \| undefined }) => void` | | Callback invoked when the selected range changes. | | `locale` | `Locale (date-fns)` | | Month and weekday names, week start and the trigger format. Defaults to the NexubProvider `dateLocale`; the calendar also follows the provider `dir`, so arrows flip in RTL. | | `placeholder` | `string` | `'Select date range'` | Placeholder text shown in the trigger input when no range is selected. | | `disabled` | `boolean` | `false` | Disables the trigger input and calendar popover. | | `minDate` | `Date` | | Earliest selectable date. Dates before this are greyed out. | | `maxDate` | `Date` | | Latest selectable date. Dates after this are greyed out. | | `aria-label` | `string` | | Field name for screen readers; the selected value is appended. | | `id` | `string` | | Id for the trigger button, e.g. to pair with a <label htmlFor>. | | `presets` | `boolean \| { label: string; range: (today: Date) => DateRange }[]` | | `true` adds Today, Last 7 days, Last 30 days, Month to date and Last month beside the calendar; or pass your own (5.5). | | `timeZone` | `string` | | IANA zone the dates mean, e.g. `Europe/London`. Shown under the calendar; presets count "today" there (5.5). `todayIn(zone)` is exported. | | `endExclusive` | `boolean` | | 11.2: `to` is the day after the last day (half-open), in and out; the calendar still shows the last day. | | `onComplete` | `(range: { from: Date; to: Date }) => void` | | 11.2: called once both ends are set (the second day picked, or a preset). | ## Example: Default ```tsx import { DateRangePicker } from '@nexub/react'; export default function Example() { return <DateRangePicker placeholder="Select date range…" />; } ``` ## Example: Controlled ```tsx import * as React from 'react'; import { DateRangePicker } from '@nexub/react'; export default function Example() { const [range, setRange] = React.useState<{ from: Date | undefined; to: Date | undefined }>({ from: new Date('2026-04-01'), to: new Date('2026-04-14'), }); return ( <DateRangePicker value={range} onChange={(r) => setRange({ from: r?.from, to: r?.to })} placeholder="Select date range…" /> ); } ``` ## Example: Presets and time zone Quick ranges counted in the chosen time zone, which is labelled under the calendar. ```tsx 'use client'; import * as React from 'react'; import { DateRangePicker, type DateRange } from '@nexub/react'; export default function Example() { const [range, setRange] = React.useState<DateRange | undefined>(); return ( <div className="w-75"> <DateRangePicker aria-label="Report period" value={range} onChange={setRange} presets timeZone="Europe/London" /> </div> ); } ``` ## Example: Half-open stay endExclusive and onComplete. ```tsx import * as React from 'react'; import { DateRangePicker, type DateRange } from '@nexub/react'; export default function Example() { // Stored half-open, as the booking API does: 1–3 March is { from: 1 Mar, to: 4 Mar }. const [stay, setStay] = React.useState<DateRange | undefined>(); const [nights, setNights] = React.useState<number | null>(null); return ( <div className="flex w-full max-w-xs flex-col gap-2"> <DateRangePicker aria-label="Stay" endExclusive value={stay} onChange={setStay} onComplete={({ from, to }) => setNights(Math.round((to.getTime() - from.getTime()) / 86400000))} /> <p className="text-body-sm text-on-surface-muted">{nights === null ? 'Pick check-in and check-out' : `${nights} nights`}</p> </div> ); } ``` --- # Date Time Picker A DatePicker and a TimePicker that edit one Date, with an optional time-zone label. - Package: `@nexub/react` · Category: Form & Input · Status: beta - Import: `import { DateTimePicker } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/date-time-picker ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `value / onValueChange` | `Date \| undefined` | | Date and time in the reader’s local time. | | `defaultTime` | `string` | `'09:00'` | Time used when the date is picked first. | | `minuteStep` | `number` | | Passed to the TimePicker. | | `minDate / maxDate` | `Date` | | Limits the calendar. | | `timeZone` | `string` | | IANA zone named next to the fields, e.g. "Time zone: GMT+8 (Asia/Singapore)". Label only. | | `aria-label` | `string` | | Names the group; the parts read "Date" and "Time". | | `clearable` | `boolean` | | 11.2: a clear button empties the value. | ## Example: Meeting start ```tsx 'use client'; import * as React from 'react'; import { DateTimePicker } from '@nexub/react'; export default function Example() { const [starts, setStarts] = React.useState<Date | undefined>(); return ( <div className="flex w-full max-w-md flex-col gap-2"> <DateTimePicker aria-label="Meeting starts" value={starts} onValueChange={setStarts} minuteStep={15} timeZone="Asia/Singapore" /> <p className="text-body-sm text-on-surface-muted">{starts ? starts.toString() : 'Pick a date first; the time defaults to 09:00.'}</p> </div> ); } ``` ## Example: Clearable reminder ```tsx import * as React from 'react'; import { DateTimePicker } from '@nexub/react'; export default function Example() { const [reminder, setReminder] = React.useState<Date | undefined>(new Date(2026, 10, 24, 9, 0)); return ( <div className="w-full max-w-md"> <DateTimePicker aria-label="Remind me" clearable value={reminder} onValueChange={setReminder} /> </div> ); } ``` ## Accessibility - A labelled group holding the DatePicker button and the native time input. Related: [date-picker](date-picker.md), [time-picker](time-picker.md) --- # Description List Key–value rows with list semantics: a receipt, a fee breakdown, the details of a record. - Package: `@nexub/react` · Category: Data Display · Status: alpha - Import: `import { DescriptionList } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/description-list ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `Root layout` | `'inline' \| 'stacked'` | `'inline'` | Label and value on one row, or label above the value. | | `Root columns` | `1 \| 2 \| 3` | `1` | Pairs per row. Falls back to fewer columns when the list itself is narrow. | | `Root divided` | `boolean` | | A hairline between rows. | | `Root size` | `'sm' \| 'md'` | `'md'` | Row height and type size. | | `Item label` (required) | `React.ReactNode` | | The term. | | `Item children` | `React.ReactNode` | | The value. | | `Item emphasis` | `boolean` | | A total: stronger label and value, and a rule above. | | `Item align` | `'start' \| 'end'` | | Where the value sits. Defaults to the end when inline, the start when stacked. | | `Item helpText` | `React.ReactNode` | | A small muted line under the label. | ## Example: Receipt with a total ```tsx import { DescriptionList } from '@nexub/react'; export default function Example() { return ( <div className="w-full max-w-sm"> <DescriptionList.Root divided aria-label="Order summary"> <DescriptionList.Item label="Subtotal" helpText="2 items">$40.00</DescriptionList.Item> <DescriptionList.Item label="Shipping">$5.00</DescriptionList.Item> <DescriptionList.Item label="Service fee">$1.50</DescriptionList.Item> <DescriptionList.Item label="Total" emphasis>$46.50</DescriptionList.Item> </DescriptionList.Root> </div> ); } ``` ## Example: Stacked, in columns ```tsx import { DescriptionList } from '@nexub/react'; export default function Example() { return ( <DescriptionList.Root layout="stacked" columns={3}> <DescriptionList.Item label="Applicant">Ada Lovelace</DescriptionList.Item> <DescriptionList.Item label="Submitted">12 March 2026</DescriptionList.Item> <DescriptionList.Item label="Reference">APP-2041</DescriptionList.Item> <DescriptionList.Item label="Plan">Standard</DescriptionList.Item> <DescriptionList.Item label="Reviewer">Not assigned</DescriptionList.Item> <DescriptionList.Item label="Status">Under review</DescriptionList.Item> </DescriptionList.Root> ); } ``` Related: [info-list](info-list.md), [table](table.md) --- # Diagram Canvas Nodes and edges on a themed, keyboard-accessible canvas: workflows and mind maps, with automatic layout and a "Show as list" text alternative. From `@nexub/diagram`, on React Flow. - Package: `@nexub/diagram` · Category: Diagram · Status: alpha - Import: `import { DiagramCanvas } from '@nexub/diagram';` `import '@nexub/diagram/styles.css';` - Install: `npm install @nexub/diagram @xyflow/react`. `@xyflow/react` (React Flow) is a peer dependency: install it next to `@nexub/diagram`. Load the stylesheet after `@nexub/react`’s. - Web only: Native apps have no diagram editor: on phones, show the same nodes and connections as a list, as the canvas’s "Show as list" view does. - Docs: https://nexub-ds-docs.pages.dev/components/diagram-canvas ## When to use - Free-form graphs people build or edit: workflow editors, automations, pipelines. - Mind maps: one idea in the middle, branches around it (`layout="mind-map"`). - Read-only maps of how things connect, where the shape matters (`readOnly`). ## When not to use - Reporting lines and other strict hierarchies people scan by name: use OrgChart or TreeView. - Steps in a fixed order: use Stepper or a list. - An app that can’t take React Flow as a dependency (about 50 kB gzip): DiagramCanvas needs `@xyflow/react` installed next to it. ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `aria-label` (required) | `string` | | Names the canvas (role="application"). Required. | | `nodes / onNodesChange` | `Node[]` | | React Flow’s controlled nodes. `type: 'nexub'` renders the Nexub card (DiagramNode) from `data: { title, description, icon, tone }`. | | `edges / onEdgesChange` | `Edge[]` | | React Flow’s controlled edges. | | `defaultNodes / defaultEdges` | `Node[] / Edge[]` | | Uncontrolled instead: the canvas keeps the state, and `layout` applies once. | | `onConnect` | `(connection: Connection) => void` | | Called when a handle is dragged to another node, or a node is picked in the "Connect to…" menu (C). Without it, nodes can’t be connected. | | `layout` | `'left-right' \| 'mind-map' \| 'none'` | `'none'` | `left-right`: a layered workflow (a tidy tree when the graph is a tree). `mind-map`: a radial tree with edges between facing sides. Runs again when node ids, sizes or links change; moves made since are kept until then. | | `readOnly` | `boolean` | | View only: no dragging, connecting, deleting or selecting. Arrow keys still move focus between nodes. | | `minimap` | `boolean` | `false` | Show the minimap. | | `controls` | `boolean` | `true` | Show the zoom in, zoom out and fit view buttons. | | `listView` | `boolean` | `true` | Show the "Show as list" text alternative under the canvas: every node with its connections by name. | | `labels` | `Partial<DiagramLabels>` | | Every string the canvas shows or announces, English by default. Pass translations here. | | `keyboardStep` | `number` | | Grid step for Alt+Arrow moves, in flow units; Shift moves four steps. Defaults to `snapGrid[0]`, else 16. | | `nodeTypes` | `NodeTypes` | | Extra node types; `nexub` (DiagramNode) is always there. | | `fitView` | `boolean` | | React Flow’s: fit the nodes into view on first render. Animation is skipped under reduced motion. | | `className` | `string` | | Sizes the canvas box (24rem tall by default), e.g. `h-96`. | ## Example: Workflow, left to right Controlled nodes and edges with `layout="left-right"`. Tab to a node, then try the arrow keys, Alt+arrows, C and Delete. ```tsx 'use client'; import * as React from 'react'; import { addEdge, applyEdgeChanges, applyNodeChanges, type Connection, type Edge, type EdgeChange, type NodeChange } from '@xyflow/react'; import { DiagramCanvas, type DiagramFlowNode } from '@nexub/diagram'; const step = (id: string, title: string, data: Partial<DiagramFlowNode['data']> = {}): DiagramFlowNode => ({ id, type: 'nexub', position: { x: 0, y: 0 }, // layout="left-right" places the nodes data: { title, ...data }, }); const initialNodes: DiagramFlowNode[] = [ step('signup', 'New sign-up', { description: 'Webhook from the website' }), step('enrich', 'Enrich profile', { description: 'Company and role lookup' }), step('score', 'Score lead', { tone: 'warning', description: 'Model update pending' }), step('welcome', 'Send welcome email', { tone: 'good' }), step('crm', 'Create CRM record'), ]; const initialEdges: Edge[] = [ { id: 'signup-enrich', source: 'signup', target: 'enrich' }, { id: 'signup-welcome', source: 'signup', target: 'welcome' }, { id: 'enrich-score', source: 'enrich', target: 'score' }, { id: 'score-crm', source: 'score', target: 'crm' }, ]; export default function Example() { const [nodes, setNodes] = React.useState(initialNodes); const [edges, setEdges] = React.useState(initialEdges); const onNodesChange = React.useCallback((changes: NodeChange<DiagramFlowNode>[]) => setNodes((ns) => applyNodeChanges(changes, ns)), []); const onEdgesChange = React.useCallback((changes: EdgeChange<Edge>[]) => setEdges((es) => applyEdgeChanges(changes, es)), []); const onConnect = React.useCallback((connection: Connection) => setEdges((es) => addEdge(connection, es)), []); // minZoom: React Flow's default (0.5) can't fit four columns into a narrow page with fitView. return ( <div className="w-full"> <DiagramCanvas aria-label="Lead onboarding workflow" layout="left-right" nodes={nodes} edges={edges} onNodesChange={onNodesChange} onEdgesChange={onEdgesChange} onConnect={onConnect} fitView minZoom={0.3} /> </div> ); } ``` ## Example: Mind map `layout="mind-map"` and `readOnly`: a radial tree to look at, not edit. ```tsx 'use client'; import type { Edge } from '@xyflow/react'; import { DiagramCanvas, type DiagramFlowNode } from '@nexub/diagram'; const idea = (id: string, title: string): DiagramFlowNode => ({ id, type: 'nexub', position: { x: 0, y: 0 }, data: { title } }); const nodes: DiagramFlowNode[] = [ idea('launch', 'Product launch'), idea('audience', 'Audience'), idea('channels', 'Channels'), idea('timeline', 'Timeline'), idea('teams', 'Small teams'), idea('enterprise', 'Enterprise'), idea('email', 'Email'), idea('events', 'Events'), idea('beta', 'Beta in March'), ]; const link = (source: string, target: string): Edge => ({ id: `${source}-${target}`, source, target }); const edges: Edge[] = [ link('launch', 'audience'), link('launch', 'channels'), link('launch', 'timeline'), link('audience', 'teams'), link('audience', 'enterprise'), link('channels', 'email'), link('channels', 'events'), link('timeline', 'beta'), ]; export default function Example() { return ( <div className="w-full"> <DiagramCanvas aria-label="Launch plan mind map" layout="mind-map" readOnly defaultNodes={nodes} defaultEdges={edges} fitView minZoom={0.3} minimap /> </div> ); } ``` ## Accessibility - Roles: application (the canvas, named by `aria-label`), group with `aria-roledescription="node"` for each node, named by its title, with the keyboard hint as its description, listbox and option (the "Connect to…" menu), Native `<details>` for "Show as list" - `Tab`: Moves into the canvas onto one node (roving tabindex: the last focused, else the first in reading order), then on to the zoom controls. - `Arrow keys`: Move focus to the nearest node in that direction. - `Home / End`: First or last node in reading order (top to bottom, then by line direction; mirrored in RTL). - `Alt (Option) + Arrow`: Moves the focused node one grid step (`keyboardStep`); with Shift, four. The new position is announced. Off in `readOnly`. - `C`: Opens the "Connect <node> to…" menu, the keyboard alternative to dragging a handle. Only with `onConnect`. - `Up / Down, Home / End, a letter`: In the Connect menu: move through the nodes it can connect to; typing a letter jumps to the next title starting with it. - `Enter / Space`: In the Connect menu: connects to the active node and announces it. - `Escape / Tab`: Closes the Connect menu; focus returns to the node. - `Delete / Backspace`: Removes the selection, or the focused node; focus moves to the next node in reading order and the count is announced. - One node is in the Tab order at a time; focus follows arrow keys, not the DOM order of React Flow’s nodes. - After a delete, focus goes to the next node (or the previous one at the end), never to the page. - Focus rings and the 24px handle hit area come from the tokens. - Each node is read by its title, then its tone ("Warning") as text, then how the keyboard works. - Connections, moves and deletes are announced in a polite live region. - "Show as list" lists every node with what it connects to and is connected from, by name: the text alternative to the drawing. - Tone is never colour alone: a dot plus text for screen readers and the list view, and a border in forced colours. - Fit view and animated edges respect reduced motion. - Every string (`labels`) is English by default: they are not in `@nexub/core` messages yet, so pass translations. Related: [org-chart](org-chart.md), [tree-view](tree-view.md), [kanban](kanban.md) --- # Dialog Modal dialog built on Radix UI. Fully accessible with focus trapping and ARIA roles. - Package: `@nexub/react` · Category: Overlays · Status: stable - Import: `import { Dialog } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/dialog ## When to use - Confirming a destructive or irreversible action - Collecting a small form without leaving the current page - Displaying critical information that requires acknowledgement - Previewing content before taking an action ## When not to use - Long multi-step flows — use a Drawer or a dedicated page instead - Quick contextual info — use a Tooltip or Popover - Non-blocking side panels — use Sheet or Drawer - Stacking multiple dialogs — always limit to one at a time ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `open` | `boolean` | | Controlled open state. | | `onOpenChange` | `(open: boolean) => void` | | Callback when open state changes. | | `defaultOpen` | `boolean` | `false` | Uncontrolled initial open state. | | `surface` | `'solid' \| 'glass'` | `'solid'` | Glass material on Dialog.Content — see Foundations → Materials. | | `maxHeight` | `string` | | 11.5 (Dialog.Content): the tallest the dialog gets before its content scrolls, e.g. "32rem". Set through CSSOM (strict CSP safe). | ## Example: Default ```tsx import * as React from 'react'; import { Button, Dialog } from '@nexub/react'; export default function Example() { const [open, setOpen] = React.useState(false); return ( <> <Button variant="filled" onClick={() => setOpen(true)}>Open Dialog</Button> <Dialog.Root open={open} onOpenChange={setOpen}> <Dialog.Portal> <Dialog.Overlay /> <Dialog.Content size="sm"> <Dialog.Title>Confirm action</Dialog.Title> <Dialog.Description className="mt-2 mb-6"> Are you sure you want to continue? This action cannot be undone. </Dialog.Description> <div className="flex gap-2 justify-end"> <Dialog.Close asChild><Button variant="outlined">Cancel</Button></Dialog.Close> <Button variant="filled" onClick={() => setOpen(false)}>Confirm</Button> </div> </Dialog.Content> </Dialog.Portal> </Dialog.Root> </> ); } ``` --- # Diff View A unified diff with added and removed lines, for agent changes. - Package: `@nexub/react` · Category: AI · Status: beta - Import: `import { DiffView } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/diff-view ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `diff` (required) | `string` | | Unified diff text. | | `file` | `string` | | File name above the diff. | ## Example: Proposed change ```tsx import { DiffView } from '@nexub/react'; const diff = `@@ -3,4 +3,4 @@ export const reminder = { - subject: 'Invoice overdue', + subject: 'A friendly reminder about your invoice', tone: 'polite', };`; export default function Example() { return <DiffView className="w-full" file="templates/reminder.ts" diff={diff} />; } ``` ## Accessibility - Added and removed lines are spelled out for screen readers; colour is not the only cue. Related: [message-bubble](message-bubble.md), [thinking-indicator](thinking-indicator.md) --- # Donut Chart Parts of a whole, with an optional total in the hole. Keep it to six slices or fewer. - Package: `@nexub/react` · Category: Data Display · Status: beta - Import: `import { DonutChart } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/donut-chart ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `title` (required) | `string` | | Accessible name of the chart. | | `data` (required) | `{ label: string; value: number; color?: ChartColor }[]` | | One entry per slice. | | `center` | `ReactNode` | | Content in the hole, such as the total. | | `valueFormat` | `(value: number) => string` | | Formats the hover text and the data table. | | `legend` | `boolean` | `true` | Show the legend beside the donut. | | `maxSlices / otherLabel` | `number / string` | | 11.3: group the smallest slices into one "Other". | | `legendValues` | `boolean` | | 11.3: value and share on each legend row. | | `data[].href` | `string` | | 11.3: makes the slice's legend row a link. | | `data[].color` | `1–8 \| 'good' \| 'warning' \| 'danger' \| 'neutral'` | | 11.3: a palette colour or a tone. | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | 11.3: diameter. | | `tableView` | `boolean \| string` | | 11.3: a visible "Show as table" disclosure. | ## Example: With total ```tsx import { DonutChart } from '@nexub/react'; const plans = [ { label: 'Pro', value: 540 }, { label: 'Team', value: 310 }, { label: 'Starter', value: 220 }, { label: 'Free', value: 130 }, ]; export default function Example() { return ( <DonutChart title="Customers by plan" data={plans} center={ <span> 1,200 <br /> <span className="text-label-sm text-on-surface-muted">customers</span> </span> } /> ); } ``` ## Example: Other, legend values and links ```tsx import { DonutChart } from '@nexub/react'; const plans = [ { label: 'Enterprise', value: 42, href: '#enterprise' }, { label: 'Team', value: 31, href: '#team' }, { label: 'Starter', value: 15 }, { label: 'Education', value: 6 }, { label: 'Nonprofit', value: 4 }, { label: 'Trial', value: 2 }, ]; export default function Example() { return <DonutChart title="Plans" size="lg" legendValues maxSlices={4} data={plans} center="100" tableView />; } ``` ## Accessibility - The chart is a `figure` named by `title`. The drawing is hidden from assistive tech; a visually hidden table carries every value. - Colour is never the only cue: the legend and table name each series. Past six series, label directly or group the rest as "Other". Related: [bar-chart](bar-chart.md) --- # Drawer Slide-in panel from any edge of the screen. - Package: `@nexub/react` · Category: Overlays · Status: stable - Import: `import { Drawer } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/drawer ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `Drawer.Root` | `compound` | | Root provider that manages open/close state. | | `Drawer.Trigger` | `compound` | | Element that opens the drawer. | | `Drawer.Portal` | `compound` | | Portals the overlay and content into the document body. | | `Drawer.Overlay` | `compound` | | Dimmed backdrop rendered behind the drawer. | | `Drawer.Content` | `compound` | | The drawer panel. Accepts a side prop. | | `scrollLock` | `'style' \| 'class'` | | On Drawer.Root. How page scroll is locked while open. `class` adds a class from @nexub/themes/base instead of injecting a <style> tag, so it works under a strict CSP (style-src 'self'). Default `style`. | | `direction` | `'left' \| 'right' \| 'top' \| 'bottom'` | | Edge of the screen from which the drawer slides in. | | `Drawer.Header` | `compound` | | Header section of the drawer panel. Sticky on solid panels (5.1): long content scrolls under it. | | `Drawer.Footer` | `compound` | | Footer section of the drawer panel. Sticky on solid panels (5.1): actions stay in view while content scrolls. | | `Drawer.Title` | `compound` | | Accessible title for the drawer. | | `Drawer.Description` | `compound` | | Supporting description text for the drawer. | | `Drawer.Close` | `compound` | | Element that closes the drawer. | | `Drawer.Content surface` | `'solid' \| 'glass'` | `'solid'` | Glass material on Drawer.Content — see Foundations → Materials. | ## Example: Default ```tsx import * as React from 'react'; import { Button, Drawer, Label, Input } from '@nexub/react'; export default function Example() { const [open, setOpen] = React.useState(false); return ( <> <Button variant="outlined" onClick={() => setOpen(true)}>Open Drawer</Button> <Drawer.Root open={open} onOpenChange={setOpen}> <Drawer.Portal> <Drawer.Overlay /> <Drawer.Content side="right"> <Drawer.Header> <Drawer.Title>Edit profile</Drawer.Title> <Drawer.Description>Update your profile details.</Drawer.Description> </Drawer.Header> <div className="p-4 flex-1 overflow-y-auto"> <div className="flex flex-col gap-3 items-start"> <div className="flex flex-col gap-1 items-start"> <Label htmlFor="d-name">Name</Label> <Input id="d-name" placeholder="Jane Smith" /> </div> <div className="flex flex-col gap-1 items-start"> <Label htmlFor="d-email">Email</Label> <Input id="d-email" type="email" placeholder="jane@example.com" /> </div> </div> </div> <Drawer.Footer> <div className="flex gap-2 justify-end"> <Drawer.Close asChild><Button variant="outlined">Cancel</Button></Drawer.Close> <Button variant="filled">Save changes</Button> </div> </Drawer.Footer> </Drawer.Content> </Drawer.Portal> </Drawer.Root> </> ); } ``` ## Example: Bottom sheet ```tsx import * as React from 'react'; import { Button, Drawer } from '@nexub/react'; export default function Example() { const [open, setOpen] = React.useState(false); return ( <> <Button variant="outlined" onClick={() => setOpen(true)}>Open Bottom Sheet</Button> <Drawer.Root open={open} onOpenChange={setOpen}> <Drawer.Portal> <Drawer.Overlay /> <Drawer.Content side="bottom"> <Drawer.Header> <Drawer.Title>Share to</Drawer.Title> </Drawer.Header> <div className="p-4 flex gap-3 flex-wrap"> {['Twitter', 'LinkedIn', 'Slack', 'Email'].map((s) => ( <Button key={s} variant="outlined" size="sm">{s}</Button> ))} </div> </Drawer.Content> </Drawer.Portal> </Drawer.Root> </> ); } ``` --- # Dropdown Menu A menu of actions opened from a button, built on Radix. - Package: `@nexub/react` · Category: Overlays · Status: stable - Import: `import { DropdownMenu } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/dropdown-menu ## When to use - Secondary actions behind a "More" button - A short set of options that change a view ## When not to use - Picking a form value: use `Select` - Site navigation: use `NavigationMenu` or `TopNav` ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `DropdownMenu.Root` | `compound` | | Holds the open state (`open`, `onOpenChange`, `defaultOpen`, `modal`). | | `DropdownMenu.Trigger` | `compound` | | The button that opens the menu. Use `asChild` with a `Button` or `IconButton`. | | `DropdownMenu.Portal / Content` | `compound` | | Renders the floating menu in a portal (`side`, `align`, `sideOffset` default 4). | | `DropdownMenu.Item` | `compound` | | An action (`onSelect`, `disabled`). | | `DropdownMenu.CheckboxItem / RadioGroup / RadioItem` | `compound` | | Toggle and single-choice items (`checked`, `onCheckedChange`; `value`, `onValueChange`). | | `DropdownMenu.Label / Group / Separator` | `compound` | | Section heading, grouping and divider. | | `DropdownMenu.Sub / SubTrigger / SubContent` | `compound` | | A nested submenu. | ## Example: Default ```tsx import { DropdownMenu, IconButton } from '@nexub/react'; import { MoreHorizontal } from '@nexub/icons'; export default function Example() { return ( <DropdownMenu.Root> <DropdownMenu.Trigger asChild> <IconButton variant="ghost" label="More actions"><MoreHorizontal size="sm" /></IconButton> </DropdownMenu.Trigger> <DropdownMenu.Portal> <DropdownMenu.Content align="end"> <DropdownMenu.Label>Project</DropdownMenu.Label> <DropdownMenu.Item>Rename</DropdownMenu.Item> <DropdownMenu.Item>Duplicate</DropdownMenu.Item> <DropdownMenu.Item disabled>Transfer ownership</DropdownMenu.Item> <DropdownMenu.Separator /> <DropdownMenu.Item>Archive</DropdownMenu.Item> </DropdownMenu.Content> </DropdownMenu.Portal> </DropdownMenu.Root> ); } ``` ## Example: Checkbox and radio items ```tsx import * as React from 'react'; import { Button, DropdownMenu } from '@nexub/react'; export default function Example() { const [showArchived, setShowArchived] = React.useState(false); const [sort, setSort] = React.useState('updated'); return ( <DropdownMenu.Root> <DropdownMenu.Trigger asChild> <Button variant="outlined">View options</Button> </DropdownMenu.Trigger> <DropdownMenu.Portal> <DropdownMenu.Content> <DropdownMenu.CheckboxItem checked={showArchived} onCheckedChange={setShowArchived}> Show archived </DropdownMenu.CheckboxItem> <DropdownMenu.Separator /> <DropdownMenu.Label>Sort by</DropdownMenu.Label> <DropdownMenu.RadioGroup value={sort} onValueChange={setSort}> <DropdownMenu.RadioItem value="updated">Last updated</DropdownMenu.RadioItem> <DropdownMenu.RadioItem value="name">Name</DropdownMenu.RadioItem> <DropdownMenu.RadioItem value="owner">Owner</DropdownMenu.RadioItem> </DropdownMenu.RadioGroup> </DropdownMenu.Content> </DropdownMenu.Portal> </DropdownMenu.Root> ); } ``` ## Accessibility - Roles: menu, menuitem, menuitemcheckbox, menuitemradio - `Enter / Space / Arrow Down`: Opens the menu from the trigger. - `Arrow Up / Down`: Moves between items. - `Arrow Right / Left`: Opens or closes a submenu. - `Escape`: Closes the menu and returns focus to the trigger. Related: [split-button](split-button.md), [context-menu](context-menu.md), [popover](popover.md) --- # Emoji Picker Pick an emoji from a searchable grid with categories, recent picks and skin tone. A popover, a bottom sheet on phones. - Package: `@nexub/react` · Category: Form Controls · Status: alpha - Import: `import { EmojiPicker } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/emoji-picker ## When to use - An emoji for a space, doc, label or status. - A reaction picker: `EmojiPicker.Panel` inside your own popover. ## When not to use - An icon from the design system: use IconPicker. - Emoji inside running text: let the keyboard’s emoji input handle it. ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `value / defaultValue` | `string \| null` | | The picked emoji, skin tone included. `null` for none. | | `onValueChange` | `(emoji: string) => void` | | Called with the picked emoji. The picker closes. | | `placeholder` | `string` | `'Pick an emoji'` | Shown on the trigger when nothing is picked. | | `recent` | `string[]` | | Recent picks, newest first. Unset: the last 16 picks are kept in localStorage (`nx-emoji-recent`). | | `skinTone / defaultSkinTone` | `0 \| 1 \| 2 \| 3 \| 4 \| 5` | | Skin tone for emoji that take one (0 is the default yellow). Unset: the last tone chosen on this device. | | `onSkinToneChange` | `(tone: SkinTone) => void` | | Called when the tone changes. | | `name` | `string` | | A hidden input posts the value with a plain form. | | `disabled / readOnly / invalid / required` | `boolean` | | Field states, as on Select. Read-only stays focusable and does not open. | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Height of the trigger. | | `sheet` | `boolean \| 'auto'` | `'auto'` | The grid as a bottom sheet below 768px. | | `EmojiPicker.Panel` | `component` | | The grid alone (`value`, `onValueChange`, `recent`, skin tone props, `autoFocus`), for any popover or page. | ## Example: Default ```tsx import * as React from 'react'; import { EmojiPicker } from '@nexub/react'; export default function Example() { const [emoji, setEmoji] = React.useState<string | null>('🚀'); return <EmojiPicker aria-label="Space icon" value={emoji} onValueChange={setEmoji} />; } ``` ## Example: Panel in a popover ```tsx import * as React from 'react'; import { Button, EmojiPickerPanel, Popover } from '@nexub/react'; export default function Example() { const [reaction, setReaction] = React.useState('👍'); const [open, setOpen] = React.useState(false); return ( <Popover.Root open={open} onOpenChange={setOpen}> <Popover.Trigger asChild> <Button variant="outlined">React {reaction}</Button> </Popover.Trigger> <Popover.Content className="p-0"> <EmojiPickerPanel aria-label="Reactions" value={reaction} onValueChange={(e) => { setReaction(e); setOpen(false); }} /> </Popover.Content> </Popover.Root> ); } ``` ## Example: States ```tsx import { EmojiPicker } from '@nexub/react'; export default function Example() { return ( <div className="flex flex-wrap gap-4"> <EmojiPicker aria-label="Invalid" invalid /> <EmojiPicker aria-label="Read-only" readOnly defaultValue="📚" /> <EmojiPicker aria-label="Disabled" disabled defaultValue="🎯" /> </div> ); } ``` ## Accessibility - Roles: combobox (trigger), listbox with a group per category, option - `Enter / Space / Arrow Down`: On the trigger: opens the picker with focus in the search box. - `Arrow Down`: From the search box: into the grid. - `Arrow keys`: Move between emoji; Arrow Up from the first row returns to the search box. - `Home / End`: First or last emoji in the row; with Ctrl, in the whole list. - `Enter / Space`: Picks the focused emoji. Enter in the search box picks the first result. - `Escape`: Closes without changing the value. - Each emoji is named by its CLDR-style name ("party popper"), not read as a glyph. - The emoji set loads when the picker opens, in its own chunk, so it stays out of the main bundle. Related: [icon-picker](icon-picker.md), [combobox-field](combobox-field.md), [popover](popover.md) --- # Empty State Placeholder UI shown when a list or page has no content. - Package: `@nexub/react` · Category: Data Display · Status: stable - Import: `import { EmptyState } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/empty-state ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `EmptyState.Root layout` | `'centered' \| 'inline'` | `'centered'` | "centered" stacks content vertically in the middle of its container; "inline" aligns content to the start. | | `EmptyState.Illustration children` | `React.ReactNode` | | Icon or SVG illustration to render above the title. | | `EmptyState.Title children` (required) | `React.ReactNode` | | Primary heading text for the empty state. | | `EmptyState.Description children` | `React.ReactNode` | | Supporting text providing more context or guidance. | | `EmptyState.Actions children` | `React.ReactNode` | | One or more action buttons rendered below the description. | | `EmptyStatePreset kind` (required) | `'noData' \| 'noResults' \| 'noAccess' \| 'serverError' \| 'offline'` | | Ready-made icon, title and description (5.6). serverError and offline are announced as alerts. | | `EmptyStatePreset title / description / actions` | `ReactNode` | | Override the localised text; add buttons such as Retry. | ## Example: Default ```tsx import { EmptyState, Button } from '@nexub/react'; export default function Example() { return ( <EmptyState.Root> <EmptyState.Illustration> <svg width="48" height="48" viewBox="0 0 48 48" fill="none"> <rect x="8" y="8" width="32" height="32" rx="4" stroke="var(--color-outline-variant)" strokeWidth="2" /> <path d="M18 24h12M24 18v12" stroke="var(--color-on-surface-muted)" strokeWidth="2" strokeLinecap="round" /> </svg> </EmptyState.Illustration> <EmptyState.Title>No results found</EmptyState.Title> <EmptyState.Description>Try adjusting your search or filters to find what you're looking for.</EmptyState.Description> <EmptyState.Actions> <Button variant="filled" size="sm">Clear filters</Button> </EmptyState.Actions> </EmptyState.Root> ); } ``` ## Example: Custom illustration ```tsx import { EmptyState, Button } from '@nexub/react'; export default function Example() { return ( <EmptyState.Root> <EmptyState.Illustration> <svg width="80" height="80" viewBox="0 0 80 80" fill="none" aria-hidden="true"> <rect width="80" height="80" rx="40" fill="var(--color-surface-container-low)" /> <rect x="24" y="28" width="32" height="24" rx="4" stroke="var(--color-outline)" strokeWidth="2" /> <path d="M24 36h32" stroke="var(--color-outline)" strokeWidth="2" /> <circle cx="40" cy="48" r="4" fill="color-mix(in srgb, var(--color-on-surface) 38%, transparent)" /> </svg> </EmptyState.Illustration> <EmptyState.Title>No documents yet</EmptyState.Title> <EmptyState.Description>Upload your first document to get started.</EmptyState.Description> <EmptyState.Actions> <Button variant="filled">Upload document</Button> </EmptyState.Actions> </EmptyState.Root> ); } ``` ## Example: Presets `EmptyStatePreset` for no data, no results, no access (403), server error (500) and offline. ```tsx import { Button, EmptyStatePreset } from '@nexub/react'; export default function Example() { return ( <div className="grid w-full gap-4 sm:grid-cols-2"> <EmptyStatePreset kind="noResults" actions={<Button variant="outlined" size="sm">Clear filters</Button>} /> <EmptyStatePreset kind="serverError" actions={<Button size="sm">Retry</Button>} /> </div> ); } ``` --- # Error State Full-page or section error view with retry action. - Package: `@nexub/react` · Category: Data Display · Status: stable - Import: `import { ErrorState } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/error-state ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `title` (required) | `string` | | Primary error heading shown to the user. | | `description` | `string` | | Supporting text with more detail about the error or recovery steps. | | `tone` | `'error' \| 'warning' \| 'info'` | `'error'` | Controls the icon and colour scheme of the error state. | | `onRetry` | `() => void` | | When provided, renders a "Try again" button that calls this function on click. | ## Example: Default ```tsx import { ErrorState } from '@nexub/react'; export default function Example() { return ( <ErrorState title="Something went wrong" description="We could not load the data. Please try again." onRetry={() => {}} /> ); } ``` ## Example: Warning ```tsx import { ErrorState } from '@nexub/react'; export default function Example() { return ( <ErrorState tone="warning" title="Connection issue" description="Check your network and try again." /> ); } ``` --- # Event Calendar A month or week grid of events. Display only: your app owns the events and what a click does. - Package: `@nexub/react` · Category: Data Display · Status: beta - Import: `import { EventCalendar } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/event-calendar ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `events` (required) | `CalendarEvent[]` | | `{ id, title, start, end?, allDay?, tone? }`. Events spanning days show on each day; `tone` is primary, success, warning, error or info. | | `date / defaultDate / onDateChange` | `Date` | | Any day in the shown month or week; Today and the arrows change it. | | `view / defaultView / onViewChange` | `'month' \| 'week'` | `'month'` | Week shows every event; month shows `maxEventsPerDay` then "N more". | | `onEventClick` | `(event) => void` | | Makes events buttons. | | `onDayClick` | `(date) => void` | | Makes day numbers and "N more" buttons, for example to open the day. | | `maxEventsPerDay` | `number` | `3` | Month view only. | | `weekStartsOn` | `0–6` | | Defaults to the locale’s first day (Monday for en-GB, Sunday for en-US). | | `onEventMove` | `(event, { start, end }) => void` | | 11.4. Makes events movable: drag one to another day (month, week) or time (day view, 15-minute steps), or press Alt+Arrow on it, pick with the arrows and press Enter (Escape cancels). The duration is kept. Events with `editable: false` stay put. | | `renderDayAction` | `(date) => ReactNode` | | 11.4. A per-day slot, e.g. a small add button: in each day’s header (month, week), above the day view and beside each agenda day. | | `eventActions` | `(event) => ReactNode` | | 11.4. Controls for one event, e.g. a menu: beside it in day and agenda views, over its end on hover or focus in month and week cells (always shown on touch screens). | | `legend` | `{ label, tone }[]` | | 11.4. A row under the toolbar naming what each tone means. Colour is never the only signal: titles still say what an event is. | ## Example: Team calendar ```tsx 'use client'; import * as React from 'react'; import { EventCalendar, type CalendarEvent } from '@nexub/react'; const today = new Date(); const on = (day: number, hour?: number) => new Date(today.getFullYear(), today.getMonth(), day, hour ?? 0); const events: CalendarEvent[] = [ { id: '1', title: 'Design review', start: on(3, 10) }, { id: '2', title: 'Offsite', start: on(11), end: on(12), allDay: true, tone: 'success' }, { id: '3', title: 'Standup', start: on(16, 9) }, { id: '4', title: 'Launch', start: on(16, 14), tone: 'warning' }, { id: '5', title: 'Retro', start: on(16, 16) }, { id: '6', title: 'Incident review', start: on(16, 17), tone: 'error' }, ]; export default function Example() { const [picked, setPicked] = React.useState(''); return ( <div className="flex w-full flex-col gap-2"> <EventCalendar events={events} onEventClick={(e) => setPicked(e.title)} onDayClick={(d) => setPicked(d.toDateString())} /> <p aria-live="polite" className="text-body-sm text-on-surface-muted">{picked && `Opened: ${picked}`}</p> </div> ); } ``` ## Example: Day and agenda views `views` adds Day (an hour grid with a "now" line) and Agenda (the month as a list) to the switcher. ```tsx import { EventCalendar, type CalendarEvent } from '@nexub/react'; // A fixed day, so the page renders the same on the server and in every time zone. const at = (day: number, hour = 0, minute = 0) => new Date(2026, 10, 16 + day, hour, minute); const events: CalendarEvent[] = [ { id: '1', title: 'Offsite', start: at(0), allDay: true, tone: 'success' }, { id: '2', title: 'Standup', start: at(0, 9, 30), end: at(0, 10) }, { id: '3', title: 'Design review', start: at(0, 9, 30), end: at(0, 11), tone: 'info' }, { id: '4', title: 'Launch', start: at(0, 14), end: at(0, 15, 30), tone: 'warning' }, { id: '5', title: 'Retro', start: at(1, 16) }, ]; export default function Example() { return ( <div className="w-full"> <EventCalendar events={events} defaultDate={at(0)} now={at(0, 11)} defaultView="day" views={['month', 'week', 'day', 'agenda']} /> </div> ); } ``` ## Example: Move, add and act on events Drag an event, or press Alt+Arrow on it, to move it; a "+" per day, a menu per event and a legend. ```tsx import * as React from 'react'; import { EventCalendar, IconButton, type CalendarEvent } from '@nexub/react'; import { MoreHorizontal, Plus } from '@nexub/icons'; // A fixed month, so the page renders the same on the server and in every time zone. const at = (day: number, hour = 0, minute = 0) => new Date(2026, 10, day, hour, minute); const initial: CalendarEvent[] = [ { id: '1', title: 'Design review', start: at(3, 10), end: at(3, 11) }, { id: '2', title: 'Offsite', start: at(11), end: at(12), allDay: true, tone: 'success' }, { id: '3', title: 'Standup', start: at(16, 9, 30), end: at(16, 10) }, { id: '4', title: 'Launch', start: at(16, 14), tone: 'warning' }, { id: '5', title: 'Payroll', start: at(25), allDay: true, tone: 'info', editable: false }, ]; export default function Example() { const [events, setEvents] = React.useState(initial); return ( <div className="w-full"> <EventCalendar events={events} defaultDate={at(16)} now={at(16, 11)} views={['month', 'week', 'day', 'agenda']} onEventMove={(event, range) => setEvents((list) => list.map((e) => (e.id === event.id ? { ...e, ...range } : e)))} renderDayAction={(date) => ( <IconButton variant="ghost" size="xs" label={`Add event on ${date.toDateString()}`}> <Plus size="sm" aria-hidden="true" /> </IconButton> )} eventActions={(event) => ( <IconButton variant="ghost" size="xs" label={`Actions for ${event.title}`}> <MoreHorizontal size="sm" aria-hidden="true" /> </IconButton> )} legend={[ { label: 'Meetings', tone: 'primary' }, { label: 'Away', tone: 'success' }, { label: 'Deadlines', tone: 'warning' }, { label: 'Payroll (fixed)', tone: 'info' }, ]} /> </div> ); } ``` ## Accessibility - `Alt + Arrow keys`: With `onEventMove`, on an event: starts a move and takes the first step. - `Arrow keys`: While moving: left and right a day; up and down a week, or 15 minutes in day view. - `Enter / Escape`: Drops the event there, or cancels the move. - A table with weekday column headers; today has `aria-current="date"` and each day reads its full date. - The title is a polite live region, so Today and the arrows announce the new month or week. - Movable events describe the keyboard move (Alt+Arrow, then arrows, Enter or Escape); each step and the drop are announced in a polite live region. Related: [date-picker](date-picker.md), [date-time-picker](date-time-picker.md) --- # Eyebrow Chip A compact eyebrow label, typically used above headings. - Package: `@nexub/react` · Category: Labels & Badges · Status: stable - Import: `import { EyebrowChip } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/eyebrow-chip ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `tone` | `ToneValue` | `'neutral'` | Text colour. | | `variant` | `'soft' \| 'gradient'` | `'soft'` | `gradient`: the marketing-mode chip; looks like `soft` outside `data-mode="marketing"`. | | `live` | `boolean` | `false` | A decorative "live" dot before the label; it pings in marketing mode and stays still under reduced motion. | | `leadingIcon` | `React.ReactNode` | | Icon before the label. | ## Example: Default ```tsx import { EyebrowChip } from '@nexub/react'; export default function Example() { return <EyebrowChip>New release</EyebrowChip>; } ``` ## Example: Usage ```tsx import { EyebrowChip } from '@nexub/react'; export default function Example() { return ( <div className="flex flex-col gap-2 items-start"> <EyebrowChip>Now available</EyebrowChip> <h2 className="m-0 text-headline-sm font-bold text-on-surface">Version 2.0</h2> </div> ); } ``` ## Example: Gradient and live (marketing mode) Inside `data-mode="marketing"`. ```tsx import { EyebrowChip } from '@nexub/react'; export default function Example() { return ( <div data-mode="marketing" className="flex flex-wrap items-center gap-3"> <EyebrowChip variant="gradient" tone="info">Now in Vietnam</EyebrowChip> <EyebrowChip variant="gradient" tone="success" live>Live</EyebrowChip> </div> ); } ``` --- # Fieldset Groups related fields under a legend; disabling it disables everything inside. - Package: `@nexub/react` · Category: Form & Input · Status: beta - Import: `import { Fieldset } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/fieldset ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `legend` (required) | `ReactNode` | | The group’s name, read before each field inside it. | | `description` | `ReactNode` | | Hint under the legend, linked with `aria-describedby`. | | `disabled` | `boolean` | | Disables every control inside, natively. | ## Example: Grouped fields ```tsx import { Fieldset, FormField, Input } from '@nexub/react'; export default function Example() { return ( <Fieldset legend="Billing address" description="Printed on every invoice." className="w-full max-w-sm"> <FormField.Root name="street"> <FormField.Label>Street</FormField.Label> <FormField.Control> <Input autoComplete="street-address" /> </FormField.Control> </FormField.Root> <FormField.Root name="city"> <FormField.Label>City</FormField.Label> <FormField.Control> <Input autoComplete="address-level2" /> </FormField.Control> </FormField.Root> </Fieldset> ); } ``` ## Accessibility - Renders a native `<fieldset>` and `<legend>`; screen readers announce the legend on entering the group. Related: [form](form.md), [form-field](form-field.md) --- # File Upload A drop zone and file list: pick, drop or paste files, with type, size and count checks and per-file progress. - Package: `@nexub/react` · Category: Form Controls · Status: stable - Import: `import { FileUpload } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/file-upload ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `accept` | `string[]` | | MIME types or extensions, e.g. `['image/*', '.pdf']`. Other files are rejected with a message. | | `maxFiles` | `number` | | Most files kept; extras are rejected. | | `maxSize` | `number` | | Largest file in bytes. | | `onFilesChange` | `(files: File[]) => void` | | The accepted files after every add or remove. Your app does the upload. | | `onReject` | `(rejections: FileRejection[]) => void` | | Files turned away, with the reason (`type`, `size`, `count` or `custom`). | | `validate` | `(file: File) => string \| null \| undefined` | | Your own check: return a message to reject the file. Validate again on the server. | | `files / defaultFiles` | `File[]` | | Controlled list: clear or set it from the page (`files={[]}` after a send) instead of remounting. | | `transform` | `(file: File) => File \| Promise<File>` | | Runs after the type check and before `maxSize` and `validate`, e.g. to shrink a photo. | | `capture` | `boolean \| 'user' \| 'environment'` | | Opens the phone camera instead of the file list. | | `disabled / busy / progress` | `boolean / boolean / number` | | Nothing can be added; `busy` shows an upload in progress (with `progress`, a bar). | | `FileUpload.Trigger` | `compound` | | An outlined button (or `iconOnly` paperclip) that opens the picker, with no drop zone: Import CSV, attach, take a photo. `asChild` takes your own Button for another look. Rejections show under it. | | `FileUpload.Dropzone` | `compound` | | A `<label>` around the native file input: click, Enter, Space, drop or paste. Children replace the default prompt. Rejection messages are announced. | | `Dropzone size` | `'sm' \| 'md'` | | `'sm'` is a compact one-line zone. | | `FileUpload.List` | `compound` | | Renders nothing until there are files. | | `FileUploadItem index` | `number` | | Which accepted file this row shows. Rows past the file count render nothing. | | `FileUploadItem progress / onCancel` | `number / () => void` | | Upload progress 0–100; below 100 shows a bar and, with `onCancel`, a cancel button. | | `FileUploadItem error` | `string` | | Why this file failed; shown under its name. | ## Example: Default ```tsx import { FileUpload } from '@nexub/react'; export default function Example() { return ( <FileUpload.Root accept={['image/*', '.pdf']} maxFiles={3} className="w-full max-w-120"> <FileUpload.Dropzone /> <FileUpload.List> {[0, 1, 2].map((i) => <FileUpload.Item key={i} index={i} />)} </FileUpload.List> </FileUpload.Root> ); } ``` ## Example: Custom prompt and limits ```tsx import { FileUpload, Text } from '@nexub/react'; export default function Example() { return ( <FileUpload.Root accept={['.csv']} maxFiles={1} maxSize={5 * 1024 * 1024} validate={(file) => (file.name.includes(' ') ? 'Rename the file without spaces.' : null)} className="w-full max-w-120" > <FileUpload.Dropzone> <Text size="body-sm"><span className="font-semibold text-primary">Choose a CSV</span> or drop it here</Text> <Text size="caption" tone="muted">One file, up to 5 MB</Text> </FileUpload.Dropzone> <FileUpload.List> <FileUpload.Item index={0} /> </FileUpload.List> </FileUpload.Root> ); } ``` ## Example: Trigger, camera and busy No drop zone: a button, a paperclip, the phone camera, and a busy compact zone. ```tsx import * as React from 'react'; import { Button, FileUpload } from '@nexub/react'; export default function Example() { const [files, setFiles] = React.useState<File[]>([]); return ( <div className="flex w-full max-w-md flex-col gap-4"> <FileUpload.Root accept={['.csv']} maxFiles={1} files={files} onFilesChange={setFiles}> <div className="flex items-center gap-2"> <FileUpload.Trigger>Import CSV</FileUpload.Trigger> <FileUpload.Trigger iconOnly aria-label="Attach a file" /> </div> <FileUpload.List> {files.map((f, i) => ( <FileUpload.Item key={f.name + i} index={i} /> ))} </FileUpload.List> </FileUpload.Root> <FileUpload.Root accept={['image/*']} capture="environment" maxFiles={1}> <FileUpload.Trigger asChild> <Button variant="tonal">Take a photo</Button> </FileUpload.Trigger> </FileUpload.Root> <FileUpload.Root busy progress={60}> <FileUpload.Dropzone size="sm" /> </FileUpload.Root> </div> ); } ``` ## Accessibility - `Enter / Space`: Opens the file picker from the focused drop zone. - Rejected files are listed in a live region (`role="alert"`) tied to the input with `aria-describedby`. Related: [form-field](form-field.md), [progress](progress.md) --- # Filter Builder Build AND/OR filter queries with nested groups. The output is plain JSON your app runs. - Package: `@nexub/react` · Category: Form Controls · Status: beta - Import: `import { FilterBuilder } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/filter-builder ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `fields` (required) | `{ id; label; type: "text" \| "number" \| "select" \| "date"; options? }[]` | | What can be filtered. The type picks the operators and the value input. | | `value / defaultValue` | `FilterGroup` | | `{ id, combinator: "and" \| "or", rules: (FilterRule \| FilterGroup)[] }`; a rule is `{ id, field, operator, value: string }`. | | `onValueChange` | `(value: FilterGroup) => void` | | Called with the whole query on every change. | | `maxDepth` | `number` | `1` | Levels of nested groups "Add group" may create; 0 hides it. | ## Example: Deals filter ```tsx 'use client'; import * as React from 'react'; import { FilterBuilder, type FilterField, type FilterGroup } from '@nexub/react'; const fields: FilterField[] = [ { id: 'name', label: 'Deal name', type: 'text' }, { id: 'amount', label: 'Amount', type: 'number' }, { id: 'stage', label: 'Stage', type: 'select', options: [ { value: 'lead', label: 'Lead' }, { value: 'proposal', label: 'Proposal' }, { value: 'won', label: 'Won' }, ], }, { id: 'close', label: 'Close date', type: 'date' }, ]; export default function Example() { const [query, setQuery] = React.useState<FilterGroup>({ id: 'root', combinator: 'and', rules: [ { id: 'r1', field: 'stage', operator: 'equals', value: 'proposal' }, { id: 'r2', field: 'amount', operator: 'greaterThan', value: '10000' }, ], }); return ( <div className="flex w-full max-w-160 flex-col gap-4"> <FilterBuilder fields={fields} value={query} onValueChange={setQuery} /> <pre className="max-h-40 overflow-auto rounded-shape-container bg-surface-container-low p-3 text-label-sm"> {JSON.stringify(query, null, 2)} </pre> </div> ); } ``` ## Accessibility - Roles: Each group is a `group` named "Filters, match all/any". - Field, condition and value controls are labelled; remove buttons say what they remove. - Helpers: `emptyFilter()`, `countFilters(group)`, `isFilterGroup(rule)`, `filterOperators`. Related: [filter-bar](filter-bar.md), [saved-views](saved-views.md), [data-table](data-table.md) --- # Filter Chip Interactive chip for filtering, supports selected/unselected state. - Package: `@nexub/react` · Category: Labels & Badges · Status: stable - Import: `import { FilterChip } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/filter-chip ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `selected` | `boolean` | | Controlled selected state of the chip. | | `disabled` | `boolean` | | Disables the chip. | ## Example: Default ```tsx import { FilterChip } from '@nexub/react'; export default function Example() { return ( <div className="flex gap-2 flex-wrap items-center justify-center"> <FilterChip>All</FilterChip> <FilterChip selected>Active</FilterChip> <FilterChip>Archived</FilterChip> <FilterChip>Draft</FilterChip> </div> ); } ``` --- # Flag A country flag from its ISO code, drawn with the system emoji font. - Package: `@nexub/react` · Category: Labels & Badges · Status: stable - Import: `import { Flag } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/flag ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `code` | `string` | | ISO 3166-1 alpha-2 country code, e.g. `JP`. Also the accessible name unless you pass `aria-label`. | | `size` | `'sm' \| 'md' \| 'lg'` | | Font size of the flag. | | `aria-label` | `string` | | A readable name, e.g. "Japan". Defaults to the code. | ## Example: Default ```tsx import { Flag } from '@nexub/react'; export default function Example() { return ( <div className="flex items-center gap-3"> <Flag code="JP" size="sm" aria-label="Japan" /> <Flag code="IN" aria-label="India" /> <Flag code="FR" size="lg" aria-label="France" /> </div> ); } ``` ## Accessibility - Roles: img - Windows has no flag emoji and shows the two letters instead. Pair the flag with the country name where it matters. Related: [country-badge](country-badge.md) --- # Flex Flexbox layout primitive. - Package: `@nexub/react` · Category: Layout · Status: stable - Import: `import { Flex } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/flex ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `direction` | `'row' \| 'column' \| 'row-reverse' \| 'column-reverse'` | | Sets the flex-direction CSS property. | | `align` | `'start' \| 'center' \| 'end' \| 'stretch'` | | Sets the align-items CSS property. | | `justify` | `'start' \| 'center' \| 'end' \| 'between' \| 'around'` | | Sets the justify-content CSS property. | | `gap` | `'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl'` | | Spacing between children using design tokens. | | `wrap` | `boolean` | | Allows children to wrap onto multiple lines. | ## Example: Default ```tsx import { Flex, Button } from '@nexub/react'; export default function Example() { return ( <Flex gap="md" align="center"> <Button variant="filled">Action</Button> <Button variant="outlined">Cancel</Button> </Flex> ); } ``` ## Example: Space between ```tsx import { Flex, Badge } from '@nexub/react'; export default function Example() { return ( <Flex justify="between" className="w-full max-w-80"> <Badge tone="success">Active</Badge> <Badge tone="neutral">Draft</Badge> </Flex> ); } ``` ## Example: Wrap ```tsx import { Flex, Badge } from '@nexub/react'; export default function Example() { return ( <Flex gap="sm" wrap className="max-w-65"> {['React', 'TypeScript', 'Tailwind', 'Radix UI', 'Storybook'].map((t) => ( <Badge key={t} tone="info">{t}</Badge> ))} </Flex> ); } ``` --- # Floating Input A text field whose label sits inside and floats up on focus or input. CSS only. - Package: `@nexub/react` · Category: Forms · Status: beta - Import: `import { FloatingInput } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/floating-input ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `label` (required) | `string` | | Always visible: inside the empty field, above the value otherwise. | | `...input` | `InputHTMLAttributes` | | Any input attribute except `placeholder`. Set `aria-invalid` for errors. | ## Example: Sign-in form ```tsx import { Button, FloatingInput } from '@nexub/react'; export default function Example() { return ( <form className="flex w-full max-w-sm flex-col gap-3"> <FloatingInput label="Email" type="email" autoComplete="email" /> <FloatingInput label="Password" type="password" autoComplete="current-password" /> <Button type="submit">Sign in</Button> </form> ); } ``` ## Accessibility - A real `<label>` tied to the input, so the name never disappears. Related: [input](input.md), [form-field](form-field.md) --- # Form Error An error message with an alert icon, announced when it appears. - Package: `@nexub/react` · Category: Form & Input · Status: stable - Import: `import { FormError } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/form-error ## When to use - A validation message under a field you lay out yourself ## When not to use - Inside `FormField.Root`: use `FormField.Error`, which wires the ids for you - Errors for a whole form: use the Error Summary pattern ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `children` | `ReactNode` | | The message: say what went wrong and how to fix it. | | `id` | `string` | | Point the control at it with `aria-describedby` so the message is read with the field. | ## Example: Under a field ```tsx import { FormError, Input, Label } from '@nexub/react'; export default function Example() { return ( <div className="flex w-70 flex-col gap-1"> <Label htmlFor="fe-email">Email</Label> <Input id="fe-email" type="email" defaultValue="jane@" aria-invalid aria-describedby="fe-email-error" /> <FormError id="fe-email-error">Enter an email address like name@example.com.</FormError> </div> ); } ``` ## Accessibility - Roles: alert - Has `role="alert"`, so it is announced when rendered. Render it only when there is an error. Related: [form-field](form-field.md), [helper-text](helper-text.md) --- # Form Field Wraps Label, Input, HelperText and FormError into a single accessible group. - Package: `@nexub/react` · Category: Form & Input · Status: stable - Import: `import { FormField } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/form-field ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `name` (required) | `string` | | Name attribute forwarded to the underlying input. | | `id` | `string` | | Explicit id for the input; defaults to the name value. | | `required` | `boolean` | | Marks the field as required and renders a required indicator on the label. | ## Example: Default ```tsx import { Label, Input, HelperText } from '@nexub/react'; export default function Example() { return ( <div className="flex flex-col gap-1 items-start w-70"> <Label htmlFor="field-name" required>Full name</Label> <Input id="field-name" placeholder="Jane Smith" /> <HelperText>Enter your legal name.</HelperText> </div> ); } ``` --- # Form Validates on submit with the browser’s own checks plus yours, shows each message on its FormField and focuses the first invalid field. - Package: `@nexub/react` · Category: Form & Input · Status: beta - Import: `import { Form } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/form ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `onSubmit` | `(data: FormData, event) => void \| Promise` | | Runs only when every field is valid. Return a promise to mark the form busy (`aria-busy`, `useForm().submitting`) until it settles. | | `validate` | `(data: FormData) => Record<string, string \| false \| null \| undefined>` | | Checks the browser can’t do (cross-field rules, a zod schema, a server answer). Keys are field names; empty values mean valid. | | `onInvalidSubmit` | `(errors: FormErrorItem[]) => void` | | Errors in field order after a failed submit, ready for ErrorSummary. | | `useForm()` | `{ errors, submitting } \| null` | | Reads the closest Form’s state, for a submit button or a custom field. | ## Example: Native validation plus a custom rule ```tsx 'use client'; import * as React from 'react'; import { Button, Form, FormField, Input, useForm } from '@nexub/react'; function Submit() { const submitting = useForm()?.submitting; return ( <Button type="submit" className="self-start" disabled={submitting}> {submitting ? 'Inviting…' : 'Send invite'} </Button> ); } export default function Example() { const [sent, setSent] = React.useState(''); return ( <Form className="w-full max-w-sm" validate={(data) => ({ email: String(data.get('email')).endsWith('@example.com') && 'Use a work address, not example.com', })} onSubmit={async (data) => { await new Promise((r) => setTimeout(r, 600)); setSent(`Invite sent to ${data.get('email')}`); }} > <FormField.Root name="email" required> <FormField.Label>Email</FormField.Label> <FormField.Control> <Input type="email" autoComplete="email" /> </FormField.Control> <FormField.Error /> </FormField.Root> <Submit /> <p aria-live="polite" className="text-body-sm text-on-surface-muted">{sent}</p> </Form> ); } ``` ## Accessibility - `Enter`: Submits from any text field; the first invalid field takes focus. - Messages come from the browser’s constraint validation (`required`, `type="email"`, `pattern`, `min`…), so they are already in the reader’s language. - FormField.Root with the same `name` picks the message up: the control gets `aria-invalid` and `aria-describedby`, and FormField.Error shows the text. - A field’s error clears as soon as it is edited; the rest stay until the next submit. - For long forms, render ErrorSummary (@nexub/patterns) from `onInvalidSubmit`. Related: [form-field](form-field.md), [fieldset](fieldset.md) --- # Funnel Drop-off through ordered steps, with conversion from the first step. - Package: `@nexub/react` · Category: Data Display · Status: beta - Import: `import { Funnel } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/funnel ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `data` (required) | `{ label: string; value: number }[]` | | Steps in order, largest first. | | `title` (required) | `string` | | Accessible name and table caption. | | `data[].values` | `Record<string, number>` | | 11.3: the other series' numbers for this step, keyed by series key. | | `series` | `{ key: string; label?: string; color?: ChartColor }[]` | | 11.3: several series per step, drawn as thin bars with a legend. `key: 'value'` reads each step's `value`; other keys read `values[key]`. The interactive tooltip uses `value`. | | `show` | `'conversion' \| 'drop-off' \| 'both'` | | 11.3: visible numbers under each step: share of the first and the previous step, how many dropped off, or both. Unset draws the bars only. | | `tableView` | `boolean \| string` | | 11.3: a "Show as table" disclosure under the drawing with the same data; a string sets its label. | ## Example: Signup funnel ```tsx import { Funnel } from '@nexub/react'; export default function Example() { return ( <Funnel className="w-full" title="Signup funnel, October" data={[{ label: 'Visited', value: 12400 }, { label: 'Started signup', value: 4100 }, { label: 'Verified email', value: 2900 }, { label: 'First payment', value: 1240 }]} /> ); } ``` ## Example: Conversion and drop-off `show="both"` with `tableView`. ```tsx import { Funnel } from '@nexub/react'; export default function Example() { return ( <Funnel className="w-full" title="Signup funnel, October" show="both" tableView data={[{ label: 'Visited', value: 12400 }, { label: 'Started signup', value: 4100 }, { label: 'Verified email', value: 2900 }, { label: 'First payment', value: 1240 }]} /> ); } ``` ## Example: Several series Web and app side by side, with conversion. ```tsx import { Funnel } from '@nexub/react'; export default function Example() { return ( <Funnel className="w-full" title="Signup funnel by channel" show="conversion" series={[{ key: 'value', label: 'Web' }, { key: 'app', label: 'App', color: 3 }]} data={[ { label: 'Visited', value: 12400, values: { app: 8200 } }, { label: 'Started signup', value: 4100, values: { app: 3900 } }, { label: 'First payment', value: 1240, values: { app: 1500 } }, ]} /> ); } ``` ## Accessibility - The drawing is hidden from assistive tech; a visually hidden table or caption carries every value. Related: [bar-chart](bar-chart.md), [line-chart](line-chart.md) --- # Gauge Progress toward a target on a 270° arc. - Package: `@nexub/react` · Category: Data Display · Status: beta - Import: `import { Gauge } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/gauge ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `value` (required) | `number` | | Current value. | | `max` | `number` | `100` | Target. | | `title` (required) | `string` | | Accessible name. | | `label` | `ReactNode` | | Centre text; defaults to the percentage. | | `color` | `ChartColor` | `1` | Palette colour, 1–8. | | `tone` | `'good' \| 'warning' \| 'danger'` | | 11.3: success, warning or error colour for the arc; wins over `color`. Pair it with a `caption` so colour is not the only signal. | | `caption` | `ReactNode` | | 11.3: a short line under the value, such as "41 of 50 GB" or "Over budget". Also read with the value. | ## Example: Storage used ```tsx import { Gauge } from '@nexub/react'; export default function Example() { return <Gauge title="Storage used" value={68} max={100} label="68 GB" color={2} />; } ``` ## Example: Tone and caption ```tsx import { Gauge } from '@nexub/react'; export default function Example() { return ( <div className="flex flex-wrap justify-center gap-6"> <Gauge title="Uptime" value={99} tone="good" caption="On target" /> <Gauge title="Storage used" value={82} tone="warning" caption="41 of 50 GB" /> <Gauge title="Budget spent" value={104} label="104%" tone="danger" caption="Over budget" /> </div> ); } ``` ## Accessibility - The drawing is hidden from assistive tech; a visually hidden table or caption carries every value. Related: [bar-chart](bar-chart.md), [line-chart](line-chart.md) --- # Gradient Divider A decorative gradient-faded horizontal rule. - Package: `@nexub/react` · Category: Dividers · Status: stable - Import: `import { GradientDivider } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/gradient-divider ## Example: Default ```tsx import { GradientDivider } from '@nexub/react'; export default function Example() { return <div className="w-70"><GradientDivider /></div>; } ``` --- # Grid CSS Grid layout primitive. - Package: `@nexub/react` · Category: Layout · Status: stable - Import: `import { Grid } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/grid ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `cols` | `number \| string` | | Number of columns or a custom grid-template-columns value. | | `gap` | `'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl'` | | Gap between grid cells using design tokens. | ## Example: 2-column ```tsx import { Grid, Card, Text } from '@nexub/react'; export default function Example() { return ( <Grid cols={2} gap="md" className="w-full max-w-100"> {[1, 2, 3, 4].map((n) => ( <Card key={n}><Text size="body-sm" tone="muted">Card {n}</Text></Card> ))} </Grid> ); } ``` ## Example: 3-column ```tsx import { Grid, Card, Text } from '@nexub/react'; export default function Example() { return ( <Grid cols={3} gap="sm" className="w-full max-w-120"> {[1, 2, 3, 4, 5, 6].map((n) => ( <Card key={n}><Text size="caption" tone="muted">Item {n}</Text></Card> ))} </Grid> ); } ``` --- # Heading Semantic heading component with size, weight, and tone control. - Package: `@nexub/react` · Category: Typography · Status: stable - Import: `import { Heading } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/heading ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `level` | `1 \| 2 \| 3 \| 4 \| 5 \| 6` | `2` | The semantic HTML heading level rendered. | | `size` | `'display' \| 'h1' \| 'h2' \| 'h3' \| 'h4' \| 'h5' \| 'h6'` | | Visual size of the heading, independent of the semantic level. | | `tone` | `'default' \| 'muted' \| 'info' \| 'success' \| 'warning' \| 'danger'` | | Color tone applied to the heading text. | | `weight` | `'regular' \| 'medium' \| 'semibold' \| 'bold' \| 'extrabold'` | | Font weight of the heading. | | `asChild` | `boolean` | | Merges props onto the immediate child element (Radix Slot). | ## Example: Default ```tsx import { Heading } from '@nexub/react'; export default function Example() { return <Heading>The quick brown fox</Heading>; } ``` ## Example: Scale ```tsx import { Heading } from '@nexub/react'; export default function Example() { return ( <div className="flex flex-col gap-2 items-start"> <Heading size="h1">Heading 1</Heading> <Heading size="h2">Heading 2</Heading> <Heading size="h3">Heading 3</Heading> <Heading size="h4">Heading 4</Heading> <Heading size="h5">Heading 5</Heading> </div> ); } ``` ## Example: Tones ```tsx import { Heading } from '@nexub/react'; export default function Example() { return ( <div className="flex flex-col gap-2 items-start"> <Heading tone="info">Info tone</Heading> <Heading tone="success">Success tone</Heading> <Heading tone="warning">Warning tone</Heading> <Heading tone="danger">Danger tone</Heading> </div> ); } ``` --- # Heatmap Intensity over a grid, such as activity by weekday and week, in seven sequential steps. - Package: `@nexub/react` · Category: Data Display · Status: beta - Import: `import { Heatmap } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/heatmap ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `data` (required) | `(number \| null)[][]` | | Rows of values. 11.3: a missing cell (`null`, `undefined` or a hole) is drawn hatched, listed as "—" and left out of the colour range. | | `rowLabels` (required) | `string[]` | | One label per row. | | `columnLabels` | `string[]` | | Used in the hover text. | | `title` (required) | `string` | | Accessible name and table caption. | | `legend` | `boolean` | | 11.3: a low → high scale under the grid with the min and max values, plus a "No data" swatch when cells are missing. | | `tableView` | `boolean \| string` | | 11.3: a "Show as table" disclosure under the drawing with the same data; a string sets its label. | ## Example: Weekly activity ```tsx import { Heatmap } from '@nexub/react'; const days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri']; const data = days.map((_, d) => Array.from({ length: 16 }, (_, w) => ((d * 7 + w * 3) % 11) + (w > 10 ? 4 : 0))); export default function Example() { return <Heatmap className="w-full" title="Payments sent per day, last 16 weeks" rowLabels={days} data={data} />; } ``` ## Example: Missing cells and legend `null` cells are hatched; `legend` shows the scale. ```tsx import { Heatmap } from '@nexub/react'; export default function Example() { return ( <Heatmap className="w-full max-w-md" title="Deploys by day and week" legend tableView rowLabels={['Mon', 'Wed', 'Fri']} columnLabels={['W1', 'W2', 'W3', 'W4', 'W5', 'W6']} data={[[2, 5, null, 3, 9, 4], [6, 1, 7, 10, null, 5], [3, 8, 4, 6, 1, null]]} /> ); } ``` ## Accessibility - The drawing is hidden from assistive tech; a visually hidden table or caption carries every value. Related: [bar-chart](bar-chart.md), [line-chart](line-chart.md) --- # Helper Text Small supporting text placed beneath a form field to provide hints or validation feedback. - Package: `@nexub/react` · Category: Form & Input · Status: stable - Import: `import { HelperText } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/helper-text ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `tone` | `'neutral' \| 'info' \| 'success' \| 'warning' \| 'danger'` | `'neutral'` | Semantic colour tone of the helper text. | | `disabled` | `boolean` | | Applies muted disabled styling. | ## Example: Default ```tsx import { HelperText } from '@nexub/react'; export default function Example() { return <HelperText>We will never share your email with anyone else.</HelperText>; } ``` ## Example: Tones ```tsx import { HelperText } from '@nexub/react'; export default function Example() { return ( <div className="flex flex-col gap-1.5 items-start"> <HelperText tone="info">Sync runs every 10 minutes.</HelperText> <HelperText tone="success">Your account is verified.</HelperText> <HelperText tone="warning">This action cannot be reversed.</HelperText> <HelperText tone="danger">Required field is missing.</HelperText> </div> ); } ``` --- # Hover Card Rich tooltip card revealed on hover. - Package: `@nexub/react` · Category: Overlays · Status: stable - Import: `import { HoverCard } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/hover-card ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `HoverCard.Root` | `compound` | | Root provider that manages open/close state. | | `HoverCard.Trigger` | `compound` | | Element that triggers the card on hover. | | `HoverCard.Content` | `compound` | | The floating card panel shown on hover. | | `openDelay` | `number` | | Delay in milliseconds before the card opens. | | `closeDelay` | `number` | | Delay in milliseconds before the card closes. | ## Example: Default ```tsx import { HoverCard, Link, Avatar, Text } from '@nexub/react'; export default function Example() { return ( <HoverCard.Root> <HoverCard.Trigger asChild> <Link href="#">@alex_johnson</Link> </HoverCard.Trigger> <HoverCard.Content> <div className="flex flex-col gap-2 items-start"> <Avatar name="Alex Johnson" size="lg" /> <div> <Text weight="semibold">Alex Johnson</Text> <Text size="body-sm" tone="muted">Product Designer</Text> </div> <Text size="body-sm" tone="secondary">Building design systems and making developers happy.</Text> </div> </HoverCard.Content> </HoverCard.Root> ); } ``` --- # Icon Button A square button designed to hold a single icon, with an accessible label. - Package: `@nexub/react` · Category: Actions · Status: stable - Import: `import { IconButton } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/icon-button ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `variant` | `'ghost' \| 'solid' \| 'outline' \| 'subtle'` | `'ghost'` | Visual style of the icon button. | | `size` | `'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl'` | `'md'` | Controls button dimensions. | | `disabled` | `boolean` | | Disables the button. | | `loading` | `boolean` | | Shows a spinner and disables interaction. | | `asChild` | `boolean` | | Merges props onto the immediate child element (Radix Slot). | ## Example: Default ```tsx import { IconButton } from '@nexub/react'; export default function Example() { const icon = <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><path d="M12 5v14M5 12h14" /></svg>; return <IconButton variant="ghost" label="Add item">{icon}</IconButton>; } ``` ## Example: Variants ```tsx import { IconButton } from '@nexub/react'; export default function Example() { const icon = <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2"><path d="M12 5v14M5 12h14" /></svg>; return ( <div className="flex gap-2 flex-wrap items-center justify-center"> <IconButton variant="ghost" label="Ghost">{icon}</IconButton> <IconButton variant="solid" label="Solid">{icon}</IconButton> <IconButton variant="outline" label="Outline">{icon}</IconButton> <IconButton variant="subtle" label="Subtle">{icon}</IconButton> </div> ); } ``` --- # Icon Chip An icon on a tinted tile, in one of the category colours or the product accent. - Package: `@nexub/react` · Category: Labels & Badges · Status: alpha - Import: `import { IconChip } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/icon-chip ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `category` | `'accent' \| 'blue' \| 'amber' \| 'emerald' \| 'pink' \| 'violet' \| 'cyan' \| 'red' \| 'lime'` | | Colour of the chip. `accent` is the product accent. Without it the chip is neutral. | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Size of the tile and its icon. | | `shape` | `'square' \| 'circle'` | `'square'` | Rounded square or circle. | ## Example: Default ```tsx import { IconChip } from '@nexub/react'; import { CreditCard } from '@nexub/icons'; export default function Example() { return ( <IconChip category="violet"> <CreditCard /> </IconChip> ); } ``` ## Example: Category colours ```tsx import { Avatar, Badge, CATEGORY_COLORS, IconChip } from '@nexub/react'; import { CreditCard } from '@nexub/icons'; export default function Example() { return ( <div className="flex flex-col gap-3"> {CATEGORY_COLORS.map((c) => ( <div key={c} className="flex items-center gap-4"> <IconChip category={c}> <CreditCard /> </IconChip> <Badge category={c} variant="soft"> {c} </Badge> <Avatar category={c} name="Ada Lovelace" /> </div> ))} </div> ); } ``` ## Example: Sizes and shapes ```tsx import { IconChip } from '@nexub/react'; import { Wallet } from '@nexub/icons'; export default function Example() { return ( <div className="flex items-center gap-3"> <IconChip size="sm" category="emerald"> <Wallet /> </IconChip> <IconChip size="md" category="emerald"> <Wallet /> </IconChip> <IconChip size="lg" category="emerald"> <Wallet /> </IconChip> <IconChip size="lg" category="emerald" shape="circle"> <Wallet /> </IconChip> <IconChip> <Wallet /> </IconChip> </div> ); } ``` Related: [badge](badge.md), [avatar](avatar.md) --- # Icon Picker Pick an icon from @nexub/icons in a searchable grid with recent picks and optional categories. A popover, a bottom sheet on phones. - Package: `@nexub/react` · Category: Form Controls · Status: alpha - Import: `import { IconPicker } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/icon-picker ## When to use - An icon for a space, doc, category or saved view. - The value is the icon’s export name, so it can be stored and drawn later. ## When not to use - An emoji: use EmojiPicker. - Icons outside @nexub/icons: build a grid of your own. ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `value / defaultValue` | `string \| null` | | The picked icon’s export name, e.g. `"CalendarDays"`. `null` for none. | | `onValueChange` | `(name: string) => void` | | Called with the picked name. The picker closes. | | `icons` | `string[]` | | Only these icons, in this order. Default: every @nexub/icons export, A–Z. | | `categories` | `{ label: string; icons: string[] }[]` | | Icons under headings, with a row of buttons to jump between them. Overrides `icons`. | | `placeholder` | `string` | `'Pick an icon'` | Shown on the trigger when nothing is picked. | | `recent` | `string[]` | | Recent picks, newest first. Unset: the last 16 picks are kept in localStorage (`nx-icon-recent`). | | `name` | `string` | | A hidden input posts the value with a plain form. | | `disabled / readOnly / invalid / required` | `boolean` | | Field states, as on Select. Read-only stays focusable and does not open. | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Height of the trigger. | | `sheet` | `boolean \| 'auto'` | `'auto'` | The grid as a bottom sheet below 768px. | | `IconPicker.Panel` | `component` | | The grid alone (`value`, `onValueChange`, `icons`, `categories`, `recent`, `autoFocus`), for any popover or page. | ## Example: Default ```tsx import * as React from 'react'; import { IconPicker } from '@nexub/react'; export default function Example() { const [icon, setIcon] = React.useState<string | null>('CalendarDays'); return <IconPicker aria-label="Menu icon" value={icon} onValueChange={setIcon} />; } ``` ## Example: Categories ```tsx import { IconPicker } from '@nexub/react'; const categories = [ { label: 'Files', icons: ['FileText', 'Folder', 'Paperclip', 'Download'] }, { label: 'People', icons: ['User', 'Users', 'Mail', 'Phone'] }, { label: 'Time', icons: ['Calendar', 'CalendarDays', 'Clock', 'Bell'] }, ]; export default function Example() { return <IconPicker aria-label="Category icon" categories={categories} defaultValue="Folder" />; } ``` ## Example: States ```tsx import { IconPicker } from '@nexub/react'; export default function Example() { return ( <div className="flex flex-wrap gap-4"> <IconPicker aria-label="Invalid" invalid /> <IconPicker aria-label="Read-only" readOnly defaultValue="Star" /> <IconPicker aria-label="Disabled" disabled defaultValue="Bell" /> </div> ); } ``` ## Accessibility - Roles: combobox (trigger), listbox with a group per section, option - `Enter / Space / Arrow Down`: On the trigger: opens the picker with focus in the search box. - `Arrow Down`: From the search box: into the grid. - `Arrow keys`: Move between icons; Arrow Up from the first row returns to the search box. - `Home / End`: First or last icon in the row; with Ctrl, in the whole list. - `Enter / Space`: Picks the focused icon. Enter in the search box picks the first result. - `Escape`: Closes without changing the value. - Each icon is named from its export name ("ArrowUpRight" reads "Arrow up right"). - The icon set is loaded with a dynamic import when the picker opens or shows a value. Related: [emoji-picker](emoji-picker.md), [icon](icon.md), [combobox-field](combobox-field.md) --- # Illustration A spot illustration for an empty, error or full-page state, drawn in code so it follows the theme, dark mode and the product accent. - Package: `@nexub/react` · Category: Data Display · Status: alpha - Import: `import { Illustration } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/illustration ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `kind` (required) | `'noData' \| 'noResults' \| 'noAccess' \| 'serverError' \| 'offline' \| 'notFound' \| 'maintenance'` | | Which drawing to show. | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | 80, 120 or 160 CSS px wide. | | `title` | `string` | | Names the drawing for assistive technology. Without it the drawing is decorative. | ## Example: Default ```tsx import { Illustration } from '@nexub/react'; export default function Example() { return <Illustration kind="noData" />; } ``` ## Example: Kinds ```tsx import { Illustration } from '@nexub/react'; const kinds = ['noData', 'noResults', 'noAccess', 'serverError', 'offline', 'notFound', 'maintenance'] as const; export default function Example() { return ( <div className="flex flex-wrap justify-center gap-6"> {kinds.map((kind) => ( <Illustration key={kind} kind={kind} title={kind} /> ))} </div> ); } ``` Related: [empty-state](empty-state.md), [error-state](error-state.md) --- # Inline Edit Text that becomes an input on click, for renaming things in place. - Package: `@nexub/react` · Category: Form & Input · Status: beta - Import: `import { InlineEdit } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/inline-edit ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `value` (required) | `string` | | The saved text. | | `onSave` (required) | `(value: string) => void \| Promise` | | Called on Enter or blur when the text changed. A promise keeps the field open and busy; a rejection keeps it open and invalid. | | `label` (required) | `string` | | Names the input, and the button reads "Edit ‹label›, ‹value›". | | `placeholder` | `string` | | Shown when the value is empty. | | `disabled` | `boolean` | | Shows the text without editing. | | `size` | `'sm' \| 'md' \| 'lg' \| 'title' \| 'headline'` | `'md'` | 11.5. Type role of the text and the input: body small, medium, large, title large or headline small. With `as` and no `size`, the text takes the wrapper’s type. | | `as` | `ElementType` | | 11.5. Wraps the text, and the input while editing, in this element: a heading (`"h2"`) or a component such as `Sheet.Title` or `Dialog.Title`, so the heading and the dialog’s name stay in place. | | `maxLength` | `number` | | 11.5. Caps the input and shows a "12/40" counter, announced near the limit. | ## Example: Rename ```tsx 'use client'; import * as React from 'react'; import { InlineEdit } from '@nexub/react'; export default function Example() { const [name, setName] = React.useState('Q4 launch plan'); return ( <InlineEdit label="Project name" placeholder="Add a name" value={name} onSave={(next) => { if (!next.trim()) return Promise.reject(new Error('Name is required')); setName(next.trim()); }} /> ); } ``` ## Example: Editable page title A headline inside an `h2`, capped at 40 characters. ```tsx import * as React from 'react'; import { InlineEdit } from '@nexub/react'; export default function Example() { const [title, setTitle] = React.useState('Quarterly roadmap'); return ( <InlineEdit as="h2" size="headline" maxLength={40} label="Page title" value={title} onSave={(next) => setTitle(next.trim() || title)} /> ); } ``` ## Accessibility - `Enter / Space`: On the text: starts editing. - `Enter`: In the input: saves. - `Escape`: Reverts and returns focus to the text. - Moving focus away saves too. Validate in `onSave` and reject to keep the field open. Related: [input](input.md), [form](form.md) --- # Input Text input field for forms. Supports size variants, icons, addons, and validation states. - Package: `@nexub/react` · Category: Form & Input · Status: stable - Import: `import { Input } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/input ## When to use - Capturing short free-form text (name, email, search term) - Single-line data entry within a form - Filtering or searching a list of items - Inline editing of a single value ## When not to use - Multi-line text — use Textarea instead - Choosing from a fixed list of options — use Select or Combobox - Numeric stepping — use NumberInput for increment/decrement control - Passwords — use PasswordInput which toggles visibility ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Control height and font size. | | `invalid` | `boolean` | `false` | Applies error ring styling. | | `disabled` | `boolean` | `false` | Disables the input. | | `placeholder` | `string` | | Placeholder text. | | `type` | `string` | `'text'` | HTML input type attribute. | | `leadingIcon` | `React.ReactNode` | | Icon rendered at the start of the input. | | `trailingIcon` | `React.ReactNode` | | Icon rendered at the end of the input. | | `leadingAddon` | `string` | | Text addon rendered before the input (e.g. "https://"). | | `trailingAddon` | `string` | | Text addon rendered after the input (e.g. ".com"). | ## Example: Default ```tsx import { Input } from '@nexub/react'; export default function Example() { return <div className="w-70"><Input placeholder="Enter value…" /></div>; } ``` ## Example: Sizes ```tsx import { Input } from '@nexub/react'; export default function Example() { return ( <div className="flex flex-col gap-2 items-start w-70"> <Input size="sm" placeholder="Small" /> <Input size="md" placeholder="Medium" /> <Input size="lg" placeholder="Large" /> </div> ); } ``` ## Example: Invalid state ```tsx import { Input } from '@nexub/react'; export default function Example() { return <div className="w-70"><Input invalid placeholder="Invalid value" /></div>; } ``` ## Example: With label and helper ```tsx import { Label, Input, HelperText } from '@nexub/react'; export default function Example() { return ( <div className="flex flex-col gap-1 items-start w-70"> <Label htmlFor="demo-email">Email address</Label> <Input id="demo-email" type="email" placeholder="you@example.com" /> <HelperText>We'll never share your email.</HelperText> </div> ); } ``` ## Accessibility - Roles: textbox - `Tab`: Moves focus to the input. - `Esc`: Browsers may revert recent changes (autofill suggestions). - Visible focus ring on `:focus-visible`. Pair with a `<Label htmlFor>` so clicking the label moves focus into the field. - `invalid` toggles `aria-invalid="true"` so AT users hear the error state. - Use `aria-describedby` to associate `HelperText` or error messages. Related: [textarea](textarea.md), [number-input](number-input.md), [password-input](password-input.md), [search-input](search-input.md) --- # Kanban Columns of cards people move by dragging or with Alt+Arrow keys. - Package: `@nexub/react` · Category: Data Display · Status: beta - Import: `import { Kanban } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/kanban ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `columns` (required) | `{ id, title, items: T[] }[]` | | The board. | | `getId / getLabel` (required) | `(item) => string` | | Stable key and the name read when it moves. | | `onChange` (required) | `(columns) => void` | | Called with the columns after a move; store them (and save to your server). | | `renderCard` (required) | `(item) => ReactNode` | | The card’s content. | | `onChange` | `(columns, move: { item, from, to }) => void` | | 11.4: the second argument names the moved card and its column and lane before and after. | | `readOnly` | `boolean` | | 11.4: no drag handles, no keyboard moves. | | `canMove` | `(move: { item, from, to }) => boolean` | | 11.4: refuse a target before the card lands (a WIP limit, a rule); the drop mark does not show and the keyboard announces it. | | `dropTargets` | `{ id, label, icon?, onDrop(item, from) }[]` | | 11.4: areas outside the columns (Archive, Trash). Alt+Arrow keys reach them after the last column. | | `renderColumnHeader / renderColumnFooter` | `(column, …) => ReactNode` | | 11.4: replace the header (WIP badge, actions); add a slot under the cards (quick add). | | `lanes / getLane` | `{ id, title }[] / (item) => string` | | 11.4: swimlanes: one row of columns per lane. | | `getTone` | `(item) => 'info' \| 'success' \| 'warning' \| 'danger' \| undefined` | | 11.4: a coloured edge on the card; say the meaning in the card text too. | | `columnWidth` | `'sm' \| 'md' \| 'lg'` | `'md'` | 11.4: 15, 18 or 24rem. | ## Example: Task board ```tsx 'use client'; import * as React from 'react'; import { Badge, Kanban, type KanbanColumn } from '@nexub/react'; type Task = { id: string; title: string; tag?: string }; export default function Example() { const [columns, setColumns] = React.useState<KanbanColumn<Task>[]>([ { id: 'todo', title: 'To do', items: [{ id: '1', title: 'Write release notes', tag: 'Docs' }, { id: '2', title: 'Update pricing page' }] }, { id: 'doing', title: 'In progress', items: [{ id: '3', title: 'Billing migration', tag: 'Backend' }] }, { id: 'done', title: 'Done', items: [{ id: '4', title: 'Hire designer' }] }, ]); return ( <Kanban columns={columns} getId={(t) => t.id} getLabel={(t) => t.title} onChange={setColumns} renderCard={(t) => ( <div className="flex flex-col items-start gap-1"> {t.title} {t.tag && <Badge>{t.tag}</Badge>} </div> )} /> ); } ``` ## Example: Workflow: lanes, WIP limit, archive ```tsx import * as React from 'react'; import { Kanban, type KanbanColumn } from '@nexub/react'; type Ticket = { id: string; title: string; owner: string; high?: boolean }; const start: KanbanColumn<Ticket>[] = [ { id: 'todo', title: 'To do', items: [{ id: 't1', title: 'Renew SSL certificate', owner: 'ana', high: true }, { id: 't2', title: 'Update pricing page', owner: 'ben' }] }, { id: 'doing', title: 'Doing', items: [{ id: 't3', title: 'Migrate invoices', owner: 'ana' }] }, { id: 'done', title: 'Done', items: [] }, ]; const WIP = 2; export default function Example() { const [cols, setCols] = React.useState(start); const [archived, setArchived] = React.useState<string[]>([]); return ( <div className="flex w-full flex-col gap-2"> <Kanban columns={cols} getId={(t) => t.id} getLabel={(t) => t.title} lanes={[{ id: 'ana', title: 'Ana' }, { id: 'ben', title: 'Ben' }]} getLane={(t) => t.owner} onChange={(next, { item, to }) => setCols(next.map((c) => ({ ...c, items: c.items.map((t) => (t.id === item.id && to.laneId ? { ...t, owner: to.laneId } : t)) }))) } canMove={({ to }) => to.columnId !== 'doing' || cols[1]!.items.length < WIP} renderColumnHeader={(c, count) => ( <span className="flex w-full items-center justify-between"> {c.title} <span className="text-label-md font-normal text-on-surface-muted">{c.id === 'doing' ? `${count} / ${WIP}` : count}</span> </span> )} getTone={(t) => (t.high ? 'danger' : undefined)} columnWidth="sm" dropTargets={[{ id: 'archive', label: 'Archive', onDrop: (t) => setArchived((a) => [...a, t.title]) }]} renderCard={(t) => ( <span className="flex flex-col"> {t.title} {t.high && <span className="text-label-sm text-error">High priority</span>} </span> )} /> <p className="text-body-sm text-on-surface-muted">Archived: {archived.join(', ') || '—'}</p> </div> ); } ``` ## Accessibility - `Alt+ArrowUp / Alt+ArrowDown`: On a handle: moves the card within its column. - `Alt+ArrowLeft / Alt+ArrowRight`: Moves the card to the previous or next column. Mirrored in RTL. - Each column is a region named by its heading. Moves are announced: "Bravo moved to Done, position 2 of 2". Related: [sortable](sortable.md) --- # Kbd Keyboard key display — renders a styled <kbd> element. - Package: `@nexub/react` · Category: Inline Primitives · Status: stable - Import: `import { Kbd } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/kbd ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `...props` | `React.HTMLAttributes<HTMLElement>` | | All standard kbd HTML attributes are forwarded. | ## Example: Default ```tsx import { Kbd } from '@nexub/react'; export default function Example() { return ( <div className="flex gap-1 flex-wrap items-center justify-center"> <Kbd>⌘</Kbd> <Kbd>K</Kbd> </div> ); } ``` ## Example: Combinations ```tsx import { Kbd, Text } from '@nexub/react'; export default function Example() { return ( <div className="flex flex-col gap-2 items-start"> <div className="flex gap-1 flex-wrap items-center justify-center"><Kbd>⌘</Kbd><Kbd>K</Kbd><Text size="body-sm" tone="secondary">— Open search</Text></div> <div className="flex gap-1 flex-wrap items-center justify-center"><Kbd>⌃</Kbd><Kbd>C</Kbd><Text size="body-sm" tone="secondary">— Copy</Text></div> <div className="flex gap-1 flex-wrap items-center justify-center"><Kbd>⇧</Kbd><Kbd>⌘</Kbd><Kbd>P</Kbd><Text size="body-sm" tone="secondary">— Command palette</Text></div> </div> ); } ``` --- # Keyboard Shortcut A key combination as `Kbd` keys joined by plus signs, read as one label. - Package: `@nexub/react` · Category: Inline Primitives · Status: stable - Import: `import { KeyboardShortcut } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/keyboard-shortcut ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `keys` | `string[]` | | The keys in order, e.g. `['⌘', 'K']`. Read as "⌘+K" (`aria-label`); pass your own `aria-label` for a spoken form like "Command K". | ## Example: Default ```tsx import { KeyboardShortcut } from '@nexub/react'; export default function Example() { return ( <div className="flex flex-wrap items-center gap-4"> <KeyboardShortcut keys={['⌘', 'K']} aria-label="Command K" /> <KeyboardShortcut keys={['Ctrl', 'Shift', 'P']} /> </div> ); } ``` ## Example: In a menu ```tsx import { KeyboardShortcut, Text } from '@nexub/react'; const rows = [ { label: 'Search', keys: ['⌘', 'K'], spoken: 'Command K' }, { label: 'New project', keys: ['⌘', 'N'], spoken: 'Command N' }, { label: 'Save', keys: ['⌘', 'S'], spoken: 'Command S' }, ]; export default function Example() { return ( <ul className="flex w-65 flex-col gap-2"> {rows.map((r) => ( <li key={r.label} className="flex items-center justify-between"> <Text size="body-sm">{r.label}</Text> <KeyboardShortcut keys={r.keys} aria-label={r.spoken} /> </li> ))} </ul> ); } ``` Related: [kbd](kbd.md), [command-palette](command-palette.md) --- # KPI Tile A headline number with its change versus last period and a trend line. - Package: `@nexub/react` · Category: Data Display · Status: beta - Import: `import { KpiTile } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/kpi-tile ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `label` (required) | `string` | | What the number is. | | `value` (required) | `ReactNode` | | The formatted number. | | `change` | `number` | | Change as a fraction, e.g. 0.114 for +11.4%. | | `invert` | `boolean` | `false` | Down is good (churn, costs): flips the colour. | | `trend` | `number[]` | | Recent values for the sparkline, oldest first. | ## Example: Dashboard row ```tsx import { KpiTile } from '@nexub/react'; export default function Example() { return ( <div className="grid w-full gap-3 sm:grid-cols-3"> <KpiTile label="Monthly revenue" value="$68,420" change={0.114} trend={[42, 48, 45, 56, 61, 68]} /> <KpiTile label="Customers" value="1,204" change={0.032} trend={[1080, 1100, 1150, 1170, 1190, 1204]} /> <KpiTile label="Churn" value="2.1%" change={0.004} invert trend={[1.8, 1.9, 2.0, 1.9, 2.0, 2.1]} /> </div> ); } ``` ## Accessibility - The drawing is hidden from assistive tech; a visually hidden table or caption carries every value. Related: [bar-chart](bar-chart.md), [line-chart](line-chart.md) --- # Label An accessible form label that optionally shows a required asterisk and links to an input via htmlFor. - Package: `@nexub/react` · Category: Form & Input · Status: stable - Import: `import { Label } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/label ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `htmlFor` | `string` | | Associates the label with a form control by its id. | | `required` | `boolean` | | Renders a required indicator (asterisk) after the label text. | | `disabled` | `boolean` | | Applies disabled styling to the label. | | `size` | `'sm' \| 'md'` | `'md'` | Controls label font size. | ## Example: Default ```tsx import { Label } from '@nexub/react'; export default function Example() { return <Label htmlFor="demo">Full name</Label>; } ``` ## Example: Required ```tsx import { Label } from '@nexub/react'; export default function Example() { return <Label required>Email address</Label>; } ``` ## Example: With input ```tsx import { Label, Input } from '@nexub/react'; export default function Example() { return ( <div className="flex flex-col gap-1 items-start w-70"> <Label htmlFor="email-ex">Email</Label> <Input id="email-ex" type="email" placeholder="you@example.com" /> </div> ); } ``` --- # Line Chart Show a trend over ordered categories such as time. Server-rendered SVG on the chart palette. - Package: `@nexub/react` · Category: Data Display · Status: beta - Import: `import { LineChart } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/line-chart ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `title` (required) | `string` | | Accessible name of the chart and caption of its data table. | | `data` (required) | `T[]` | | One row per category, in order. | | `index` (required) | `keyof T` | | Key of the category label in each row (the x axis). | | `series` (required) | `ChartSeries[]` | | `{ key, label?, color? }` per series. `color` is 1–8 from the categorical chart palette; defaults to the series position. | | `valueFormat` | `(value: number) => string` | | Formats axis labels, hover text and the data table. | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Plot height: 8, 12 or 16rem. | | `legend` | `boolean` | | Show the legend. Defaults to on for more than one series. | | `area` | `boolean` | `false` | Fill the area under each line. | | `series[].color` | `1–8 \| 'good' \| 'warning' \| 'danger' \| 'neutral'` | | 11.3: a palette colour or a semantic tone. | | `series[].valueFormat` | `(value: number) => string` | | 11.3: formats this series in the tooltip and table (one currency per series). | | `integerTicks` | `boolean` | | 11.3: gridlines on whole numbers only (counts). Also 11.3: a `null` or missing value is drawn as a gap (no bar, a break in the line) and listed as "—", not counted as 0. | | `tableView` | `boolean \| string` | | 11.3: a visible "Show as table" disclosure with the same data. Works without JS. | ## Example: Two series ```tsx import { LineChart } from '@nexub/react'; const data = [ { week: 'W1', active: 820, trial: 310 }, { week: 'W2', active: 870, trial: 290 }, { week: 'W3', active: 905, trial: 340 }, { week: 'W4', active: 960, trial: 330 }, { week: 'W5', active: 1010, trial: 360 }, { week: 'W6', active: 1080, trial: 355 }, ]; export default function Example() { return ( <LineChart className="w-full" title="Weekly users" data={data} index="week" series={[{ key: 'active', label: 'Active' }, { key: 'trial', label: 'Trial' }]} /> ); } ``` ## Example: Area ```tsx import { LineChart } from '@nexub/react'; const data = [ { day: 'Mon', p95: 210 }, { day: 'Tue', p95: 190 }, { day: 'Wed', p95: 240 }, { day: 'Thu', p95: 205 }, { day: 'Fri', p95: 180 }, ]; export default function Example() { return ( <LineChart area size="sm" className="w-full" title="API latency, p95" data={data} index="day" series={[{ key: 'p95', label: 'p95 latency', color: 6 }]} valueFormat={(v) => `${v} ms`} /> ); } ``` ## Example: Gaps and one currency per series ```tsx import { LineChart } from '@nexub/react'; const months = [ { month: 'Jan', usd: 12400, myr: 31000 }, { month: 'Feb', usd: 13100, myr: null }, { month: 'Mar', usd: null, myr: 35500 }, { month: 'Apr', usd: 15800, myr: 38200 }, ]; const usd = (v: number) => new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', maximumFractionDigits: 0 }).format(v); const myr = (v: number) => new Intl.NumberFormat('en-MY', { style: 'currency', currency: 'MYR', maximumFractionDigits: 0 }).format(v); export default function Example() { return ( <LineChart className="w-full max-w-2xl" title="Revenue by currency" data={months} index="month" tableView series={[{ key: 'usd', label: 'USD', valueFormat: usd }, { key: 'myr', label: 'MYR', valueFormat: myr }]} /> ); } ``` ## Accessibility - The chart is a `figure` named by `title`. The drawing is hidden from assistive tech; a visually hidden table carries every value. - Colour is never the only cue: the legend and table name each series. Past six series, label directly or group the rest as "Other". Related: [bar-chart](bar-chart.md), [sparkline](sparkline.md) --- # Link Styled anchor link with variant and external support. - Package: `@nexub/react` · Category: Inline Primitives · Status: stable - Import: `import { Link } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/link ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `variant` | `'default' \| 'muted' \| 'underline'` | | Visual style of the link. | | `external` | `boolean` | | Opens the link in a new tab with appropriate rel attributes. | | `href` | `string` | | The URL the link points to. | | `asChild` | `boolean` | | Merges props onto the immediate child element (Radix Slot). | ## Example: Default ```tsx import { Link } from '@nexub/react'; export default function Example() { return <Link href="#">View documentation</Link>; } ``` ## Example: Variants ```tsx import { Link } from '@nexub/react'; export default function Example() { return ( <div className="flex gap-4 flex-wrap items-center justify-center"> <Link href="#" variant="default">Default</Link> <Link href="#" variant="muted">Muted</Link> <Link href="#" variant="underlined">Underline</Link> </div> ); } ``` ## Example: External ```tsx import { Link } from '@nexub/react'; export default function Example() { return <Link href="#" external>Open in new tab</Link>; } ``` --- # Logo The Nexub mark and wordmark, with an optional product name. - Package: `@nexub/react` · Category: Inline Primitives · Status: stable - Import: `import { Logo } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/logo ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `variant` | `'full' \| 'icon' \| 'mark'` | | `full` = mark and wordmark; `icon` = the mark only. `mark` is the old name for `icon`. | | `product` | `string` | | Product name after the wordmark, e.g. "Command Hub". Truncates in a narrow container. Ignored for `icon`. | | `size` | `'sm' \| 'md' \| 'lg'` | | Height: 24, 32 or 40 px. | | `tone` | `'default' \| 'inverse'` | | `inverse` is always white, for dark backgrounds or imagery in either theme. | | `mark` | `'color' \| 'mono'` | | `color` = the official mark in brand colours; `mono` = `currentColor`. | ## Example: Variants ```tsx import { Logo } from '@nexub/react'; export default function Example() { return ( <div className="flex flex-wrap items-center gap-6"> <Logo /> <Logo variant="icon" /> <Logo mark="mono" /> <span className="rounded-shape-container bg-inverse-surface p-3"> <Logo tone="inverse" /> </span> </div> ); } ``` ## Example: With a product name ```tsx import { Logo } from '@nexub/react'; export default function Example() { return ( <div className="flex flex-col items-start gap-4"> <Logo product="Command Hub" size="sm" /> <Logo product="Command Hub" /> <Logo product="Command Hub" size="lg" /> </div> ); } ``` ## Accessibility - Roles: img - Read as "Nexub", or "Nexub Command Hub" with `product`. Related: [top-nav](top-nav.md), [sidebar](sidebar.md) --- # Media Card An image card with a glass caption over a soft scrim. With `href`, the whole card is one link. - Package: `@nexub/react` · Category: Layout · Status: beta - Import: `import { MediaCard } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/media-card ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `src` (required) | `string` | | Image URL. Loaded lazily. | | `alt` (required) | `string` | | Image description. Pass '' when the image is decorative. | | `ratio` | `'16/9' \| '4/3' \| '1/1' \| '3/4'` | `'16/9'` | Aspect ratio of the image box. | | `title` | `ReactNode` | | Caption title, rendered as an h3. | | `description` | `ReactNode` | | Caption text under the title. | | `eyebrow` | `ReactNode` | | Small label above the title. | | `href` | `string` | | Makes the whole card one link, stretched from the title (so it needs `title`). Adds the hover lift and image zoom. | | `children` | `ReactNode` | | Actions under the caption. They stay clickable above the stretched link. | ## Example: With link ```tsx import { MediaCard } from '@nexub/react'; // Gradient placeholder image: a data: URI keeps it inside the docs CSP (img-src 'self' data:). const COVER = 'data:image/svg+xml;utf8,' + encodeURIComponent( '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 300"><defs><linearGradient id="g" x2="1" y2="1"><stop offset="0" stop-color="#0e7490"/><stop offset="1" stop-color="#f59e0b"/></linearGradient></defs><rect width="400" height="300" fill="url(#g)"/></svg>', ); export default function Example() { return ( <div className="w-80"> <MediaCard src={COVER} alt="" eyebrow="Guide" title="A weekend in Lisbon" description="Where to eat, walk and stay." href="#" /> </div> ); } ``` ## Example: Without link, with actions ```tsx import { MediaCard, Button } from '@nexub/react'; // Gradient placeholder image: a data: URI keeps it inside the docs CSP (img-src 'self' data:). const COVER = 'data:image/svg+xml;utf8,' + encodeURIComponent( '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 300"><defs><linearGradient id="g" x2="1" y2="1"><stop offset="0" stop-color="#0e7490"/><stop offset="1" stop-color="#f59e0b"/></linearGradient></defs><rect width="400" height="300" fill="url(#g)"/></svg>', ); export default function Example() { return ( <div className="w-80"> <MediaCard src={COVER} alt="" title="Q3 brand shoot" description="48 photos"> <Button size="sm" variant="tonal">Open</Button> <Button size="sm" variant="text">Share</Button> </MediaCard> </div> ); } ``` ## Example: Ratios ```tsx import { MediaCard } from '@nexub/react'; // Gradient placeholder image: a data: URI keeps it inside the docs CSP (img-src 'self' data:). const COVER = 'data:image/svg+xml;utf8,' + encodeURIComponent( '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 300"><defs><linearGradient id="g" x2="1" y2="1"><stop offset="0" stop-color="#0e7490"/><stop offset="1" stop-color="#f59e0b"/></linearGradient></defs><rect width="400" height="300" fill="url(#g)"/></svg>', ); export default function Example() { return ( <div className="flex gap-3 flex-wrap items-start justify-center"> {(['16/9', '4/3', '1/1', '3/4'] as const).map((r) => ( <div key={r} className="w-40"> <MediaCard ratio={r} src={COVER} alt="" title={r} /> </div> ))} </div> ); } ``` ## Accessibility - Roles: link (when `href` is set), heading level 3 (title) - `Tab`: Focuses the link (the card shows the focus ring), then any actions. - `Enter`: Follows the link. - With `href`, the link’s name is the title only, not the whole caption. - Most card images repeat the title, so `alt=""` is usually right. Related: [card](card.md) --- # Menubar A horizontal bar of menus, like a desktop app’s File / Edit / View, built on Radix. - Package: `@nexub/react` · Category: Navigation · Status: stable - Import: `import { Menubar } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/menubar ## When to use - Editors and tools with many commands grouped like a desktop app ## When not to use - Site navigation: use `NavigationMenu` or `TopNav` - A few icon actions: use `Toolbar` ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `Menubar.Root` | `compound` | | The bar (`value`, `onValueChange`, `loop`). | | `Menubar.Menu` | `compound` | | One menu: a trigger and its content. | | `Menubar.Trigger` | `compound` | | The menu’s button in the bar. | | `Menubar.Portal / Content` | `compound` | | Renders the floating menu in a portal (`sideOffset` default 8). | | `Menubar.Item` | `compound` | | An action (`onSelect`, `disabled`). | | `Menubar.CheckboxItem / RadioGroup / RadioItem` | `compound` | | Toggle and single-choice items. | | `Menubar.Label / Group / Separator / Arrow` | `compound` | | Section heading, grouping, divider and an optional arrow. | | `Menubar.Sub / SubTrigger / SubContent` | `compound` | | A nested submenu. | ## Example: Default ```tsx import { Menubar } from '@nexub/react'; export default function Example() { return ( <Menubar.Root> <Menubar.Menu> <Menubar.Trigger>File</Menubar.Trigger> <Menubar.Portal> <Menubar.Content> <Menubar.Item>New file</Menubar.Item> <Menubar.Item>Open…</Menubar.Item> <Menubar.Separator /> <Menubar.Item>Save</Menubar.Item> </Menubar.Content> </Menubar.Portal> </Menubar.Menu> <Menubar.Menu> <Menubar.Trigger>Edit</Menubar.Trigger> <Menubar.Portal> <Menubar.Content> <Menubar.Item>Undo</Menubar.Item> <Menubar.Item>Redo</Menubar.Item> <Menubar.Separator /> <Menubar.Item>Copy</Menubar.Item> <Menubar.Item>Paste</Menubar.Item> </Menubar.Content> </Menubar.Portal> </Menubar.Menu> <Menubar.Menu> <Menubar.Trigger>View</Menubar.Trigger> <Menubar.Portal> <Menubar.Content> <Menubar.Item>Zoom in</Menubar.Item> <Menubar.Item>Zoom out</Menubar.Item> </Menubar.Content> </Menubar.Portal> </Menubar.Menu> </Menubar.Root> ); } ``` ## Accessibility - Roles: menubar, menu, menuitem - `Arrow Left / Right`: Moves between menus in the bar, and between open menus. - `Enter / Space / Arrow Down`: Opens the focused menu. - `Escape`: Closes the menu. Related: [dropdown-menu](dropdown-menu.md), [toolbar](toolbar.md), [context-menu](context-menu.md) --- # Message Bubble One message in a conversation. User messages sit in a bubble at the end; assistant replies run full width. MessageActions adds copy, feedback and regenerate. - Package: `@nexub/react` · Category: AI · Status: beta - Import: `import { MessageBubble } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/message-bubble ## When to use - Each turn in a chat or assistant thread, inside Conversation. - MessageActions under assistant replies the user may want to copy, rate or retry. ## When not to use - Comment threads and activity logs: use ActivityFeed or NotificationItem. - Model output as HTML: render text or React elements as children, never `dangerouslySetInnerHTML`. ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `from` (required) | `'user' \| 'assistant' \| 'system' \| 'other'` | | Who sent it. Sets layout and the default accessible name. `other` (11.5) is a third party in a group conversation. | | `avatar` | `ReactNode` | | Assistant and other: shown at the inline start. | | `name` | `string` | | Accessible name of the message. Defaults to "You said" or "Assistant said". With `from="other"` it is also shown as the header. | | `meta` | `ReactNode` | | 11.5: header text beside the name, e.g. the time. | | `status` | `'sending' \| 'error'` | | `sending` sets `aria-busy`; `error` shows "Failed to send". | | `onRetry` | `() => void` | | With `status="error"`, adds a Retry button. | | `messages` | `Partial<MessageStrings>` | | Local string overrides. | | `MessageActions text` | `string` | | Text Copy puts on the clipboard. | | `MessageActions copy` | `boolean` | `true` | Set false to hide Copy. | | `MessageActions feedback / defaultFeedback / onFeedback` | `'up' \| 'down' \| null` | | Thumbs up/down appear when `onFeedback` is set. Pressing the active one clears it. | | `MessageActions onRegenerate` | `() => void` | | Shows Regenerate when set. | | `MessageActions actions` | `{ label: string; icon: ReactNode; onSelect: () => void; disabled?: boolean }[]` | | 11.5: your own icon buttons after the built-in ones. `children` render after these. | ## Example: Conversation Hover or focus the assistant reply to show its actions. ```tsx import { MessageBubble, Avatar, MessageActions, toast } from '@nexub/react'; import { Sparkles } from '@nexub/icons'; export default function Example() { return ( <div className="flex flex-col gap-4 items-stretch w-full max-w-140"> <MessageBubble from="user">How do I cancel my subscription?</MessageBubble> <MessageBubble from="assistant" avatar={<Avatar size="sm" fallback={<Sparkles />} />}> <p>Open Settings, then Billing, and choose Cancel plan. You keep access until the end of the billing period.</p> <MessageActions text="Open Settings, then Billing, and choose Cancel plan." onFeedback={() => {}} onRegenerate={() => toast.info('Regenerating…')} /> </MessageBubble> <MessageBubble from="system">Conversation moved to Billing support</MessageBubble> </div> ); } ``` ## Example: Failed to send ```tsx import { MessageBubble, toast } from '@nexub/react'; export default function Example() { return ( <div className="w-full max-w-140"> <MessageBubble from="user" status="error" onRetry={() => toast.info('Retrying…')}> Can I get a refund for last month? </MessageBubble> </div> ); } ``` ## Example: Group thread A third party with a name and time header, and a custom Pin action. ```tsx import { MessageBubble, Avatar, MessageActions, toast } from '@nexub/react'; import { Pin, Sparkles } from '@nexub/icons'; const REPLY = 'I moved the review to Thursday at 10:00 and told the team.'; export default function Example() { return ( <div className="flex flex-col gap-4 items-stretch w-full max-w-140"> <MessageBubble from="other" name="Ada Lovelace" meta="09:40" avatar={<Avatar size="sm" fallback="AL" />}> Can we move the review to Thursday? </MessageBubble> <MessageBubble from="user" meta="09:41"> Thursday works for me. </MessageBubble> <MessageBubble from="assistant" meta="09:41" avatar={<Avatar size="sm" fallback={<Sparkles />} />}> <p>{REPLY}</p> <MessageActions text={REPLY} actions={[{ label: 'Pin to thread', icon: <Pin size="sm" aria-hidden="true" />, onSelect: () => toast.info('Pinned') }]} /> </MessageBubble> </div> ); } ``` ## Accessibility - Roles: article (each message), alert (send error), button (actions) - `Tab`: Moves through the action buttons; focusing one reveals the row. - `Space / Enter`: Activates an action. Feedback buttons toggle. - Each message is an `article` named "You said" or "Assistant said", so users can jump between messages. - Feedback buttons expose `aria-pressed`. Copy announces "Copied" through a status region. - The action row is only visually hidden until hover; it stays in the tab order and accessibility tree. Related: [streaming-text](streaming-text.md), [conversation](conversation.md), [citation](citation.md) --- # Money Input An amount field: locale-aware parsing as you type, grouped on blur, the currency symbol leading. - Package: `@nexub/react` · Category: Form & Input · Status: beta - Import: `import { MoneyInput } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/money-input ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `currency` (required) | `string` | | ISO 4217 code, e.g. "EUR". | | `locale` | `string` | | BCP 47 locale for separators. Defaults to the user's. | | `value / defaultValue` | `number \| null` | | The amount, or null when empty. | | `onValueChange` | `(value: number \| null) => void` | | Parsed amount, rounded to the minor unit, as the person types. | | `currencySlot` | `ReactNode` | | 11.2: shown before the amount, e.g. a CurrencySelect. | ## Example: Default ```tsx import { MoneyInput } from '@nexub/react'; export default function Example() { return <MoneyInput aria-label="Amount to send" currency="USD" defaultValue={1250} />; } ``` ## Example: German separators ```tsx import { MoneyInput } from '@nexub/react'; export default function Example() { return <MoneyInput aria-label="Betrag" currency="EUR" locale="de-DE" defaultValue={1234.5} />; } ``` Related: [amount](amount.md), [number-input](number-input.md), [input](input.md) --- # Collapse Expands and collapses content along the block axis. - Package: `@nexub/react` · Category: Motion · Status: stable - Import: `import { MotionCollapse } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/motion-collapse ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `in` (required) | `boolean` | | When true, expands the content to its natural height. When false, collapses it to zero height. | | `duration` | `'instant' \| 'fast' \| 'normal' \| 'slow' \| 'slower'` | `'normal'` | Controls the animation speed using the design token scale. | | `unmountOnExit` | `boolean` | `false` | Removes the element from the DOM after the collapse animation completes. | | `as` | `React.ElementType` | `'div'` | The HTML element or component to render as the wrapper. | | `children` (required) | `React.ReactNode` | | Content to expand and collapse. | ## Example: Default ```tsx import { Collapse, Text } from '@nexub/react'; export default function Example() { return ( <Collapse in> <div className="p-4 bg-surface-container-low rounded-shape-field"> <Text size="body-sm">Collapsed content goes here.</Text> </div> </Collapse> ); } ``` ## Example: Toggle ```tsx import * as React from 'react'; import { Button, Collapse, Text } from '@nexub/react'; export default function Example() { const [visible, setVisible] = React.useState(true); return ( <div className="flex flex-col gap-3 items-start"> <Button variant="outlined" onClick={() => setVisible((v) => !v)}> {visible ? 'Collapse' : 'Expand'} </Button> <Collapse in={visible}> <div className="p-4 bg-surface-container-low rounded-shape-field"> <Text size="body-sm">This content collapses and expands smoothly.</Text> </div> </Collapse> </div> ); } ``` --- # Fade Animates opacity between 0 and 1 based on the `in` prop. - Package: `@nexub/react` · Category: Motion · Status: stable - Import: `import { MotionFade } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/motion-fade ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `in` (required) | `boolean` | | When true, fades content in. When false, fades it out. | | `duration` | `'instant' \| 'fast' \| 'normal' \| 'slow' \| 'slower'` | `'normal'` | Controls the animation speed using the design token scale. | | `unmountOnExit` | `boolean` | `false` | Removes the element from the DOM after the exit animation completes. | | `as` | `React.ElementType` | `'div'` | The HTML element or component to render as the wrapper. | | `children` (required) | `React.ReactNode` | | Content to animate. | ## Example: Default ```tsx import { Fade, Card, Text } from '@nexub/react'; export default function Example() { return <Fade in><Card className="w-50"><Text size="body-sm">Faded in content</Text></Card></Fade>; } ``` ## Example: Toggle ```tsx import * as React from 'react'; import { Button, Fade, Card, Text } from '@nexub/react'; export default function Example() { const [visible, setVisible] = React.useState(true); return ( <div className="flex flex-col gap-3 items-start"> <Button variant="outlined" onClick={() => setVisible((v) => !v)}> {visible ? 'Hide' : 'Show'} </Button> <Fade in={visible} unmountOnExit> <Card className="w-50"><Text size="body-sm">Animated content</Text></Card> </Fade> </div> ); } ``` ## Example: Slow spring ```tsx import * as React from 'react'; import { Button, Fade, Card, Text } from '@nexub/react'; export default function Example() { const [visible, setVisible] = React.useState(true); return ( <div className="flex flex-col gap-3 items-start"> <Button variant="outlined" onClick={() => setVisible((v) => !v)}>Toggle</Button> <Fade in={visible} duration="slow"> <Card className="w-50"><Text size="body-sm">Slow spring fade animation.</Text></Card> </Fade> </div> ); } ``` --- # Float Gently bobs its content (floating cards over a hero visual), in marketing mode. Server component; still under reduced motion. - Package: `@nexub/react` · Category: Motion · Status: beta - Import: `import { MotionFloat } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/motion-float ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `speed` | `'normal' \| 'slow'` | `'normal'` | `slow` drifts on a longer, reversed loop, so two floating cards don’t move in step. | | `asChild` | `boolean` | `false` | Merge onto the child element instead of a div. | ## Example: Default ```tsx import { Card, Float } from '@nexub/react'; export default function Example() { return ( <div data-mode="marketing" className="flex gap-8 p-6"> <Float> <Card variant="showcase" className="nx-mkt-float-card p-5">Payroll approved</Card> </Float> <Float speed="slow"> <Card variant="showcase" className="nx-mkt-float-card p-5">Books closed</Card> </Float> </div> ); } ``` --- # Marquee A row that scrolls sideways forever (logo strips, tool lists), in marketing mode. Pauses on hover and while focus is inside, stands still under reduced motion; the repeated copy is hidden from assistive tech and can’t be focused. Server component. - Package: `@nexub/react` · Category: Motion · Status: beta - Import: `import { MotionMarquee } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/motion-marquee ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `speed` | `'slow' \| 'normal' \| 'fast'` | `'normal'` | Loop length: 44s, 28s or 18s. | | `rowClassName` | `string` | `'gap-12 pe-12 items-center'` | Classes for each copy of the row. | | `children` (required) | `React.ReactNode` | | The items. | ## Example: Default ```tsx import { Marquee } from '@nexub/react'; const tools = ['Slack', 'Xero', 'Google Workspace', 'Stripe', 'QuickBooks', 'WhatsApp']; export default function Example() { return ( <div data-mode="marketing" className="w-full"> <Marquee> {tools.map((t) => ( <span key={t} className="text-title-md text-on-surface-variant">{t}</span> ))} </Marquee> </div> ); } ``` --- # Reveal Fades its content up as it scrolls into view, in marketing mode. CSS scroll-driven where supported, an IntersectionObserver elsewhere; content on screen at load, and every visitor without JS or with reduced motion, just sees it. - Package: `@nexub/react` · Category: Motion · Status: beta - Import: `import { MotionReveal } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/motion-reveal ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `asChild` | `boolean` | `false` | Merge onto the child element instead of a div. | | `children` (required) | `React.ReactNode` | | Content to reveal. | ## Example: Default ```tsx import { Card, Reveal } from '@nexub/react'; export default function Example() { return ( <div data-mode="marketing" role="region" aria-label="Reveal demo" tabIndex={0} className="flex h-64 w-full flex-col gap-6 overflow-y-auto p-2"> <p className="m-0 shrink-0 pb-40 text-body-md text-on-surface-variant">Scroll down</p> {[1, 2, 3].map((n) => ( <Reveal key={n} className="shrink-0"> <Card variant="showcase" className="p-6">Section {n}</Card> </Reveal> ))} </div> ); } ``` --- # Scale Scales content in/out from its center. - Package: `@nexub/react` · Category: Motion · Status: stable - Import: `import { MotionScale } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/motion-scale ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `in` (required) | `boolean` | | When true, scales content in from 0 to 1. When false, scales it back down to 0. | | `duration` | `'instant' \| 'fast' \| 'normal' \| 'slow' \| 'slower'` | `'normal'` | Controls the animation speed using the design token scale. | | `unmountOnExit` | `boolean` | `false` | Removes the element from the DOM after the exit animation completes. | | `as` | `React.ElementType` | `'div'` | The HTML element or component to render as the wrapper. | | `children` (required) | `React.ReactNode` | | Content to animate. | ## Example: Default ```tsx import { Scale, Card, Text } from '@nexub/react'; export default function Example() { return <Scale in><Card className="w-50"><Text size="body-sm">Scaled content</Text></Card></Scale>; } ``` ## Example: Toggle ```tsx import * as React from 'react'; import { Button, Scale, Card, Text } from '@nexub/react'; export default function Example() { const [visible, setVisible] = React.useState(true); return ( <div className="flex flex-col gap-3 items-start"> <Button variant="outlined" onClick={() => setVisible((v) => !v)}>Toggle</Button> <Scale in={visible} unmountOnExit> <Card className="w-50"><Text size="body-sm">Scaling content</Text></Card> </Scale> </div> ); } ``` --- # Slide Slides content in from a direction based on the `in` prop. - Package: `@nexub/react` · Category: Motion · Status: stable - Import: `import { MotionSlide } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/motion-slide ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `in` (required) | `boolean` | | When true, slides content in. When false, slides it out. | | `direction` | `'up' \| 'down' \| 'left' \| 'right'` | `'up'` | The direction from which the content slides in. | | `duration` | `'instant' \| 'fast' \| 'normal' \| 'slow' \| 'slower'` | `'normal'` | Controls the animation speed using the design token scale. | | `unmountOnExit` | `boolean` | `false` | Removes the element from the DOM after the exit animation completes. | | `as` | `React.ElementType` | `'div'` | The HTML element or component to render as the wrapper. | | `children` (required) | `React.ReactNode` | | Content to animate. | ## Example: Default ```tsx import { Slide, Card, Text } from '@nexub/react'; export default function Example() { return <Slide in direction="up"><Card className="w-50"><Text size="body-sm">Slid in from bottom</Text></Card></Slide>; } ``` ## Example: Directions ```tsx import * as React from 'react'; import { Button, Slide, Card, Text } from '@nexub/react'; export default function Example() { const [visible, setVisible] = React.useState(true); return ( <div className="flex flex-col gap-3 items-start"> <Button variant="outlined" onClick={() => setVisible((v) => !v)}>Toggle</Button> <Slide in={visible} direction="up" unmountOnExit> <Card className="w-50"><Text size="body-sm">Sliding content</Text></Card> </Slide> </div> ); } ``` --- # Multi Select Pick several options as chips, with search, "+N more" and an optional create option. - Package: `@nexub/react` · Category: Form Controls · Status: beta - Import: `import { MultiSelect } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/multi-select ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `options` (required) | `{ value: string; label: string }[]` | | The options to pick from. | | `value / defaultValue` | `string[]` | | Selected values, controlled or not. | | `onValueChange` | `(value: string[]) => void` | | Called with the new selection. | | `maxVisibleChips` | `number` | `3` | Chips shown before the rest collapse into "+N more". | | `onInputChange` | `(text: string) => void` | | Called as the user types. When set, options are shown as given, so you can fetch them. | | `onCreate` | `(text: string) => void` | | Adds a "Create “text”" option when the text matches no option. | | `loading` | `boolean` | | Skeleton rows instead of options; "Loading" is announced. | | `aria-label / aria-labelledby` | `string` | | Name the field: there is no visible label inside it. | | `onSearch` | `(text: string) => void` | | 11.2: async search (same as `onInputChange`); picked values keep their labels and avatars. | | `options[].description / disabled / avatar` | `string / boolean / ReactNode` | | 11.2: a second line (also searched), options that can't be picked, and an avatar in the list and on the chip. | ## Example: Labels with create ```tsx 'use client'; import * as React from 'react'; import { MultiSelect } from '@nexub/react'; const labels = [ { value: 'bug', label: 'Bug' }, { value: 'design', label: 'Design' }, { value: 'docs', label: 'Docs' }, { value: 'perf', label: 'Performance' }, { value: 'a11y', label: 'Accessibility' }, { value: 'security', label: 'Security' }, ]; export default function Example() { const [options, setOptions] = React.useState(labels); const [value, setValue] = React.useState(['bug', 'a11y']); return ( <div className="w-80"> <MultiSelect aria-label="Labels" placeholder="Add labels…" options={options} value={value} onValueChange={setValue} onCreate={(text) => { const v = text.toLowerCase(); setOptions((o) => [...o, { value: v, label: text }]); setValue((s) => [...s, v]); }} /> </div> ); } ``` ## Example: People with server search ```tsx import * as React from 'react'; import { Avatar, MultiSelect, type MultiSelectOption } from '@nexub/react'; const all: MultiSelectOption[] = [ { value: 'u1', label: 'Aisha Rahman', description: 'Finance' }, { value: 'u2', label: 'Ben Ong', description: 'Sales' }, { value: 'u3', label: 'Chen Wei', description: 'On leave', disabled: true }, { value: 'u4', label: 'Dana Lee', description: 'Product' }, { value: 'u5', label: 'Eli Tan', description: 'Support' }, ].map((p) => ({ ...p, avatar: <Avatar size="xs" name={p.label} /> })); export default function Example() { const [value, setValue] = React.useState<string[]>(['u1']); const [options, setOptions] = React.useState(all); const [loading, setLoading] = React.useState(false); const timer = React.useRef<ReturnType<typeof setTimeout>>(undefined); return ( <div className="w-full max-w-md"> <MultiSelect aria-label="Reviewers" options={options} value={value} onValueChange={setValue} loading={loading} onSearch={(text) => { clearTimeout(timer.current); setLoading(true); timer.current = setTimeout(() => { const q = text.toLowerCase(); setOptions(all.filter((p) => p.label.toLowerCase().includes(q) || p.description?.toLowerCase().includes(q))); setLoading(false); }, 300); }} /> </div> ); } ``` ## Accessibility - `Type`: Filters the options and opens the list. - `ArrowDown / ArrowUp`: Moves through the options. - `Enter`: Toggles the highlighted option. - `Backspace`: In an empty field, removes the last chip. - `Escape`: Closes the list. - Options carry `aria-checked`; each chip has a "Remove <label>" button. Related: [autocomplete](autocomplete.md), [chip](chip.md), [select](select.md) --- # Navigation Menu Site navigation links with flyout panels, built on Radix. - Package: `@nexub/react` · Category: Navigation · Status: stable - Import: `import { NavigationMenu } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/navigation-menu ## When to use - Marketing or docs sites whose sections need a flyout of links ## When not to use - Actions: use `DropdownMenu` or `Menubar` - App navigation without flyouts: use `TopNav` or `Sidebar` ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `NavigationMenu.Root` | `compound` | | The `<nav>` (`value`, `onValueChange`, `delayDuration`). Renders the panel viewport for you. | | `NavigationMenu.List / Item` | `compound` | | The list of top-level entries. | | `NavigationMenu.Trigger` | `compound` | | Opens the item’s panel on hover or click. | | `NavigationMenu.Content` | `compound` | | The flyout panel for an item. | | `NavigationMenu.Link` | `compound` | | A link, top-level or inside a panel (`href`, `active`, `asChild` for router links). | | `NavigationMenu.Indicator` | `compound` | | Optional arrow under the open trigger. | ## Example: Default ```tsx import { NavigationMenu } from '@nexub/react'; const products = [ { title: 'Analytics', body: 'Track key metrics in real time.' }, { title: 'Dashboards', body: 'Build and share custom views.' }, { title: 'Reports', body: 'Export and schedule reports.' }, ]; export default function Example() { return ( <NavigationMenu.Root aria-label="Site"> <NavigationMenu.List> <NavigationMenu.Item> <NavigationMenu.Trigger>Products</NavigationMenu.Trigger> <NavigationMenu.Content> <ul className="grid w-70 gap-1 p-2"> {products.map((p) => ( <li key={p.title}> <NavigationMenu.Link href="#"> <span className="block text-label-lg">{p.title}</span> <span className="mt-1 block text-body-sm text-on-surface-muted">{p.body}</span> </NavigationMenu.Link> </li> ))} </ul> </NavigationMenu.Content> </NavigationMenu.Item> <NavigationMenu.Item> <NavigationMenu.Link href="#">Pricing</NavigationMenu.Link> </NavigationMenu.Item> <NavigationMenu.Item> <NavigationMenu.Link href="#">Docs</NavigationMenu.Link> </NavigationMenu.Item> </NavigationMenu.List> </NavigationMenu.Root> ); } ``` ## Accessibility - `Tab`: Moves between top-level entries. - `Enter / Space`: Opens or closes a panel. - `Escape`: Closes the panel and returns focus to its trigger. - Give `NavigationMenu.Root` an `aria-label` when the page has more than one navigation landmark. Related: [top-nav](top-nav.md), [menubar](menubar.md) --- # Navigation Rail Navigation for medium-width windows: icons over labels, with an active pill behind the icon. - Package: `@nexub/react` · Category: Navigation · Status: beta - Import: `import { NavigationRail } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/navigation-rail ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `Root header` | `ReactNode` | | Slot above the items, e.g. a primary action. Not shown in the bottom bar. | | `Root orientation` | `'vertical' \| 'bottom'` | `'vertical'` | 11.5. `bottom` is a phone tab bar: a row that sticks to the bottom of the scroll area, with safe-area padding and 48px targets. Put it after the page content. | | `Root aria-label` | `string` | `'Main'` | Name of the nav landmark. | | `Item icon / label` (required) | `ReactNode` | | Icon in the indicator pill; label below. | | `Item active` | `boolean` | | Marks the current page (aria-current="page"). | | `Item badge` | `number \| boolean` | | 11.5. A count on the icon (99+ above 99, nothing at 0), or `true` for a dot. Screen readers hear it after the label: "Inbox, 3 unread" or "Feed, New". | | `Item badgeLabel` | `string` | | 11.5. Other wording for the badge, e.g. "2 failed builds". | | `Item asChild` | `boolean` | | Use your router link as the item; pass it as the only child. | ## Example: Default ```tsx import { NavigationRail } from '@nexub/react'; export default function Example() { const glyph = (d: string) => ( <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d={d} /></svg> ); return ( <NavigationRail.Root aria-label="Workspace" className="h-auto bg-surface-container-low rounded-shape-overlay"> <NavigationRail.Item href="#" icon={glyph('M3 10l9-7 9 7v10a1 1 0 0 1-1 1h-5v-6H9v6H4a1 1 0 0 1-1-1z')} label="Home" active /> <NavigationRail.Item href="#" icon={glyph('M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z')} label="Files" /> <NavigationRail.Item href="#" icon={glyph('M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z')} label="Settings" /> </NavigationRail.Root> ); } ``` ## Example: Bottom tab bar with badges For phones: `orientation="bottom"`, with a count and a dot badge. ```tsx import { NavigationRail } from '@nexub/react'; import { Bell, Home, Inbox, User } from '@nexub/icons'; export default function Example() { return ( <div className="flex h-80 w-full max-w-sm flex-col overflow-auto rounded-shape-overlay border border-outline-variant"> <main className="flex-1 p-4 text-body-md text-on-surface-variant">Page content scrolls above the tab bar.</main> <NavigationRail.Root orientation="bottom" aria-label="Main"> <NavigationRail.Item href="#" icon={<Home />} label="Home" active /> <NavigationRail.Item href="#" icon={<Inbox />} label="Inbox" badge={3} /> <NavigationRail.Item href="#" icon={<Bell />} label="Alerts" badge /> <NavigationRail.Item href="#" icon={<User />} label="Profile" /> </NavigationRail.Root> </div> ); } ``` Related: [sidebar](sidebar.md), [top-nav](top-nav.md) --- # Number Input Element `<nx-number-input>`: the NumberInput rules as a form-associated web component, for server-rendered pages without React. A plain `<form>` posts its value. - Package: `@nexub/elements` · Category: Web Components · Status: alpha - Load: `<script type="module" src="https://cdn.jsdelivr.net/npm/@nexub/elements/dist/define.js"></script>` - Install: `npm install @nexub/elements`. No build step: the script tag above registers `<nx-number-input>`. With a bundler, `import '@nexub/elements/define';` once does the same. - Web only: It is a web component for HTML pages; native apps use NumberInput’s twin in `@nexub/react-native`, `Stepper`. - Docs: https://nexub-ds-docs.pages.dev/components/number-input-element ## When to use - A number on a page with no React: server-rendered HTML, a plain `<form method="post">`, a CMS template. - Where `<input type="number">` would do, but it must look like the rest of Nexub, be empty without being 0, and clamp on blur as the React field does. ## When not to use - In a React app: use NumberInput from `@nexub/react` (steppers, `nullable`, NexubProvider strings). - Phone numbers, codes and ids: use a text input. They are not quantities. - Money: use MoneyInput. ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `name` | `string` | | The form field name: a `<form>` posts the value under it. | | `value` | `string` | | The starting value, and what `form.reset()` goes back to. Empty for none. The `value` property is the current value. In React, server rendering writes `value` as this attribute; in a client-only render pass `defaultValue`, which sets it. | | `min` | `string` | | Smallest value, applied on blur, Enter and steps (never while typing, so 30 can be typed with a minimum of 15). Below it, the field is invalid (`rangeUnderflow`). | | `max` | `string` | | Largest value, applied the same way (`rangeOverflow`). | | `step` | `string` | | Arrow-key increment: a positive number (default 1), or `any` for any decimal (keys then move by 1). | | `required` | `boolean` | | Empty is invalid (`valueMissing`); the form won’t submit and shows the browser’s message. | | `disabled` | `boolean` | | Not editable, not posted. A disabled `<fieldset>` around it does the same. | | `readonly` | `boolean` | | Posted but not editable; arrow keys do nothing. | | `placeholder` | `string` | | Hint shown while empty. | | `size` | `'sm' \| 'md' \| 'lg'` | | `sm`, `md` (default) or `lg`: the control heights of `@nexub/react`. | | `aria-label` | `string` | | Names the field when it has no `<label for>`. | | `input event` | `Event` | | On every edit and step that changes the value. Read `event.target.value` (a string, `''` when cleared). | | `change event` | `Event` | | When the value is committed: blur, Enter or a step. | ## Example: Default Labelled with `<label for>`, limits applied on blur. Rendered here in React 19, which passes the attributes and listens to the element’s events. ```tsx 'use client'; import * as React from 'react'; // Registers <nx-number-input> and <nx-date-picker>. On a page without a bundler, use // <script type="module" src="…/@nexub/elements/dist/define.js"></script> instead. import '@nexub/elements/define'; export default function Example() { const ref = React.useRef<HTMLElementTagNameMap['nx-number-input']>(null); const [value, setValue] = React.useState('4'); React.useEffect(() => { const el = ref.current; if (!el) return; const onChange = () => setValue(el.value); el.addEventListener('change', onChange); return () => el.removeEventListener('change', onChange); }, []); return ( <div className="flex w-full max-w-xs flex-col gap-2"> <label htmlFor="seats" className="text-label-lg text-on-surface"> Seats </label> <nx-number-input ref={ref} id="seats" name="seats" min="1" max="50" step="1" value="4" placeholder="1–50" /> <p className="text-body-sm text-on-surface-muted">Committed value: {value === '' ? 'empty' : value}</p> </div> ); } ``` ## Example: In a form Form-associated: `FormData` has the value, `required` and `min` block the submit, and Reset goes back to the `value` attribute. ```tsx 'use client'; import * as React from 'react'; import { Button } from '@nexub/react'; import '@nexub/elements/define'; export default function Example() { const [posted, setPosted] = React.useState<string | null>(null); return ( <form className="flex w-full max-w-xs flex-col gap-3" onSubmit={(e) => { e.preventDefault(); // The element is form-associated: FormData has its value, as a native input's. setPosted(JSON.stringify(Object.fromEntries(new FormData(e.currentTarget)))); }} onReset={() => setPosted(null)} > <div className="flex flex-col gap-1"> <label htmlFor="guests" className="text-label-lg text-on-surface"> Guests (required, 2 or more) </label> <nx-number-input id="guests" name="guests" min="2" required /> </div> <div className="flex flex-col gap-1"> <label htmlFor="budget" className="text-label-lg text-on-surface"> Budget per guest </label> <nx-number-input id="budget" name="budget" step="any" value="42.5" size="sm" /> </div> <div className="flex gap-2"> <Button type="submit">Send</Button> <Button type="reset" variant="outlined"> Reset </Button> </div> <p className="text-body-sm text-on-surface-muted">Posted: {posted ?? 'nothing yet'}</p> </form> ); } ``` ## Accessibility - Roles: spinbutton (the inner `<input>`), with `aria-valuenow`, `aria-valuemin` and `aria-valuemax` - `ArrowUp / ArrowDown`: One step up or down, inside `min` and `max`. Fires `input` and `change`. - `PageUp / PageDown`: Ten steps. - `Home / End`: To `min` or `max`, when set. - `Enter`: Applies the limits and submits the form, as a native input does. - One tab stop: focus is delegated to the inner input, so `<label for>` clicks and `element.focus()` land in the field. - Focus ring from the tokens; forced colours draw it in Highlight. - The inner input is named from the host’s `<label for>` (or a wrapping `<label>`, or `aria-label`): a label can’t reach into a shadow root, so the element copies its text. - `aria-required` and `aria-invalid` follow the field; the invalid state shows only after an edit or a failed submit. - Validation messages come from a native input where the browser has one, so they are in the browser’s language. - Shadow DOM: page CSS can’t break the inside. Style it with the theme variables, or `::part(field)` and `::part(input)`. - Themed by the same CSS custom properties as `@nexub/react`: load `@nexub/themes` and `data-theme` / `data-product` apply. Related: [number-input](number-input.md), [date-picker-element](date-picker-element.md), [form](form.md) --- # Number Input A numeric input with optional steppers. Limits apply when the field loses focus; `nullable` lets it be empty. - Package: `@nexub/react` · Category: Form & Input · Status: stable - Import: `import { NumberInput } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/number-input ## When to use - A quantity people type or step: seats, limits, percentages. - A value that may be empty (`nullable`) and must stay inside `min` and `max`. ## When not to use - On a page without React (server-rendered HTML, a plain `<form>`): use `<nx-number-input>` from `@nexub/elements`, the same rules as a web component. - Money: use MoneyInput. Phone numbers and codes: use a text input. ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `value` | `number \| null` | | Controlled value. `null` (with `nullable`) shows an empty field. | | `nullable` | `boolean` | `false` | The field can be empty: clearing it reports `null`, not 0, and a half-typed `2.` or `-` stays while focused. | | `onValueChange` | `(value: number) => void \| (value: number \| null) => void` | | Called while typing (not yet clamped) and with the clamped value on blur, steppers and arrow keys. With `nullable`, `null` when cleared. | | `min` | `number` | | Lowest value, applied on blur, steppers and arrow keys (never mid-typing, so 30 can be typed with a minimum of 15). | | `max` | `number` | | Highest value, applied the same way. | | `step` | `number \| 'any'` | `1` | Increment for steppers and arrow keys. `'any'` allows any decimal (steppers then move by 1). | | `disabled` | `boolean` | | Disables the input and its controls. | | `size` | `'sm' \| 'md' \| 'lg'` | | Controls font size and padding. | ## Example: Default ```tsx import { NumberInput } from '@nexub/react'; export default function Example() { return <div className="w-45"><NumberInput defaultValue={0} /></div>; } ``` ## Example: With range ```tsx import { NumberInput } from '@nexub/react'; export default function Example() { return <div className="w-45"><NumberInput defaultValue={5} min={0} max={10} /></div>; } ``` ## Example: Can be empty `nullable`: cleared means null. The limits apply on blur. ```tsx import * as React from 'react'; import { NumberInput } from '@nexub/react'; export default function Example() { const [value, setValue] = React.useState<number | null>(null); return ( <div className="flex w-56 flex-col gap-2"> <NumberInput nullable aria-label="Seat limit" placeholder="No limit" min={15} max={500} step="any" showSteppers value={value} onValueChange={setValue} /> <span className="text-body-sm text-on-surface-muted">{value === null ? 'No limit (null)' : `${value} seats`}</span> </div> ); } ``` Related: [number-input-element](number-input-element.md), [money-input](money-input.md), [slider](slider.md) --- # Number Ticker A number whose digits roll to new values on the spatial spring. The first render never animates. - Package: `@nexub/react` · Category: Data Display · Status: beta - Import: `import { NumberTicker } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/number-ticker ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `value` (required) | `number \| string \| NumberTickerPart[]` | | A number (formatted with `format` and `locale`), an already-formatted string, or styled parts. | | `format` | `Intl.NumberFormatOptions` | | Formatting for a number `value`. | | `locale` | `string` | | BCP 47 locale. Defaults to the user's. | | `aria-live` | `'off' \| 'polite'` | `'off'` | Announce changes to screen readers. Use `polite` only for values the user is waiting on. | | `countOnView` | `boolean` | `false` | Count up from zeros when the ticker first scrolls into view (3.1). Only for a ticker that starts below the fold; the server HTML and screen readers always get the real value. Off under reduced motion. | ## Example: Formatted number Each digit is a 0–9 strip; separators and symbols stay still. ```tsx import * as React from 'react'; import { NumberTicker, Button } from '@nexub/react'; export default function Example() { const [n, setN] = React.useState(12480); return ( <div className="flex flex-col gap-3 items-center"> <NumberTicker value={n} format={{ maximumFractionDigits: 0 }} className="text-title-lg" /> <Button size="sm" variant="outlined" onClick={() => setN(Math.round(Math.random() * 100000))}> Change </Button> </div> ); } ``` ## Example: Amount `Amount animate` uses the ticker and keeps the quieter symbol and minor units. ```tsx import * as React from 'react'; import { Amount, Button } from '@nexub/react'; export default function Example() { const [balance, setBalance] = React.useState(128450.75); return ( <div className="flex flex-col gap-3 items-center"> <Amount value={balance} currency="USD" size="display" animate /> <Button size="sm" variant="outlined" onClick={() => setBalance(Math.round(Math.random() * 20000000) / 100)}> Change </Button> </div> ); } ``` ## Example: Count on view Scroll the preview so the number enters the view; it counts up once. ```tsx import { NumberTicker } from '@nexub/react'; export default function Example() { return ( <div className="flex h-48 w-full flex-col overflow-y-auto"> <p className="m-0 shrink-0 pb-64 text-body-md text-on-surface-variant">Scroll down</p> <NumberTicker value={2000} countOnView className="shrink-0 text-display-sm" /> </div> ); } ``` ## Accessibility - The full value is read as one string; the rolling digits are hidden from assistive tech. - Under reduced motion digits change instantly. Related: [amount](amount.md), [stat-card](stat-card.md) --- # Org Chart People top-down as cards joined by lines, keyboard navigable as a tree. A TreeView on narrow screens. - Package: `@nexub/react` · Category: Data Display · Status: alpha - Import: `import { OrgChart } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/org-chart ## When to use - Reporting lines: a company, a team, a studio. - Any small hierarchy people scan by face or name. ## When not to use - Deep or wide data people search or check: use TreeView. - Free-form graphs and workflows: use DiagramCanvas. ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `nodes` (required) | `OrgChartNode[]` | | The TreeView node shape plus `description` (the role line) and `avatar` (photo URL; initials without one). | | `aria-label / aria-labelledby` (required) | `string` | | Names the tree. | | `expanded / defaultExpanded / onExpandedChange` | `string[]` | | Open node ids. Shared with the narrow-screen TreeView. | | `onActivate` | `(node) => void` | | Click or Enter on a card, e.g. to open the profile. | | `renderCard` | `(node) => ReactNode` | | Replaces the card content; it also names the item. The reports control stays. | | `className` | `string` | | On the scroll box. Wide charts scroll sideways inside it. | ## Example: Default ```tsx 'use client'; import * as React from 'react'; import { OrgChart, type OrgChartNode } from '@nexub/react'; const people: OrgChartNode[] = [ { id: 'ada', label: 'Ada Lovelace', description: 'Chief Executive', children: [ { id: 'alan', label: 'Alan Turing', description: 'Engineering', children: [ { id: 'grace', label: 'Grace Hopper', description: 'Platform lead' }, { id: 'margaret', label: 'Margaret Hamilton', description: 'Flight software' }, ], }, { id: 'mary', label: 'Mary Somerville', description: 'Finance', children: [{ id: 'emmy', label: 'Emmy Noether', description: 'Analyst' }] }, { id: 'katherine', label: 'Katherine Johnson', description: 'Research' }, ], }, ]; export default function Example() { const [opened, setOpened] = React.useState<string | null>(null); return ( <div className="flex w-full flex-col gap-2"> <OrgChart aria-label="Company" nodes={people} defaultExpanded={['ada', 'alan']} onActivate={(p) => setOpened(String(p.label))} /> <p className="text-body-sm text-on-surface-muted">Opened: {opened ?? 'nobody yet'}</p> </div> ); } ``` ## Example: Custom cards, controlled ```tsx 'use client'; import * as React from 'react'; import { Badge, OrgChart, type OrgChartNode } from '@nexub/react'; const teams: OrgChartNode[] = [ { id: 'studio', label: 'Studio', description: '24 people', children: [ { id: 'design', label: 'Design', description: '8 people' }, { id: 'build', label: 'Build', description: '12 people', children: [{ id: 'web', label: 'Web', description: '7 people' }, { id: 'apps', label: 'Apps', description: '5 people' }] }, { id: 'ops', label: 'Ops', description: '4 people' }, ], }, ]; export default function Example() { const [expanded, setExpanded] = React.useState<string[]>(['studio']); return ( <OrgChart aria-label="Teams" nodes={teams} expanded={expanded} onExpandedChange={setExpanded} renderCard={(team) => ( <span className="flex flex-col items-center gap-1"> <span className="text-title-sm">{team.label}</span> <Badge variant="soft">{team.description}</Badge> </span> )} /> ); } ``` ## Accessibility - Roles: tree, treeitem with aria-level, aria-setsize, aria-posinset, aria-expanded, group - `ArrowDown / ArrowUp`: Next or previous visible card in tree order (depth first), as in TreeView, not by position on screen. - `ArrowRight`: Opens a closed card, or moves to its first report. Mirrored in RTL. - `ArrowLeft`: Closes an open card, or moves to its manager. Mirrored in RTL. - `Home / End`: First or last visible card. - `Enter`: Calls `onActivate`. - `Space`: Opens or closes the card’s reports. - The chart is one tab stop (roving tabindex); focus scrolls the card into view. - Each item is named by its name and role only, not by its reports. - The "3 reports" control is a pointer shortcut; keyboard and screen readers use the item’s expanded state. - Below 768px the same nodes render as a TreeView (photo, name and role on one row). - Connectors are CSS borders on logical sides, so RTL mirrors and forced colours keep them. Related: [tree-view](tree-view.md), [avatar](avatar.md), [diagram-canvas](diagram-canvas.md) --- # OTP Input One box per digit for verification codes, with paste and one-time-code autofill. - Package: `@nexub/react` · Category: Form Controls · Status: beta - Import: `import { OtpInput } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/otp-input ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `length` | `number` | `6` | Number of boxes. | | `value / defaultValue / onValueChange` | `string` | | The code so far, without gaps. | | `onComplete` | `(code: string) => void` | | Called when every box is filled; submit or verify here. | | `mode` | `'numeric' \| 'alphanumeric'` | `'numeric'` | Numeric shows the number keypad on phones. | | `invalid / disabled` | `boolean` | | Error styling (pair with a FormError) and the disabled state. | | `name` | `string` | | Submits the code with a form. | | `aria-label` | `string` | `'Verification code'` | Group name; each box reads "Digit N of M". | | `mode: 'backup'` | `'numeric' \| 'alphanumeric' \| 'backup'` | | 11.2: a 12-character recovery code in one field, grouped in fours; the value has no dashes. | | `autoFocus` | `boolean` | | 11.2: focus the first box on mount. | ## Example: Verification code ```tsx 'use client'; import * as React from 'react'; import { OTPInput } from '@nexub/react'; export default function Example() { const [status, setStatus] = React.useState(''); return ( <div className="flex flex-col items-start gap-3"> <OTPInput onComplete={(code) => setStatus(code === '123456' ? 'Verified' : 'That code didn’t work')} onValueChange={() => setStatus('')} /> <p aria-live="polite" className="text-body-sm text-on-surface-muted"> {status || 'Try 123456'} </p> </div> ); } ``` ## Example: Backup code ```tsx import * as React from 'react'; import { OTPInput } from '@nexub/react'; export default function Example() { const [done, setDone] = React.useState(false); return ( <form className="flex w-full max-w-xs flex-col gap-2"> <OTPInput mode="backup" name="recoveryCode" autoFocus={false} onComplete={() => setDone(true)} /> <p className="text-body-sm text-on-surface-muted">{done ? 'Checking the code…' : 'Enter one of your 12-character backup codes'}</p> </form> ); } ``` ## Accessibility - `Type`: Fills the box and moves to the next. - `Backspace`: Clears the box, or the previous one when empty. - `ArrowLeft / ArrowRight`: Moves between boxes. - The first box has `autocomplete="one-time-code"`, so the code from an SMS fills every box. Related: [input](input.md), [password-input](password-input.md) --- # Page Header The top of a page: title, description, breadcrumb and actions. - Package: `@nexub/react` · Category: Layout · Status: stable - Import: `import { PageHeader } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/page-header ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `title` | `ReactNode` | | The page title. Truncates on one line. | | `description` | `ReactNode` | | A line under the title. | | `actions` | `ReactNode` | | Buttons on the end side; they wrap under the title on narrow screens. | | `breadcrumb` | `ReactNode` | | A `Breadcrumb` above the title. | | `level` | `1 \| 2 \| 3` | | Heading level of the title. Use 2 or 3 when the page already has an h1. | | `eyebrow` | `ReactNode` | | 11.5: a row above the title, e.g. an EyebrowChip and status badges. | ## Example: Default ```tsx import { Button, PageHeader } from '@nexub/react'; export default function Example() { return ( <PageHeader className="w-full" level={2} title="Projects" description="Everything your team is working on." actions={<><Button variant="outlined">Import</Button><Button>New project</Button></>} /> ); } ``` ## Example: With breadcrumb ```tsx import { Breadcrumb, Button, PageHeader } from '@nexub/react'; export default function Example() { return ( <PageHeader className="w-full" level={2} breadcrumb={ <Breadcrumb.Root> <Breadcrumb.List> <Breadcrumb.Item><Breadcrumb.Link href="#">Projects</Breadcrumb.Link></Breadcrumb.Item> <Breadcrumb.Separator /> <Breadcrumb.Item><Breadcrumb.Page>Billing service</Breadcrumb.Page></Breadcrumb.Item> </Breadcrumb.List> </Breadcrumb.Root> } title="Billing service" description="Updated 2 hours ago" actions={<Button variant="outlined">Settings</Button>} /> ); } ``` Related: [breadcrumb](breadcrumb.md), [app-shell](app-shell.md), [heading](heading.md) --- # Pagination Page navigation control with prev/next and page number buttons. - Package: `@nexub/react` · Category: Navigation · Status: stable - Import: `import { Pagination } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/pagination ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `page` (required) | `number` | | The currently active page (1-indexed). | | `totalItems` (required) | `number` | | Total number of items across all pages. | | `pageSize` | `number` | `10` | Number of items per page. Used to calculate total page count. | | `siblingCount` | `number` | `1` | Number of page buttons to show on each side of the current page. | | `onPageChange` (required) | `(page: number) => void` | | Callback invoked with the new page number when the user navigates. | | `disabled` | `boolean` | `false` | Disables all pagination controls. | ## Example: Default ```tsx import * as React from 'react'; import { Pagination } from '@nexub/react'; export default function Example() { const [page, setPage] = React.useState(3); return <Pagination page={page} totalItems={100} pageSize={10} onPageChange={setPage} />; } ``` ## Example: Large dataset ```tsx import * as React from 'react'; import { Pagination } from '@nexub/react'; export default function Example() { const [page, setPage] = React.useState(3); return <Pagination page={page} totalItems={500} pageSize={20} siblingCount={2} onPageChange={setPage} />; } ``` --- # Password Input A password field with a built-in toggle to reveal or hide the entered value. - Package: `@nexub/react` · Category: Form & Input · Status: stable - Import: `import { PasswordInput } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/password-input ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `placeholder` | `string` | | Placeholder text shown when the field is empty. | | `invalid` | `boolean` | | Applies error styling to indicate a validation failure. | | `disabled` | `boolean` | | Disables the input. | | `size` | `'sm' \| 'md' \| 'lg'` | | Controls font size and padding. | | `visible` | `boolean` | | Shows the password as text. Controlled when set; pair with onVisibleChange. | | `defaultVisible` | `boolean` | | Initial visibility when uncontrolled. Defaults to false. | | `onVisibleChange` | `(visible: boolean) => void` | | Called when the reveal toggle is pressed. | ## Example: Default ```tsx import { PasswordInput } from '@nexub/react'; export default function Example() { return <div className="w-70"><PasswordInput placeholder="Enter password…" /></div>; } ``` ## Example: Invalid ```tsx import { PasswordInput } from '@nexub/react'; export default function Example() { return <div className="w-70"><PasswordInput invalid placeholder="Password is too short" /></div>; } ``` --- # Phone Input A phone field with a country picker. Groups the number as you type and reports it in E.164. - Package: `@nexub/react` · Category: Form Controls · Status: alpha - Import: `import { PhoneInput } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/phone-input ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `value / defaultValue` | `string` | | The number in E.164 ("+919847012345"), or an empty string. | | `onValueChange` | `(e164: string, details: { country: string; national: string; valid: boolean }) => void` | | Called on every change. `valid` is a length check for the country, not proof the number exists. | | `defaultCountry` | `string` | | ISO 3166-1 alpha-2 code to start on. Defaults to the region of the provider locale, else `US`. | | `country / onCountryChange` | `string` | | Controls the selected country. | | `countries` | `string[]` | | Limits the picker to these countries, in this order. With one entry the picker becomes text. | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Height of the field. | | `invalid / disabled` | `boolean` | | Field states, with `readOnly` and `required`. Inside `FormField.Control` they come from the field. | | `name` | `string` | | Submits the E.164 value with a form. | | `sheet` | `boolean \| 'auto'` | `'auto'` | Shows the country list as a bottom sheet; `'auto'` only on phones. | | `formatPhone(e164, { style })` | `(e164: string, options?: { style?: 'national' \| 'international' }) => string` | | Read-only display of a stored number: "+91 98470 12345" or "98470 12345". | | `parsePhone(value)` | `(value: string) => { country, dialCode, national, e164, valid }` | | The parts, for apps that store the country and number apart. The E.164 string stays the one stored form. | ## Example: Default ```tsx import * as React from 'react'; import { PhoneInput } from '@nexub/react'; export default function Example() { const [value, setValue] = React.useState(''); const [valid, setValid] = React.useState(false); return ( <div className="flex w-80 max-w-full flex-col gap-2"> <PhoneInput aria-label="Phone number" defaultCountry="IN" value={value} onValueChange={(e164, details) => { setValue(e164); setValid(details.valid); }} /> <p aria-live="polite" className="text-body-sm text-on-surface-muted"> {value ? `${value}${valid ? '' : ' (incomplete)'}` : 'Type a number, or paste one with its country code'} </p> </div> ); } ``` ## Example: Restricted countries in a form field ```tsx import * as React from 'react'; import { FormField, PhoneInput } from '@nexub/react'; export default function Example() { const [valid, setValid] = React.useState(true); return ( <FormField.Root name="mobile" required invalid={!valid} className="w-80 max-w-full"> <FormField.Label>Mobile number</FormField.Label> <FormField.Control> <PhoneInput countries={['IN', 'AE', 'SA', 'QA']} sheet="auto" onValueChange={(e164, details) => setValid(!e164 || details.valid)} /> </FormField.Control> <FormField.Description>We send a code to confirm it.</FormField.Description> <FormField.Error>That number looks too short or too long.</FormField.Error> </FormField.Root> ); } ``` ## Accessibility - `Tab`: Moves from the country picker to the number. - `Enter / Space`: Opens the country list; type to filter it. - The picker reads "Country code, India +91". The number field takes its name from the label or `aria-label`. - Pasting a full international number picks its country and fills the rest. - Validation is plausibility only: confirm the number on the server. Related: [input](input.md), [select](select.md), [otp-input](otp-input.md), [form-field](form-field.md) --- # Plan Tracker An agent plan: ordered steps with done, active, pending or failed status. - Package: `@nexub/react` · Category: AI · Status: beta - Import: `import { PlanTracker } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/plan-tracker ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `steps` (required) | `{ title; status; detail? }[]` | | Status is done, active, pending or failed. | ## Example: Agent plan ```tsx import { PlanTracker } from '@nexub/react'; export default function Example() { return ( <PlanTracker steps={[ { title: 'Read October invoices', status: 'done', detail: '42 invoices' }, { title: 'Match payments to invoices', status: 'active', detail: '31 of 42 matched' }, { title: 'Draft reminders for the unpaid ones', status: 'pending' }, { title: 'Ask you before sending', status: 'pending' }, ]} /> ); } ``` ## Accessibility - Each step reads its status in text; the active step has `aria-current="step"`. Related: [message-bubble](message-bubble.md), [thinking-indicator](thinking-indicator.md) --- # Popover Floating content panel anchored to a trigger element. - Package: `@nexub/react` · Category: Overlays · Status: stable - Import: `import { Popover } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/popover ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `Popover.Root` | `compound` | | Root provider that manages open/close state. | | `Popover.Trigger` | `compound` | | Element that toggles the popover on click. | | `Popover.Content` | `compound` | | The floating content panel. | | `Popover.Arrow` | `compound` | | Optional arrow pointing to the trigger. | | `Popover.Close` | `compound` | | Button that closes the popover. | | `side` | `'top' \| 'right' \| 'bottom' \| 'left'` | | Preferred side of the trigger to render the content. | | `align` | `'start' \| 'center' \| 'end'` | | Alignment of the content relative to the trigger. | | `sideOffset` | `number` | | Distance in pixels between the trigger and the content. | | `surface` | `'solid' \| 'glass'` | `'solid'` | Glass material on Popover.Content — see Foundations → Materials. | ## Example: Default ```tsx import { Popover, Button, Text } from '@nexub/react'; export default function Example() { return ( <Popover.Root> <Popover.Trigger asChild> <Button variant="outlined">Open popover</Button> </Popover.Trigger> <Popover.Content> <Text size="body-sm">This is popover content. You can put anything here.</Text> </Popover.Content> </Popover.Root> ); } ``` ## Example: With close button ```tsx import { Popover, Button, Text } from '@nexub/react'; export default function Example() { return ( <div className="flex gap-3 flex-wrap items-center justify-center"> {(['top', 'right', 'bottom', 'left'] as const).map((s) => ( <Popover.Root key={s}> <Popover.Trigger asChild> <Button variant="text" size="sm">{s}</Button> </Popover.Trigger> <Popover.Content side={s}> <Text size="body-sm">Opens {s}</Text> </Popover.Content> </Popover.Root> ))} </div> ); } ``` --- # Progress Horizontal progress bar with optional tone and animation. - Package: `@nexub/react` · Category: Loading States · Status: stable - Import: `import { Progress } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/progress ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `value` | `number` | | Current progress value between 0 and max. | | `max` | `number` | `100` | Maximum value of the progress bar. | | `tone` | `'neutral' \| 'info' \| 'success' \| 'warning' \| 'danger'` | | Semantic colour tone of the filled track. | | `animated` | `boolean` | `false` | Adds a stripes-in-motion animation to the filled track. | ## Example: Default ```tsx import { Progress } from '@nexub/react'; export default function Example() { return <div className="w-70"><Progress value={65} /></div>; } ``` ## Example: Tones ```tsx import { Progress } from '@nexub/react'; export default function Example() { return ( <div className="flex flex-col gap-2.5 items-start w-70"> <Progress value={80} tone="success" /> <Progress value={55} tone="info" /> <Progress value={30} tone="warning" /> <Progress value={20} tone="danger" /> </div> ); } ``` ## Example: Animated ```tsx import { Progress } from '@nexub/react'; export default function Example() { return <div className="w-70"><Progress value={40} animated tone="info" /></div>; } ``` --- # Prompt Input The composer for a chat: an auto-growing text field with Send, which turns into Stop while a reply streams. - Package: `@nexub/react` · Category: AI · Status: beta - Import: `import { PromptInput } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/prompt-input ## When to use - The message box of a chat or assistant. - Any free-text prompt that starts a long-running, stoppable generation. ## When not to use - Ordinary forms: use Textarea, where Enter adds a line. - Search: use SearchInput. ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `value / defaultValue / onValueChange` | `string` | | Controlled or uncontrolled text. Uncontrolled input clears itself after a submit. | | `onSubmit` | `(value: string) => void` | | Called with the text on Enter or Send. Not called while empty, disabled or not `idle`. | | `onStop` | `() => void` | | Called by Stop, or Escape in the field, while `status="streaming"`. | | `status` | `'idle' \| 'submitting' \| 'streaming'` | `'idle'` | `streaming` swaps Send for Stop; `submitting` holds Send until the request is accepted. | | `maxRows` | `number` | `8` | Rows the field grows to before it scrolls. | | `attachments` | `ReactNode` | | Rendered above the text, e.g. removable Chips. | | `actions` | `ReactNode` | | Rendered bottom-start, e.g. an attach IconButton or a model picker. | | `surface` | `'solid' \| 'glass'` | `'solid'` | Glass material for composers floating over content. | | `label` | `string` | `messages.promptLabel ('Message')` | Accessible name of the text field. | | `messages` | `Partial<PromptInputMessages>` | | Local overrides for `promptLabel`, `sendMessage`, `stopGenerating`, `promptHint`. | | `sendLabel` | `ReactNode` | | 11.5: a visible text label on Send, beside the arrow. Without it, Send is an icon button. | | `submitOn` | `'enter' \| 'mod-enter'` | `'enter'` | 11.5: `mod-enter` sends on Cmd/Ctrl+Enter, makes Enter add a line and shows that hint under the field. | | `hint` | `ReactNode` | | 11.5: helper text under the field, linked with `aria-describedby`. | | `error` | `ReactNode` | | 11.5: an error under the field. Marks the field invalid (`aria-invalid`) and links it. | | `textareaClassName` | `string` | | Class for the textarea; `className` goes to the outer container. | ## Example: Default Enter sends, Shift+Enter adds a line. Send stays inert until there is text. ```tsx import { PromptInput } from '@nexub/react'; export default function Example() { return ( <div className="w-full max-w-130"> <PromptInput placeholder="Ask anything" /> </div> ); } ``` ## Example: Attachments and actions ```tsx import * as React from 'react'; import { PromptInput, Chip, IconButton } from '@nexub/react'; import { Paperclip, Globe } from '@nexub/icons'; export default function Example() { const [files, setFiles] = React.useState(['q3-report.pdf', 'pricing.csv']); return ( <div className="w-full max-w-130"> <PromptInput placeholder="Ask about these files" attachments={ files.length > 0 && files.map((f) => ( <Chip key={f} onRemove={() => setFiles((all) => all.filter((x) => x !== f))}> {f} </Chip> )) } actions={ <> <IconButton size="sm" label="Attach files"><Paperclip /></IconButton> <IconButton size="sm" label="Search the web"><Globe /></IconButton> </> } /> </div> ); } ``` ## Example: Streaming Send a message: the button turns into Stop for three seconds. Stop or Escape ends it early. ```tsx import * as React from 'react'; import { type PromptInputStatus, PromptInput } from '@nexub/react'; export default function Example() { const [status, setStatus] = React.useState<PromptInputStatus>('idle'); const timer = React.useRef<ReturnType<typeof setTimeout>>(undefined); React.useEffect(() => () => clearTimeout(timer.current), []); const send = () => { setStatus('streaming'); timer.current = setTimeout(() => setStatus('idle'), 3000); }; const stop = () => { clearTimeout(timer.current); setStatus('idle'); }; return ( <div className="w-full max-w-130"> <PromptInput placeholder="Ask anything" status={status} onSubmit={send} onStop={stop} /> </div> ); } ``` ## Example: Label, hint and error Cmd/Ctrl+Enter sends and Enter adds a line. Type more than 280 characters to see the error. ```tsx import * as React from 'react'; import { PromptInput, toast } from '@nexub/react'; const LIMIT = 280; export default function Example() { const [value, setValue] = React.useState(''); const tooLong = value.length > LIMIT; return ( <div className="w-full max-w-130"> <PromptInput placeholder="Write a reply to the thread" value={value} onValueChange={setValue} onSubmit={() => { if (tooLong) return; toast.success('Reply sent'); setValue(''); }} submitOn="mod-enter" sendLabel="Reply" hint="Everyone in the thread can see your reply." error={tooLong ? `Shorten your reply to ${LIMIT} characters.` : undefined} /> </div> ); } ``` ## Accessibility - Roles: textbox (multiline), button (Send / Stop) - `Enter`: Sends. Ignored while an IME composition is open. - `Shift + Enter`: New line. - `Cmd/Ctrl + Enter`: Sends with `submitOn="mod-enter"`, where Enter adds a line. - `Escape`: Stops the reply while streaming. - Focus stays in the field after sending, so the user can type the next message straight away. - An empty field keeps Send focusable with `aria-disabled`, rather than removing it from the tab order. - The field is named by `label` (default "Message") and described by the Enter/Shift+Enter hint. - Send and Stop are icon buttons with their own names; the swap does not move focus. Related: [message-bubble](message-bubble.md), [conversation](conversation.md), [textarea](textarea.md) --- # QR Code A QR code as an SVG, always dark on light so it scans in every theme, with its value shown as text. - Package: `@nexub/react` · Category: Data Display · Status: alpha - Import: `import { QrCode } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/qr-code ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `value` (required) | `string` | | The text to encode, usually a URL. Up to 2,953 bytes of UTF-8 (1,273 with a logo). | | `size` | `number \| string` | `160` | Width of the code: pixels, or any CSS length. It never grows past its container. | | `ecc` | `'L' \| 'M' \| 'Q' \| 'H'` | `'M', or 'H' with a logo` | Error correction: how much of the code may be damaged or covered (7%, 15%, 25%, 30%). | | `logo` | `ReactNode` | | A mark in the centre, on a light tile a fifth of the width. | | `quietZone` | `number` | `4` | Light margin around the code, in modules. Readers need 4. | | `label` | `string` | `"QR code for <value>"` | Text alternative of the image. The default is English: pass your own to translate it. | | `caption` | `ReactNode \| false` | `the value` | The text under the code, so it can be read and typed without a camera. `false` hides it. | ## Example: Default ```tsx import { QRCode } from '@nexub/react'; export default function Example() { return <QRCode value="https://example.com/h/4729" />; } ``` ## Example: With a logo and a caption ```tsx import { QRCode } from '@nexub/react'; import { Sparkles } from '@nexub/icons'; export default function Example() { return <QRCode value="https://example.com/h/4729" size={200} logo={<Sparkles />} caption="example.com/h/4729" label="QR code for order 4729" />; } ``` Related: [aspect-ratio](aspect-ratio.md), [otp-input](otp-input.md) --- # Radio Card A radio group where each option is a whole card: title, description and optional icon, one choice. - Package: `@nexub/react` · Category: Form Controls · Status: beta - Import: `import { RadioCard } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/radio-card ## When to use - Two to six options that each need a sentence of explanation, like plans or regions. - A choice important enough to deserve the space. ## When not to use - Short labels with no description: use RadioGroup. - More than six options: use Select or Combobox. - Cards that hold links or buttons: the whole card is the control, so use Card with CardLink. ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `RadioCardGroup columns` | `1 \| 2 \| 3 \| 4` | `1` | Grid columns. Collapses to one column on narrow screens. | | `RadioCardGroup value / defaultValue / onValueChange` | `string` | | Radix RadioGroup props; the group also takes `disabled`, `name`, `required`. | | `value` (required) | `string` | | The option this card selects. | | `title` (required) | `ReactNode` | | The card’s accessible name. | | `description` | `ReactNode` | | Secondary text, exposed as the accessible description. | | `icon` | `ReactNode` | | Leading icon. Turns primary when selected. | | `children` | `ReactNode` | | Extra content under the description. Keep it non-interactive: the whole card is the control. | | `disabled` | `boolean` | `false` | Disables this card only. | ## Example: Plan picker ```tsx import * as React from 'react'; import { RadioCardGroup, RadioCard } from '@nexub/react'; import { User, Users, Building2 } from '@nexub/icons'; export default function Example() { const [plan, setPlan] = React.useState('team'); return ( <RadioCardGroup aria-label="Plan" columns={3} value={plan} onValueChange={setPlan} className="w-full"> <RadioCard value="solo" icon={<User />} title="Solo" description="One seat, core features."> <span className="text-sm font-medium">$0 / month</span> </RadioCard> <RadioCard value="team" icon={<Users />} title="Team" description="Up to 20 seats, shared workspaces."> <span className="text-sm font-medium">$12 / seat</span> </RadioCard> <RadioCard value="enterprise" icon={<Building2 />} title="Enterprise" description="SSO, audit logs, priority support."> <span className="text-sm font-medium">Contact sales</span> </RadioCard> </RadioCardGroup> ); } ``` ## Example: Columns Two columns from the sm breakpoint up, one below. ```tsx import { RadioCardGroup, RadioCard } from '@nexub/react'; export default function Example() { return ( <RadioCardGroup aria-label="Billing" columns={2} defaultValue="yearly" className="w-full"> <RadioCard value="monthly" title="Monthly" description="Billed every month." /> <RadioCard value="yearly" title="Yearly" description="Two months free." /> </RadioCardGroup> ); } ``` ## Example: Disabled Disable one card, or pass `disabled` to the group to disable all of them. ```tsx import { RadioCardGroup, RadioCard } from '@nexub/react'; export default function Example() { return ( <RadioCardGroup aria-label="Region" columns={2} defaultValue="eu" className="w-full"> <RadioCard value="eu" title="Europe" description="Frankfurt" /> <RadioCard value="us" title="United States" description="Virginia" /> <RadioCard value="ap" title="Asia Pacific" description="Coming soon" disabled /> </RadioCardGroup> ); } ``` ## Accessibility - Roles: radiogroup, radio (each card) - `Tab`: Moves focus into the group, to the selected card. - `Arrow keys`: Move between cards and select. - `Space`: Selects the focused card. - The title is the accessible name and the description is the accessible description. - Give the group an `aria-label` or `aria-labelledby`. Related: [radio-group](radio-group.md), [checkbox-card](checkbox-card.md), [card](card.md) --- # Radio Group Group of mutually exclusive radio inputs. - Package: `@nexub/react` · Category: Form Controls · Status: stable - Import: `import { RadioGroup } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/radio-group ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `RadioGroup.Root` | `compound` | | Root provider that manages selection state. | | `RadioGroup.Item` | `compound` | | Individual radio option within the group. | | `value` | `string` | | The controlled selected value. | | `defaultValue` | `string` | | The initial selected value when uncontrolled. | | `onValueChange` | `(value: string) => void` | | Callback fired when the selection changes. | | `disabled` | `boolean` | | Disables all items in the group. | | `orientation` | `'horizontal' \| 'vertical'` | | Layout orientation of the radio items. | ## Example: Default ```tsx import { RadioGroup, Label } from '@nexub/react'; export default function Example() { return ( <RadioGroup.Root defaultValue="monthly"> <div className="flex flex-col gap-2 items-start"> {['Monthly', 'Yearly', 'Lifetime'].map((opt) => ( <div key={opt} className="flex items-center gap-2"> <RadioGroup.Item value={opt.toLowerCase()} id={`rg-${opt}`} /> <Label htmlFor={`rg-${opt}`}>{opt}</Label> </div> ))} </div> </RadioGroup.Root> ); } ``` ## Example: Horizontal ```tsx import { RadioGroup, Label } from '@nexub/react'; export default function Example() { return ( <RadioGroup.Root defaultValue="monthly" orientation="horizontal"> <div className="flex gap-4"> {[{ value: 'monthly', label: 'Monthly' }, { value: 'annual', label: 'Annual' }].map(({ value, label }) => ( <div key={value} className="flex items-center gap-2"> <RadioGroup.Item value={value} id={`rgh-${value}`} /> <Label htmlFor={`rgh-${value}`}>{label}</Label> </div> ))} </div> </RadioGroup.Root> ); } ``` --- # Rating Star rating input, supports controlled and read-only modes. - Package: `@nexub/react` · Category: Interactive · Status: stable - Import: `import { Rating } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/rating ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `value` | `number` | | The controlled rating value. | | `max` | `number` | `5` | Maximum number of stars. | | `readOnly` | `boolean` | `false` | Prevents user interaction when true. | | `size` | `'sm' \| 'md' \| 'lg'` | | Size of the star icons. | | `onValueChange` | `(value: number) => void` | | Callback fired when the user selects a new rating. | ## Example: Default ```tsx import * as React from 'react'; import { Rating } from '@nexub/react'; export default function Example() { const [val, setVal] = React.useState(3); return <Rating value={val} onValueChange={setVal} />; } ``` ## Example: Read-only ```tsx import { Rating } from '@nexub/react'; export default function Example() { return <Rating value={4} readOnly />; } ``` ## Example: Sizes ```tsx import { Rating } from '@nexub/react'; export default function Example() { return ( <div className="flex flex-col gap-2 items-start"> <Rating size="sm" value={4} readOnly /> <Rating size="md" value={4} readOnly /> <Rating size="lg" value={4} readOnly /> </div> ); } ``` --- # Resizable Panels Panels with draggable separators, for list–detail and editor layouts. - Package: `@nexub/react` · Category: Layout · Status: beta - Import: `import { ResizablePanels } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/resizable-panels ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `children` (required) | `ReactNode` | | The panels; a separator goes between each pair. | | `direction` | `'horizontal' \| 'vertical'` | `'horizontal'` | Side by side or stacked. | | `sizes / defaultSizes / onSizesChange` | `number[]` | | One percentage per panel, adding up to 100. Save them (localStorage, user settings) to restore the layout. | | `minSizes` | `number[]` | `10 each` | Smallest size per panel, in percent. | | `handleLabel` | `string` | `"Resize panels"` | Names the separators. | ## Example: List and detail ```tsx import { ResizablePanels } from '@nexub/react'; export default function Example() { return ( <ResizablePanels defaultSizes={[35, 65]} minSizes={[20, 30]} className="h-64 w-full rounded-shape-container border border-outline-variant"> <ul className="flex flex-col gap-2 p-4 text-body-md"> <li>Quarterly report</li> <li>Launch checklist</li> <li>Hiring plan</li> </ul> <div className="p-4 text-body-md">Drag the line, or focus it with Tab and use the arrow keys.</div> </ResizablePanels> ); } ``` ## Accessibility - Roles: separator (focusable, with aria-valuenow / min / max and aria-controls) - `Arrow keys`: Move the focused separator by 5%. Mirrored in RTL. - `Home / End`: To the smallest or largest size. - `Enter`: Back to the default split. Related: [sidebar](sidebar.md), [app-shell](app-shell.md) --- # Resource Timeline One row per person, days across: rosters, team leave and allocation, with totals in the footer. - Package: `@nexub/react` · Category: Data Display · Status: alpha - Import: `import { ResourceTimeline } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/resource-timeline ## When to use - Who is where, day by day: rosters, leave, shifts, allocation. - A few weeks across and up to a few dozen people. ## When not to use - Events at times of day: use EventCalendar. - Rows with many fields that sort and filter: use DataTable. ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `label` (required) | `string` | | Names the table, e.g. "Team leave, November". | | `resources` (required) | `TimelineResource[]` | | `{ id, label, description?, avatar? }`, one row each. The first column stays put while the days scroll. | | `range` (required) | `{ from: Date; to: Date }` | | The days shown, both ends included. | | `getCell` | `(resourceId, date) => { value?, tone? } \| undefined` | | A cell’s content. `tone` (neutral, primary, success, warning, error, info) colours it; `value` must say what it means too. | | `onCellActivate` | `(resourceId, date, cell: HTMLElement) => void` | | Makes the cells a grid: arrow keys move between them, Enter, Space or a click calls this, e.g. to open your editor anchored to `cell`. | | `footer` | `(date) => ReactNode` | | A totals row: one cell per day. | | `rowTotal / grandTotal` | `(resourceId) => ReactNode / ReactNode` | | A total column at the end, and its footer cell. | | `resourceHeader` | `ReactNode` | `"Name"` | The first column’s header. | | `weekend` | `number[]` | `[0, 6]` | Days of the week shaded as weekend (0 = Sunday). | | `now` | `Date` | `new Date()` | Marks today. Pin it in tests and screenshots. | ## Example: Team leave Enter or a click on a cell toggles leave; your app opens its own editor there. ```tsx import * as React from 'react'; import { Avatar, ResourceTimeline, type ResourceCell } from '@nexub/react'; // A fixed fortnight, so the page renders the same on the server and in every time zone. const range = { from: new Date(2026, 10, 2), to: new Date(2026, 10, 15) }; const people = [ { id: 'ana', label: 'Ana Lima', description: 'Design' }, { id: 'ben', label: 'Ben Ode', description: 'Engineering' }, { id: 'cho', label: 'Cho Park', description: 'Support' }, ].map((p) => ({ ...p, avatar: <Avatar size="sm" name={p.label} /> })); const leave: ResourceCell = { value: 'AL', tone: 'info' }; export default function Example() { const [cells, setCells] = React.useState<Record<string, ResourceCell>>({ 'ana-3': leave, 'ana-4': leave, 'ben-10': { value: 'Sick', tone: 'warning' } }); const count = (match: (key: string) => boolean) => Object.keys(cells).filter(match).length; return ( <div className="w-full"> <ResourceTimeline label="Team leave, November 2026" resources={people} range={range} now={new Date(2026, 10, 9)} getCell={(id, date) => cells[`${id}-${date.getDate()}`]} onCellActivate={(id, date) => setCells((c) => { const key = `${id}-${date.getDate()}`; const { [key]: had, ...rest } = c; return had ? rest : { ...c, [key]: leave }; }) } footer={(date) => count((k) => k.endsWith(`-${date.getDate()}`)) || ''} rowTotal={(id) => count((k) => k.startsWith(`${id}-`))} grandTotal={Object.keys(cells).length} /> </div> ); } ``` ## Example: Read-only roster Without `onCellActivate` it is a plain table, and the scroller takes focus so the days can be scrolled. ```tsx import { ResourceTimeline } from '@nexub/react'; const range = { from: new Date(2026, 10, 9), to: new Date(2026, 10, 15) }; const people = [ { id: 'ana', label: 'Ana Lima' }, { id: 'ben', label: 'Ben Ode' }, ]; const shifts: Record<string, string> = { 'ana-9': 'Early', 'ana-10': 'Early', 'ben-11': 'Late', 'ben-12': 'Late', 'ben-14': 'On call' }; export default function Example() { return ( <div className="w-full"> <ResourceTimeline label="Support rota" resources={people} range={range} now={new Date(2026, 10, 9)} resourceHeader="Agent" getCell={(id, date) => { const value = shifts[`${id}-${date.getDate()}`]; return value ? { value, tone: value === 'On call' ? 'warning' : 'neutral' } : undefined; }} /> </div> ); } ``` ## Accessibility - `Tab`: Enters the grid at the last focused cell (one Tab stop). - `Arrow keys`: Move between people and days (left and right follow the reading direction). - `Home / End`: First or last day in the row; with Ctrl, the first or last cell. - `Enter / Space / F2`: Calls `onCellActivate` for the cell. - A real table: column headers read the full date, row headers the person, so each cell is announced with both. - With `onCellActivate` the table has `role="grid"` and roving focus; without it, a plain table in a focusable scroll region. - Today’s header has `aria-current="date"` and a filled day number; weekends are shaded and still read their weekday. Related: [event-calendar](event-calendar.md), [data-table](data-table.md) --- # Saved Views A menu to switch, save, update and delete saved filter views. Your app stores them. - Package: `@nexub/react` · Category: Navigation · Status: beta - Import: `import { SavedViews } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/saved-views ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `views` (required) | `{ id: string; name: string }[]` | | The saved views. | | `activeId` | `string` | | The view in use; its name shows on the button. | | `onSelect` (required) | `(id: string) => void` | | Switch to a view: restore its filters, sort and columns. | | `onSave` | `(name: string) => void \| Promise<unknown>` | | Adds "Save as new view…", which asks for a name. A returned promise keeps the dialog busy; a rejection shows its message. | | `onUpdate / onDelete` | `(id: string) => void \| Promise<unknown>` | | Add "Update" and "Delete" for the active view. A returned promise holds the control busy; a rejection shows its message. | | `onRename` | `(id: string, name: string) => void \| Promise<unknown>` | | 11.5: adds "Rename" for the active view, which asks for a new name. | | `confirmDelete` | `boolean` | `false` | 11.5: ask in an AlertDialog before deleting. | | `defaultView` | `string` | | 11.5: the default view’s id. Tagged "Default" in the menu, and applied once on mount when `activeId` is undefined. | | `maxLength` | `number` | | 11.5: the longest name allowed when saving or renaming. | ## Example: Views for a deals table ```tsx 'use client'; import * as React from 'react'; import { SavedViews, type SavedView } from '@nexub/react'; export default function Example() { const [views, setViews] = React.useState<SavedView[]>([ { id: 'mine', name: 'My open deals' }, { id: 'big', name: 'Over $10k' }, ]); const [active, setActive] = React.useState('mine'); return ( <SavedViews views={views} activeId={active} onSelect={setActive} onSave={(name) => { const id = crypto.randomUUID(); setViews((v) => [...v, { id, name }]); setActive(id); }} onUpdate={() => {}} onDelete={(id) => { setViews((v) => v.filter((x) => x.id !== id)); setActive(''); }} /> ); } ``` ## Example: Async, with a default view Save, rename and delete wait on a request. Saving an existing name fails; deleting asks first. ```tsx import * as React from 'react'; import { SavedViews, type SavedView } from '@nexub/react'; // Stands in for a request to your server. const request = () => new Promise((resolve) => setTimeout(resolve, 800)); export default function Example() { const [views, setViews] = React.useState<SavedView[]>([ { id: 'mine', name: 'My open deals' }, { id: 'big', name: 'Over $10k' }, ]); const [active, setActive] = React.useState<string>(); return ( <SavedViews views={views} activeId={active} onSelect={setActive} defaultView="mine" maxLength={40} confirmDelete onSave={async (name) => { await request(); if (views.some((v) => v.name === name)) throw new Error('A view with this name already exists.'); const id = crypto.randomUUID(); setViews((v) => [...v, { id, name }]); setActive(id); }} onRename={async (id, name) => { await request(); setViews((v) => v.map((x) => (x.id === id ? { ...x, name } : x))); }} onDelete={async (id) => { await request(); setViews((v) => v.filter((x) => x.id !== id)); setActive('mine'); }} /> ); } ``` Related: [filter-builder](filter-builder.md), [filter-bar](filter-bar.md), [data-table](data-table.md) --- # Scroll Area Scrollable container with custom styled scrollbars. - Package: `@nexub/react` · Category: Disclosure · Status: stable - Import: `import { ScrollArea } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/scroll-area ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `type` | `'auto' \| 'always' \| 'scroll' \| 'hover'` | `'hover'` | Controls when the scrollbar is visible. "hover" shows it on mouse-over, "scroll" while scrolling, "always" always, "auto" when content overflows. | | `scrollHideDelay` | `number` | `600` | Milliseconds before the scrollbar hides after the user stops interacting (only applies to types "scroll" and "hover"). | | `orientation` | `'vertical' \| 'horizontal' \| 'both'` | `'vertical'` | Which axis(es) to make scrollable. | | `className` | `string` | | Additional CSS class names applied to the viewport wrapper. | | `style` | `React.CSSProperties` | | Inline styles applied to the viewport wrapper. | ## Example: Default ```tsx import { ScrollArea } from '@nexub/react'; export default function Example() { return ( <ScrollArea className="h-50 w-70 border border-outline-variant rounded-shape-field p-3"> {Array.from({ length: 20 }, (_, i) => ( <div key={i} className="py-1 px-0 text-body-sm text-on-surface-variant"> List item {i + 1} </div> ))} </ScrollArea> ); } ``` ## Example: Horizontal ```tsx import { ScrollArea } from '@nexub/react'; export default function Example() { return ( <ScrollArea orientation="horizontal" className="w-80 border border-outline-variant rounded-shape-field p-3"> <div className="flex gap-2 w-max"> {Array.from({ length: 12 }, (_, i) => ( <div key={i} className="w-20 h-20 bg-surface-container-low rounded-shape-tooltip flex items-center justify-center text-label-sm text-on-surface-variant shrink-0" > Card {i + 1} </div> ))} </div> </ScrollArea> ); } ``` --- # Scroll Progress A thin bar along the top that fills as the page scrolls. CSS only. - Package: `@nexub/react` · Category: Motion · Status: beta - Import: `import { ScrollProgress } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/scroll-progress ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `className` | `string` | | Position or colour overrides. Defaults to the accent (the Vivid gradient under data-expression="vivid"). | ## Example: Long page ```tsx import { ScrollProgress } from '@nexub/react'; export default function Example() { return ( <div className="w-full text-body-sm text-on-surface-variant"> <ScrollProgress /> Scroll this page: the bar along the very top of the window fills as you read. </div> ); } ``` ## Accessibility - Decorative (`aria-hidden`); hidden under reduced motion and where scroll-driven animations are not supported. Related: [scroll-area](scroll-area.md) --- # Search Input A text input pre-wired with a search icon and a clear button for filtering content. - Package: `@nexub/react` · Category: Form & Input · Status: stable - Import: `import { SearchInput } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/search-input ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `placeholder` | `string` | | Placeholder text shown when empty. | | `value` | `string` | | Controlled value of the search field. | | `onClear` | `() => void` | | Called when the user clicks the clear button. | | `size` | `'sm' \| 'md' \| 'lg'` | | Controls font size and padding. | ## Example: Default ```tsx import { SearchInput } from '@nexub/react'; export default function Example() { return <div className="w-70"><SearchInput placeholder="Search…" /></div>; } ``` --- # Section A full-width page band with vertical padding and a background tone; put a `Container` inside. - Package: `@nexub/react` · Category: Layout · Status: stable - Import: `import { Section } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/section ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `paddingY` | `'sm' \| 'md' \| 'lg'` | | Vertical padding: 48, 80 or 128 px. | | `tone` | `'default' \| 'subtle' \| 'muted' \| 'inverse'` | | Background: the surface, two container tints, or the inverse surface. | | `asChild` | `boolean` | | Apply the classes to the child element instead of a `<section>`. | ## Example: Tones ```tsx import { Container, Section, Text } from '@nexub/react'; const tones = ['default', 'subtle', 'muted', 'inverse'] as const; export default function Example() { return ( <div className="w-full overflow-hidden rounded-shape-container border border-outline-variant"> {tones.map((tone) => ( <Section key={tone} tone={tone} paddingY="sm" aria-label={`${tone} tone`}> <Container size="sm"> <Text size="body-sm" className="text-inherit">tone="{tone}"</Text> </Container> </Section> ))} </div> ); } ``` ## Accessibility - A `<section>` is a region landmark only when it has an accessible name: give it `aria-labelledby` pointing at its heading. Related: [container](container.md), [box](box.md) --- # Segmented Control Tab-style control for mutually exclusive selections. - Package: `@nexub/react` · Category: Interactive · Status: stable - Import: `import { SegmentedControl } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/segmented-control ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Size of the segmented control. | | `value` | `string` | | The controlled selected value. | | `defaultValue` | `string` | | The initial selected value when uncontrolled. | ## Example: Default ```tsx import { SegmentedControl } from '@nexub/react'; export default function Example() { return ( <SegmentedControl.Root defaultValue="month"> <SegmentedControl.Item value="day">Day</SegmentedControl.Item> <SegmentedControl.Item value="week">Week</SegmentedControl.Item> <SegmentedControl.Item value="month">Month</SegmentedControl.Item> </SegmentedControl.Root> ); } ``` ## Example: Sizes ```tsx import { SegmentedControl } from '@nexub/react'; export default function Example() { return ( <div className="flex flex-col gap-3 items-start"> {(['sm', 'md', 'lg'] as const).map((s) => ( <SegmentedControl.Root key={s} size={s} defaultValue="a"> <SegmentedControl.Item value="a">A</SegmentedControl.Item> <SegmentedControl.Item value="b">B</SegmentedControl.Item> <SegmentedControl.Item value="c">C</SegmentedControl.Item> </SegmentedControl.Root> ))} </div> ); } ``` --- # Select Accessible dropdown select built on Radix UI. Supports groups and search. - Package: `@nexub/react` · Category: Form Controls · Status: stable - Import: `import { Select } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/select ## When to use - Choosing a single option from a list of 5+ items - When screen space is limited and a dropdown collapses the options - Selecting a region, country, currency, or other enumerated value - Filtering or configuring a setting with predefined choices ## When not to use - Fewer than 5 options — use RadioGroup to keep choices visible - Searching or typing to find an option — use Combobox instead - Multi-select — use Combobox or a checkbox list - Boolean on/off choices — use Switch or Checkbox ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `value` | `string` | | Controlled selected value. | | `onValueChange` | `(value: string) => void` | | Callback when value changes. | | `placeholder` | `string` | | Placeholder when no value selected. | | `disabled` | `boolean` | `false` | Disables the select. | ## Example: Default ```tsx import { Select } from '@nexub/react'; export default function Example() { return ( <div className="w-55"> <Select.Root> <Select.Trigger><Select.Value placeholder="Select an option…" /></Select.Trigger> <Select.Content> <Select.Item value="option-1">Option 1</Select.Item> <Select.Item value="option-2">Option 2</Select.Item> <Select.Item value="option-3">Option 3</Select.Item> </Select.Content> </Select.Root> </div> ); } ``` ## Example: Sizes and read-only size on Select.Trigger matches Input. A readOnly trigger keeps its value readable and does not open. ```tsx import { Select } from '@nexub/react'; const sizes = ['sm', 'md', 'lg'] as const; export default function Example() { return ( <div className="flex w-56 flex-col gap-3"> {sizes.map((size) => ( <Select.Root key={size}> <Select.Trigger size={size} aria-label={`Size ${size}`}><Select.Value placeholder={`Size ${size}`} /></Select.Trigger> <Select.Content> <Select.Item value="inr">INR</Select.Item> <Select.Item value="usd">USD</Select.Item> </Select.Content> </Select.Root> ))} <Select.Root defaultValue="inr"> <Select.Trigger readOnly aria-label="Currency"><Select.Value /></Select.Trigger> <Select.Content> <Select.Item value="inr">INR (read-only)</Select.Item> <Select.Item value="usd">USD</Select.Item> </Select.Content> </Select.Root> </div> ); } ``` --- # Separator A horizontal or vertical visual divider. - Package: `@nexub/react` · Category: Dividers · Status: stable - Import: `import { Separator } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/separator ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `orientation` | `'horizontal' \| 'vertical'` | `'horizontal'` | Direction of the separator line. | ## Example: Default ```tsx import { Separator } from '@nexub/react'; export default function Example() { return <div className="w-70"><Separator /></div>; } ``` ## Example: Vertical ```tsx import { Separator } from '@nexub/react'; export default function Example() { return ( <div className="flex h-8 items-center gap-4"> <span className="text-on-surface-variant text-body-sm">Left</span> <Separator orientation="vertical" /> <span className="text-on-surface-variant text-body-sm">Right</span> </div> ); } ``` --- # Shared Element Morphs the same element between two states or pages inside a view transition. - Package: `@nexub/react` · Category: Motion · Status: beta - Import: `import { SharedElement } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/shared-element ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `name` (required) | `string` | | Same name on both sides, e.g. `avatar-${id}`. One element per name on screen at a time. | | `children` (required) | `ReactElement` | | One element; the name is set on it. | ## Example: List to detail ```tsx 'use client'; import * as React from 'react'; import { Avatar, Button, Card, SharedElement, startViewTransition } from '@nexub/react'; const people = [{ id: 'sl', name: 'Sam Lee', role: 'Finance' }, { id: 'ar', name: 'Ana Ruiz', role: 'Design' }]; export default function Example() { const [open, setOpen] = React.useState<string | null>(null); const person = people.find((p) => p.id === open); const go = (id: string | null) => startViewTransition(() => setOpen(id)); return person ? ( <Card variant="surface" className="flex w-full flex-col items-center gap-3 p-8"> <SharedElement name={`avatar-${person.id}`}><Avatar size="xl" fallback={person.id.toUpperCase()} /></SharedElement> <p className="m-0 text-title-lg">{person.name}</p> <Button variant="outlined" onClick={() => go(null)}>Back</Button> </Card> ) : ( <div className="flex w-full flex-col gap-2"> {people.map((p) => ( <Card key={p.id} variant="interactive" asChild> <button type="button" onClick={() => go(p.id)} className="flex items-center gap-3 p-3 text-start"> <SharedElement name={`avatar-${p.id}`}><Avatar size="sm" fallback={p.id.toUpperCase()} /></SharedElement> <span className="text-body-md">{p.name} · {p.role}</span> </button> </Card> ))} </div> ); } ``` ## Accessibility - Visual only: run the change in `startViewTransition()` and move focus to the new view as usual. Related: [motion-fade](motion-fade.md) --- # Sheet Alias for Drawer — slide-in sheet panel. - Package: `@nexub/react` · Category: Overlays · Status: stable - Import: `import { Sheet } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/sheet ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `Sheet.Root` | `compound` | | Root provider that manages open/close state. Exported from Drawer. | | `Sheet.Trigger` | `compound` | | Element that opens the sheet. | | `Sheet.Portal` | `compound` | | Portals the overlay and content into the document body. | | `Sheet.Overlay` | `compound` | | Dimmed backdrop rendered behind the sheet. | | `Sheet.Content` | `compound` | | The sheet panel. Accepts a side prop. | | `scrollLock` | `'style' \| 'class'` | | On Sheet.Root. How page scroll is locked while open. `class` adds a class from @nexub/themes/base instead of injecting a <style> tag, so it works under a strict CSP (style-src 'self'). Default `style`. | | `side` | `'left' \| 'right' \| 'top' \| 'bottom'` | | Edge of the screen from which the sheet slides in. | | `Sheet.Header` | `compound` | | Header section of the sheet panel. | | `Sheet.Footer` | `compound` | | Footer section of the sheet panel. | | `Sheet.Title` | `compound` | | Accessible title for the sheet. | | `Sheet.Description` | `compound` | | Supporting description text for the sheet. | | `Sheet.Close` | `compound` | | Element that closes the sheet. | ## Example: Default ```tsx import * as React from 'react'; import { Button, Sheet, Text } from '@nexub/react'; export default function Example() { const [open, setOpen] = React.useState(false); return ( <> <Button variant="outlined" onClick={() => setOpen(true)}>Open Sheet</Button> <Sheet.Root open={open} onOpenChange={setOpen}> <Sheet.Portal> <Sheet.Overlay /> <Sheet.Content side="right"> <Sheet.Header> <Sheet.Title>Notifications</Sheet.Title> <Sheet.Description>Your recent activity</Sheet.Description> </Sheet.Header> <div className="p-4 flex-1"> <Text size="body-sm" tone="muted">No new notifications.</Text> </div> </Sheet.Content> </Sheet.Portal> </Sheet.Root> </> ); } ``` --- # Sidebar Vertical app navigation: a header, grouped items with icons, and a pinned footer. Collapses to icons. - Package: `@nexub/react` · Category: Navigation · Status: stable - Import: `import { Sidebar } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/sidebar ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `collapsed` | `boolean` | | Icon-only width. Labels stay for screen readers and show as a native tooltip. | | `aria-label` | `string` | | Name of the nav landmark. Defaults to the localised "Sidebar". | | `SidebarHeader status` | `ReactNode` | | Trailing element next to the logo (`Sidebar.Header` children), e.g. a `Badge`. Moves under the logo when they don’t fit. | | `SidebarGroup label` | `string` | | Heading above a group of items. | | `SidebarItem icon` | `ReactNode` | | Leading icon; the only thing shown when collapsed. | | `SidebarItem active` | `boolean` | | Marks the current page (`aria-current="page"`). | | `SidebarItem asChild` | `boolean` | | Use your router `<Link>` as the item; pass it as the only child. | | `Sidebar.Separator / Footer` | `compound` | | A divider, and a footer that stays pinned while the items scroll. | ## Example: Default ```tsx import { Badge, Logo, Sidebar } from '@nexub/react'; import { BarChart3, Folder, Home, Settings, Users } from '@nexub/icons'; export default function Example() { return ( <div className="h-95"> <Sidebar.Root aria-label="Workspace" className="rounded-shape-container"> <Sidebar.Header status={<Badge variant="soft" size="sm">Beta</Badge>}> <Logo size="sm" /> </Sidebar.Header> <Sidebar.Group> <Sidebar.Item href="#" icon={<Home size="sm" />} active>Overview</Sidebar.Item> <Sidebar.Item href="#" icon={<Folder size="sm" />}>Projects</Sidebar.Item> <Sidebar.Item href="#" icon={<BarChart3 size="sm" />}>Reports</Sidebar.Item> </Sidebar.Group> <Sidebar.Group label="Admin"> <Sidebar.Item href="#" icon={<Users size="sm" />}>Members</Sidebar.Item> <Sidebar.Item href="#" icon={<Settings size="sm" />}>Settings</Sidebar.Item> </Sidebar.Group> <Sidebar.Footer className="text-body-sm text-on-surface-muted">v2.4.0</Sidebar.Footer> </Sidebar.Root> </div> ); } ``` ## Example: Collapsed ```tsx import * as React from 'react'; import { Button, Sidebar } from '@nexub/react'; import { BarChart3, Folder, Home, Settings } from '@nexub/icons'; export default function Example() { const [collapsed, setCollapsed] = React.useState(true); return ( <div className="flex h-70 items-start gap-4"> <Sidebar.Root aria-label="Workspace" collapsed={collapsed} className="rounded-shape-container"> <Sidebar.Group> <Sidebar.Item href="#" icon={<Home size="sm" />} active>Overview</Sidebar.Item> <Sidebar.Item href="#" icon={<Folder size="sm" />}>Projects</Sidebar.Item> <Sidebar.Item href="#" icon={<BarChart3 size="sm" />}>Reports</Sidebar.Item> <Sidebar.Item href="#" icon={<Settings size="sm" />}>Settings</Sidebar.Item> </Sidebar.Group> </Sidebar.Root> <Button variant="outlined" onClick={() => setCollapsed((c) => !c)} aria-pressed={!collapsed}> {collapsed ? 'Expand' : 'Collapse'} </Button> </div> ); } ``` Related: [app-shell](app-shell.md), [navigation-rail](navigation-rail.md), [top-nav](top-nav.md) --- # Skeleton Placeholder loading animation that mimics content layout. - Package: `@nexub/react` · Category: Loading States · Status: stable - Import: `import { Skeleton } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/skeleton ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `shape` | `'line' \| 'rect' \| 'circle'` | `'line'` | Shape of the skeleton placeholder. | | `width` | `string \| number` | | Width of the skeleton element. | | `height` | `string \| number` | | Height of the skeleton element. | | `animated` | `boolean` | `true` | Enables the shimmer animation. | ## Example: Default ```tsx import { Skeleton } from '@nexub/react'; export default function Example() { return ( <div className="flex flex-col gap-2 items-start w-70"> <Skeleton shape="line" width="60%" /> <Skeleton shape="line" width="100%" /> <Skeleton shape="line" width="80%" /> <div className="flex gap-2 flex-nowrap items-center justify-center"> <Skeleton shape="circle" width={40} height={40} /> <div className="flex flex-col gap-1.5 items-start flex-1"> <Skeleton shape="line" width="70%" /> <Skeleton shape="line" width="50%" /> </div> </div> </div> ); } ``` ## Example: Shapes ```tsx import { Skeleton } from '@nexub/react'; export default function Example() { return ( <div className="flex gap-4 flex-wrap items-center justify-center"> <Skeleton shape="line" width={80} /> <Skeleton shape="rect" width={80} height={40} /> <Skeleton shape="circle" width={40} height={40} /> </div> ); } ``` --- # Slider Range slider built on Radix UI Slider. - Package: `@nexub/react` · Category: Interactive · Status: stable - Import: `import { Slider } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/slider ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `value` | `number[]` | | The controlled value of the slider. | | `defaultValue` | `number[]` | | The initial value when uncontrolled. | | `min` | `number` | | The minimum value of the slider. | | `max` | `number` | | The maximum value of the slider. | | `step` | `number` | | The step increment between values. | | `disabled` | `boolean` | | Disables slider interaction when true. | | `onValueChange` | `(value: number[]) => void` | | Callback fired when the value changes. | ## Example: Default ```tsx import { Slider } from '@nexub/react'; export default function Example() { return <div className="w-60"><Slider defaultValue={[50]} min={0} max={100} /></div>; } ``` ## Example: Range ```tsx import { Slider } from '@nexub/react'; export default function Example() { return <div className="w-60"><Slider defaultValue={[20, 80]} min={0} max={100} /></div>; } ``` --- # Sortable A list people reorder by dragging or with Alt+Arrow keys on a handle. - Package: `@nexub/react` · Category: Data Display · Status: beta - Import: `import { Sortable } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/sortable ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `items` (required) | `T[]` | | The list, in order. Not used with `list`. | | `getLabel` | `(item) => string` | | The name read in "Move ‹label›" and the move announcements. Defaults to `String(item)`: pass it for objects. | | `getId` | `(item) => string` | | Stable key. Defaults to `item.id`, else a key kept per object, else the value itself (keep string values unique). | | `onReorder` (required) | `(items: T[]) => void` | | Called with the new order; store it. Not used with `list`. | | `children` (required) | `(item) => ReactNode` | | The item’s content; the handle sits before it. | | `aria-label` | `string` | | Names the list. Inside a group it defaults to the list’s label. | | `layout` | `'list' \| 'grid'` | | Default `list`. `grid` wraps items into cells (cards, images); Alt+Arrow keys move an item by one cell or row. | | `variant` | `'default' \| 'flat'` | | Default `default`. `flat` drops the card chrome around items, for dense lists inside a card. | | `disabled` | `boolean` | | Turns every handle off: nothing moves. | | `isLocked` | `(item) => boolean` | | Locked items show a lock, can’t be moved, and keep their index while others move around them, so nothing lands above a locked first item. | | `list` | `string` | | Inside `Sortable.Group`: which of its lists this renders (instead of `items` / `onReorder`). | | `Sortable.Group` | `{ lists: { id, label, items }[]; onChange; getLabel; getId?; isLocked?; disabled? }` | | Owns several lists items move between; `onChange` gets every list after a move. | ## Example: Widget order ```tsx 'use client'; import * as React from 'react'; import { Sortable } from '@nexub/react'; export default function Example() { const [widgets, setWidgets] = React.useState(['Revenue', 'Active users', 'Churn', 'Support tickets']); return ( <Sortable aria-label="Dashboard widgets" items={widgets} getId={(w) => w} getLabel={(w) => w} onReorder={setWidgets} className="w-full max-w-sm"> {(w) => w} </Sortable> ); } ``` ## Example: Grid Cards that wrap; the items have no id. ```tsx 'use client'; import * as React from 'react'; import { Sortable } from '@nexub/react'; type Photo = { name: string; hue: string }; export default function Example() { // No ids: objects get a stable key of their own. const [photos, setPhotos] = React.useState<Photo[]>([ { name: 'Harbour', hue: 'bg-primary-container' }, { name: 'Dunes', hue: 'bg-tertiary-container' }, { name: 'Forest', hue: 'bg-secondary-container' }, { name: 'Glacier', hue: 'bg-surface-container-high' }, { name: 'Canyon', hue: 'bg-primary-container' }, { name: 'Meadow', hue: 'bg-secondary-container' }, ]); return ( <Sortable aria-label="Gallery order" layout="grid" items={photos} getLabel={(p) => p.name} onReorder={setPhotos} className="w-full"> {(p) => ( <figure className="m-0 flex flex-col gap-2"> <div className={`aspect-video rounded-shape-control ${p.hue}`} /> <figcaption className="text-body-sm text-on-surface-variant">{p.name}</figcaption> </figure> )} </Sortable> ); } ``` ## Example: Flat, locked and disabled A dense list in a card: the first column is locked, and the switch turns editing off. ```tsx 'use client'; import * as React from 'react'; import { Card, Sortable, SwitchField } from '@nexub/react'; export default function Example() { const [columns, setColumns] = React.useState(['Name', 'Owner', 'Status', 'Due date', 'Budget']); const [editing, setEditing] = React.useState(true); return ( <Card className="flex w-full max-w-sm flex-col gap-3 p-4"> <SwitchField checked={editing} onCheckedChange={setEditing} label="Edit order" /> <Sortable aria-label="Table columns" variant="flat" disabled={!editing} isLocked={(c) => c === 'Name'} items={columns} getLabel={(c) => c} onReorder={setColumns} > {(c) => c} </Sortable> </Card> ); } ``` ## Example: Groups Move stories between the backlog and the sprint, by drag or Alt+ArrowLeft / Alt+ArrowRight. ```tsx 'use client'; import * as React from 'react'; import { Sortable } from '@nexub/react'; type Story = { id: string; title: string }; type Lists = { id: string; label: string; items: Story[] }[]; export default function Example() { const [lists, setLists] = React.useState<Lists>([ { id: 'backlog', label: 'Backlog', items: [{ id: '1', title: 'Export to CSV' }, { id: '2', title: 'Dark mode charts' }, { id: '3', title: 'SSO for teams' }] }, { id: 'sprint', label: 'This sprint', items: [{ id: '4', title: 'Invoice reminders' }] }, ]); return ( <Sortable.Group lists={lists} onChange={setLists} getLabel={(s) => s.title}> <div className="grid w-full gap-6 sm:grid-cols-2"> {lists.map((l) => ( <div key={l.id} className="flex flex-col gap-2"> <h3 className="m-0 text-title-sm text-on-surface">{l.label}</h3> <Sortable<Story> list={l.id} className="min-h-16"> {(s) => s.title} </Sortable> </div> ))} </div> </Sortable.Group> ); } ``` ## Accessibility - `Alt+ArrowUp / Alt+ArrowDown`: On a handle: moves the item (by a row in a grid); focus stays on its handle. - `Alt+ArrowLeft / Alt+ArrowRight`: In a grid, moves the item by one cell; in a group, to the previous or next list. Mirrored in RTL. - Every handle is a button named "Move ‹label›", described by the key hint. - Moves are announced: "Alpha moved to position 3 of 5", or "Alpha moved to Sprint, position 1 of 2" across lists. - A locked item’s handle is disabled and named "‹label› is locked". - Dragging uses Pointer Events (mouse, pen, touch; Escape cancels), so there is no extra dependency. The settle animation is off under reduced motion. Related: [kanban](kanban.md), [data-table](data-table.md) --- # Sparkline A tiny trend line with no axes, for stat cards and table cells. - Package: `@nexub/react` · Category: Data Display · Status: beta - Import: `import { Sparkline } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/sparkline ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `values` (required) | `number[]` | | The points, oldest first. | | `label` | `string` | | Accessible summary, such as "Revenue, last 12 weeks, up 8%". Without it the sparkline is decorative. | | `color` | `ChartColor` | `1` | Palette colour, 1–8. | | `area` | `boolean` | `false` | Fill the area under the line. | ## Example: In a stat ```tsx import { Sparkline } from '@nexub/react'; export default function Example() { return ( <div className="flex items-end gap-4 rounded-2xl border border-outline-variant p-4"> <div> <p className="text-label-md text-on-surface-variant">Monthly revenue</p> <p className="text-title-lg text-on-surface">$68,420</p> </div> <Sparkline area values={[42, 48, 45, 56, 61, 68]} label="Up 62% over six months" color={2} /> </div> ); } ``` ## Accessibility - The chart is a `figure` named by `title`. The drawing is hidden from assistive tech; a visually hidden table carries every value. - Colour is never the only cue: the legend and table name each series. Past six series, label directly or group the rest as "Other". Related: [line-chart](line-chart.md), [stat-card](stat-card.md) --- # Spinner Animated loading indicator. Inherits color from context. - Package: `@nexub/react` · Category: Feedback · Status: stable - Import: `import { Spinner } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/spinner ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `size` | `'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl'` | `'md'` | Diameter of the spinner. | | `label` | `string` | `'Loading…'` | Screen-reader accessible label. | ## Example: Sizes ```tsx import { Spinner } from '@nexub/react'; export default function Example() { return <div className="flex gap-5 flex-wrap items-center justify-center"><Spinner size="sm" /><Spinner size="md" /><Spinner size="lg" /><Spinner size="xl" /></div>; } ``` ## Example: Inside button ```tsx import { Spinner } from '@nexub/react'; export default function Example() { return ( <div className="flex gap-5 flex-wrap items-center justify-center"> <Spinner size="md" tone="info" /> <Spinner size="md" tone="success" /> <Spinner size="md" tone="warning" /> <Spinner size="md" tone="danger" /> </div> ); } ``` --- # Split Button A primary action with related secondary actions behind a chevron, as one connected control. - Package: `@nexub/react` · Category: Actions · Status: beta - Import: `import { SplitButton } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/split-button ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `menuLabel` (required) | `string` | | Accessible name of the menu toggle, e.g. "More save options". | | `menu` (required) | `ReactNode` | | `DropdownMenu.Item`s for the secondary actions. | | `align` | `'start' \| 'end'` | `'end'` | Menu alignment against the toggle. | | `variant / size / tone` | `Button props` | | Applied to both halves. | ## Example: Default ```tsx import { SplitButton, DropdownMenu } from '@nexub/react'; export default function Example() { return ( <SplitButton menuLabel="More save options" menu={ <> <DropdownMenu.Item>Save as draft</DropdownMenu.Item> <DropdownMenu.Item>Save a copy</DropdownMenu.Item> </> } > Save </SplitButton> ); } ``` ## Example: Outlined ```tsx import { SplitButton, DropdownMenu } from '@nexub/react'; export default function Example() { return ( <SplitButton variant="outlined" menuLabel="More export options" menu={<DropdownMenu.Item>CSV</DropdownMenu.Item>}> Export </SplitButton> ); } ``` Related: [button](button.md), [button-group](button-group.md), [dropdown-menu](dropdown-menu.md) --- # Stack Vertical stack layout with configurable gap. - Package: `@nexub/react` · Category: Layout · Status: stable - Import: `import { Stack } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/stack ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `gap` | `'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl'` | `'md'` | Spacing between child elements. | | `align` | `'start' \| 'center' \| 'end' \| 'stretch'` | | Cross-axis alignment of children. | | `divider` | `boolean` | | Element rendered between each pair of children, e.g. `<Separator />`. | ## Example: Default ```tsx import { Stack, Button } from '@nexub/react'; export default function Example() { return ( <Stack gap="md"> <Button variant="outlined">Item 1</Button> <Button variant="outlined">Item 2</Button> <Button variant="outlined">Item 3</Button> </Stack> ); } ``` ## Example: With dividers ```tsx import { Stack, Separator, Text } from '@nexub/react'; export default function Example() { return ( <Stack gap="md" divider={<Separator />} className="w-55"> <Text size="body-sm">First item</Text> <Text size="body-sm">Second item</Text> <Text size="body-sm">Third item</Text> </Stack> ); } ``` --- # Stage Counter A row of selectable stat cards, each with a count and a failed count, that filters a list. - Package: `@nexub/react` · Category: Data Display · Status: alpha - Import: `import { StageCounter } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/stage-counter ## When to use - Counts per stage above a list of jobs, imports or orders, where pressing a stage filters the list. ## When not to use - Counts that do not filter anything: use StatCard. - Switching between views: use Tabs or SegmentedControl. ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `stages` (required) | `StageCounterStage[]` | | `{ value, label, count, failed?, tone? }`. `failed` shows "3 failed" in the danger tone; `tone` colours the count. | | `value / defaultValue` | `string \| null` | | The selected stage, `null` for all. Pressing the selected stage again clears it. | | `onValueChange` | `(value: string \| null) => void` | | Called with the new stage, or `null`. | | `multiple` | `boolean` | `false` | Several stages at once: `value` is a `string[]`, an empty array means all. | | `aria-label` | `string` | | Names the group, e.g. "Filter by stage". | ## Example: Filters a list ```tsx import * as React from 'react'; import { StageCounter } from '@nexub/react'; const stages = [ { value: 'queued', label: 'Queued', count: 24 }, { value: 'processing', label: 'Processing', count: 6, tone: 'info' as const }, { value: 'review', label: 'In review', count: 3, tone: 'warning' as const }, { value: 'done', label: 'Done', count: 1284, failed: 7 }, ]; const jobs = [ { id: 101, stage: 'queued' }, { id: 102, stage: 'processing' }, { id: 103, stage: 'review' }, { id: 104, stage: 'done' }, { id: 105, stage: 'queued' }, ]; export default function Example() { const [stage, setStage] = React.useState<string | null>(null); const shown = stage ? jobs.filter((j) => j.stage === stage) : jobs; return ( <div className="flex w-full max-w-3xl flex-col gap-4"> <StageCounter aria-label="Filter imports by stage" stages={stages} value={stage} onValueChange={setStage} /> <ul className="m-0 flex flex-col gap-1 ps-4 text-body-md text-on-surface"> {shown.map((j) => ( <li key={j.id}> Import #{j.id} · {stages.find((s) => s.value === j.stage)?.label} </li> ))} </ul> </div> ); } ``` ## Example: Several stages ```tsx import { StageCounter } from '@nexub/react'; export default function Example() { return ( <StageCounter aria-label="Filter orders by stage" multiple defaultValue={['new', 'packing']} stages={[ { value: 'new', label: 'New', count: 18 }, { value: 'packing', label: 'Packing', count: 7 }, { value: 'shipped', label: 'Shipped', count: 342, failed: 2 }, { value: 'returned', label: 'Returned', count: 4, tone: 'danger' }, ]} /> ); } ``` ## Accessibility - Roles: `group` named by `aria-label`; each card is a toggle `button` with `aria-pressed`. - `Tab`: Moves between the stages. - `Enter / Space`: Selects or clears the stage. - The failed count is written out ("3 failed"), not shown by colour alone. Cards wrap on small screens. Related: [stat-card](stat-card.md), [segmented-control](segmented-control.md), [filter-bar](filter-bar.md), [toggle-group](toggle-group.md) --- # Stepper Progress through a multi-step flow, with clickable steps that follow the order you allow. - Package: `@nexub/react` · Category: Navigation · Status: beta - Import: `import { Stepper } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/stepper ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `steps` (required) | `{ id, label, description? }[]` | | The steps in order. | | `current` (required) | `number` | | Index of the step being shown. | | `completed` | `number[]` | | Finished steps. Defaults to every step before `current`. | | `onStepChange` | `(index) => void` | | Makes reachable steps buttons: finished ones and the first unfinished one. | | `nonLinear` | `boolean` | | Every step is reachable. | | `orientation` | `'horizontal' \| 'vertical'` | `'horizontal'` | Vertical suits side columns and narrow screens. | | `aria-label` | `string` | | Names the navigation landmark, e.g. "Setup steps". | | `steps[].status` | `'complete' \| 'current' \| 'upcoming' \| 'error' \| 'warning' \| 'skipped' \| 'cancelled'` | | 11.4: the step's state, named as in StatusSteps; read after the label. Wins over `current` and `completed`. | | `steps[].description` | `ReactNode` | | 11.4: any content (a date, a link). | | `steps[].actions` | `ReactNode` | | 11.4: actions under the step, e.g. Retry. | ## Example: Wizard with a form per step ```tsx 'use client'; import * as React from 'react'; import { Button, Form, FormField, Input, Stepper } from '@nexub/react'; const steps = [ { id: 'account', label: 'Account' }, { id: 'workspace', label: 'Workspace' }, { id: 'done', label: 'Done' }, ]; export default function Example() { const [current, setCurrent] = React.useState(0); return ( <div className="flex w-full max-w-lg flex-col gap-6"> <Stepper aria-label="Sign-up steps" steps={steps} current={current} onStepChange={setCurrent} /> {current < 2 ? ( <Form key={current} onSubmit={() => setCurrent(current + 1)}> <FormField.Root name={current === 0 ? 'email' : 'workspace'} required> <FormField.Label>{current === 0 ? 'Work email' : 'Workspace name'}</FormField.Label> <FormField.Control> <Input type={current === 0 ? 'email' : 'text'} /> </FormField.Control> <FormField.Error /> </FormField.Root> <Button type="submit" className="self-start">Continue</Button> </Form> ) : ( <p className="text-body-md">All set.</p> )} </div> ); } ``` ## Example: Statuses and actions `current={-1}` for "all done" is deprecated in 11.4 (removed in 12.0): use `status`. `nexub-migrate --rules deprecated-in-11` finds it. ```tsx import { Button, Stepper } from '@nexub/react'; export default function Example() { return ( <Stepper className="w-full" current={2} steps={[ { label: 'Details', status: 'complete' }, { label: 'Identity', status: 'skipped', description: 'Not needed for this plan' }, { label: 'Bank check', status: 'error', description: 'The bank rejected the account', actions: <Button size="sm" variant="outlined">Retry</Button> }, { label: 'Payout', status: 'upcoming' }, ]} /> ); } ``` ## Accessibility - A `nav` with an ordered list; the current step has `aria-current="step"`. - Each step reads "Step 2 of 4: Billing", plus "completed" when finished. - Validate each step with a Form and move `current` on its submit. Related: [form](form.md), [tabs](tabs.md) --- # Streaming Text Assistant text as it arrives: new chunks fade in, text already shown stays still, and a caret marks the end. - Package: `@nexub/react` · Category: AI · Status: beta - Import: `import { StreamingText } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/streaming-text ## When to use - Any model output rendered token by token. ## When not to use - Finished text loaded from history: render it as plain text, or with `streaming={false}`. - Model output as HTML or Markdown HTML: StreamingText renders text only. Parse Markdown to React elements yourself; never inject model HTML. ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `text` (required) | `string` | | The full text received so far. Append to it; anything that is not an append renders statically. | | `streaming` | `boolean` | `false` | Shows the caret and sets `aria-busy` while more text is expected. | | `as` | `'div' \| 'p' \| 'span'` | `'div'` | Element to render. | | `aria-live` | `'off' \| 'polite'` | `'off'` | Opt-in live announcements. Leave off: screen readers would re-read the region on every token. | ## Example: Streaming a reply Words arrive on a timer. Restart streams the paragraph again. ```tsx import * as React from 'react'; import { StreamingText, Button } from '@nexub/react'; const STREAM_DEMO_TEXT = 'Tokens arrive a few characters at a time. Each new chunk fades in while the text before it stays put, so the eye can keep reading.'; export default function Example() { const [length, setLength] = React.useState(0); const streaming = length < STREAM_DEMO_TEXT.length; React.useEffect(() => { if (!streaming) return; const id = setTimeout(() => setLength((n) => Math.min(STREAM_DEMO_TEXT.length, n + 6)), 60); return () => clearTimeout(id); }, [length, streaming]); return ( <div className="flex flex-col gap-3 items-start max-w-120"> <StreamingText as="p" text={STREAM_DEMO_TEXT.slice(0, length)} streaming={streaming} /> <Button variant="outlined" size="sm" onClick={() => setLength(0)}>Restart</Button> </div> ); } ``` ## Accessibility - Not a live region by default. Announce the finished message once instead, e.g. through a polite status or Conversation’s `announce` for whole messages. - `aria-busy` is true while streaming, so assistive tech can wait for the final text. - The caret is decorative (`aria-hidden`). With reduced motion, chunks appear without fading and the caret does not blink. - Only the last three chunks keep their own span, so the DOM stays flat however long the reply gets. Related: [message-bubble](message-bubble.md), [thinking-indicator](thinking-indicator.md), [conversation](conversation.md) --- # Success Check A small success moment: a ring that pops in and a tick that draws. - Package: `@nexub/react` · Category: Feedback · Status: alpha - Import: `import { SuccessCheck } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/success-check ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `label` | `string` | | Accessible name, e.g. "Payment sent". Without it the mark is decorative: say the result in text. | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Size of the mark. | ## Example: Default ```tsx import { SuccessCheck } from '@nexub/react'; export default function Example() { return ( <div className="flex flex-col items-center gap-3"> <SuccessCheck size="lg" /> <p className="m-0 text-title-md text-on-surface">Payment sent</p> </div> ); } ``` ## Example: Sizes ```tsx import { SuccessCheck } from '@nexub/react'; export default function Example() { return ( <div className="flex items-center gap-4"> <SuccessCheck size="sm" label="Saved" /> <SuccessCheck size="md" label="Saved" /> <SuccessCheck size="lg" label="Saved" /> </div> ); } ``` Related: [celebrate](celebrate.md), [toast](toast.md) --- # Switch Field A Switch with its label, description and error, the label clickable. - Package: `@nexub/react` · Category: Form Controls · Status: alpha - Import: `import { SwitchField } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/switch-field ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `label` (required) | `ReactNode` | | Names the switch; clicking it toggles. | | `description / error` | `ReactNode` | | Help under the label and the error under the row. `error` marks the switch invalid. | | `layout` | `'end' \| 'start'` | `'end'` | `'end'`: label first, the switch at the row end (settings lists). `'start'`: the switch first, for tight rows. | | `checked / onCheckedChange` | `boolean / (checked: boolean) => void` | | As Switch, with `size`, `loading`, `disabled` and `readOnly`. | ## Example: Settings row ```tsx import { SwitchField } from '@nexub/react'; export default function Example() { return ( <div className="flex w-full max-w-md flex-col gap-4"> <SwitchField label="Online store" description="Buyers can see and order from the shop" defaultChecked /> <SwitchField label="Two-step sign-in" error="Required by your organisation" /> </div> ); } ``` ## Example: Compact, before the label ```tsx import { SwitchField } from '@nexub/react'; export default function Example() { return <SwitchField label="Email me a weekly summary" layout="start" size="sm" />; } ``` ## Accessibility - The label is a `<label for>` on the switch, so it names it and toggles it. - Description and error are linked with `aria-describedby`. Related: [switch](switch.md), [checkbox-field](checkbox-field.md), [form-field](form-field.md) --- # Switch Toggle control for binary on/off settings. Built on Radix UI Switch. - Package: `@nexub/react` · Category: Form Controls · Status: stable - Import: `import { Switch } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/switch ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `checked` | `boolean` | | Controlled checked state. | | `defaultChecked` | `boolean` | `false` | Uncontrolled initial state. | | `onCheckedChange` | `(checked: boolean) => void` | | Callback when checked state changes. | | `disabled` | `boolean` | `false` | Disables interaction. | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Switch size. | ## Example: Default ```tsx import { Switch } from '@nexub/react'; export default function Example() { return <div className="flex gap-4 flex-wrap items-center justify-center"><Switch defaultChecked /><Switch /></div>; } ``` ## Example: Sizes ```tsx import { Switch } from '@nexub/react'; export default function Example() { return <div className="flex gap-4 flex-wrap items-center justify-center"><Switch size="sm" defaultChecked /><Switch size="md" defaultChecked /><Switch size="lg" defaultChecked /></div>; } ``` --- # Table Semantic HTML table with styled variants. - Package: `@nexub/react` · Category: Data Display · Status: stable - Import: `import { Table } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/table ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `Table.Root striped` | `boolean` | `false` | Applies alternating row background colours. | | `Table.Root bordered` | `boolean` | `false` | Adds borders between rows and columns. | | `Table.Root hoverable` | `boolean` | `false` | Highlights rows on mouse hover. | | `Table.Root stickyHeader` | `boolean` | `false` | Fixes the table header to the top when scrolling inside a scrollable container. | | `Table.Head align` | `'start' \| 'center' \| 'end'` | `'start'` | Text alignment within the header cell. | | `Table.Cell align` | `'start' \| 'center' \| 'end'` | `'start'` | Text alignment within the data cell. | | `Table.Caption side` | `'top' \| 'bottom'` | `'bottom'` | Whether the caption appears above or below the table. | ## Example: Default ```tsx import { Table, Badge } from '@nexub/react'; export default function Example() { const rows = [ { name: 'Alice Brown', status: 'Active', date: 'Jan 15, 2026' }, { name: 'Bob Carter', status: 'Pending', date: 'Jan 14, 2026' }, { name: 'Carol Davis', status: 'Inactive', date: 'Jan 10, 2026' }, ]; return ( <Table.Root className="w-full max-w-120"> <Table.Header> <Table.Row> <Table.Head>Name</Table.Head> <Table.Head>Status</Table.Head> <Table.Head>Date</Table.Head> </Table.Row> </Table.Header> <Table.Body> {rows.map((r) => ( <Table.Row key={r.name}> <Table.Cell>{r.name}</Table.Cell> <Table.Cell><Badge tone={r.status === 'Active' ? 'success' : r.status === 'Pending' ? 'warning' : 'neutral'} size="sm">{r.status}</Badge></Table.Cell> <Table.Cell>{r.date}</Table.Cell> </Table.Row> ))} </Table.Body> </Table.Root> ); } ``` ## Example: With caption ```tsx import { Table, Badge } from '@nexub/react'; export default function Example() { const rows = [ { name: 'Alice Brown', status: 'Active', date: 'Jan 15, 2026' }, { name: 'Bob Carter', status: 'Pending', date: 'Jan 14, 2026' }, { name: 'Carol Davis', status: 'Inactive', date: 'Jan 10, 2026' }, ]; return ( <Table.Root className="w-full max-w-120"> <Table.Caption>Recent user activity — last 30 days</Table.Caption> <Table.Header> <Table.Row> <Table.Head>Name</Table.Head> <Table.Head>Status</Table.Head> <Table.Head>Date</Table.Head> </Table.Row> </Table.Header> <Table.Body> {rows.map((r) => ( <Table.Row key={r.name}> <Table.Cell>{r.name}</Table.Cell> <Table.Cell><Badge variant="soft" tone={r.status === 'Active' ? 'success' : r.status === 'Pending' ? 'warning' : 'neutral'}>{r.status}</Badge></Table.Cell> <Table.Cell>{r.date}</Table.Cell> </Table.Row> ))} </Table.Body> <Table.Footer> <Table.Row> <Table.Cell colSpan={3} className="text-on-surface-variant text-body-sm"> Showing {rows.length} of {rows.length} users </Table.Cell> </Table.Row> </Table.Footer> </Table.Root> ); } ``` ## Example: Sticky header, compact and striped `stickyHeader` with `maxHeight` keeps the header in view, `density="compact"` tightens this table only, and `striped` tints every other row. ```tsx import { Table } from '@nexub/react'; const rows = Array.from({ length: 12 }, (_, i) => ({ name: `Person ${i + 1}`, role: i % 3 === 0 ? 'Admin' : 'Member' })); export default function Example() { return ( <Table.Root aria-label="People" stickyHeader maxHeight={240} density="compact" striped className="w-full max-w-[30rem]"> <Table.Header> <Table.Row> <Table.Head>Name</Table.Head> <Table.Head>Role</Table.Head> </Table.Row> </Table.Header> <Table.Body> {rows.map((r) => ( <Table.Row key={r.name}> <Table.Cell>{r.name}</Table.Cell> <Table.Cell>{r.role}</Table.Cell> </Table.Row> ))} </Table.Body> </Table.Root> ); } ``` --- # Tabs Layered content panels switched by tab triggers. Built on Radix UI Tabs. - Package: `@nexub/react` · Category: Navigation · Status: stable - Import: `import { Tabs } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/tabs ## When to use - Switching between related views within the same page context - Organising content that belongs to the same entity - Reducing visual clutter by hiding secondary content behind tabs - Horizontal navigation within a bounded section ## When not to use - Global site navigation — use the sidebar or top nav - Sequential steps in order — use Stepper - Comparing content side-by-side — keep both views visible - More than 5–7 tabs — consider a Select or sub-navigation ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `defaultValue` | `string` | | Initially active tab value (uncontrolled). | | `value` | `string` | | Controlled active tab value. | | `onValueChange` | `(value: string) => void` | | Callback when active tab changes. | | `orientation` | `'horizontal' \| 'vertical'` | `'horizontal'` | Layout direction of the tab list. | ## Example: Default ```tsx import { Tabs } from '@nexub/react'; export default function Example() { return ( <div className="w-80"> <Tabs.Root defaultValue="tab1"> <Tabs.List> <Tabs.Trigger value="tab1">Overview</Tabs.Trigger> <Tabs.Trigger value="tab2">Analytics</Tabs.Trigger> <Tabs.Trigger value="tab3">Settings</Tabs.Trigger> </Tabs.List> <Tabs.Content value="tab1"> <div className="py-3 px-0 text-on-surface-variant text-body-sm">Overview content goes here.</div> </Tabs.Content> <Tabs.Content value="tab2"> <div className="py-3 px-0 text-on-surface-variant text-body-sm">Analytics content goes here.</div> </Tabs.Content> <Tabs.Content value="tab3"> <div className="py-3 px-0 text-on-surface-variant text-body-sm">Settings content goes here.</div> </Tabs.Content> </Tabs.Root> </div> ); } ``` ## Example: Vertical orientation="vertical": the indicator slides on the inline-end edge, and arrow up/down move between tabs. ```tsx import { Tabs } from '@nexub/react'; export default function Example() { return ( <div className="w-105"> <Tabs.Root defaultValue="profile" orientation="vertical"> <Tabs.List aria-label="Account"> <Tabs.Trigger value="profile">Profile</Tabs.Trigger> <Tabs.Trigger value="security">Security</Tabs.Trigger> <Tabs.Trigger value="billing">Billing</Tabs.Trigger> </Tabs.List> <Tabs.Content value="profile"> <div className="p-3 text-body-sm text-on-surface-variant">Name, photo and contact details.</div> </Tabs.Content> <Tabs.Content value="security"> <div className="p-3 text-body-sm text-on-surface-variant">Password, passkeys and sessions.</div> </Tabs.Content> <Tabs.Content value="billing"> <div className="p-3 text-body-sm text-on-surface-variant">Plan, invoices and payment method.</div> </Tabs.Content> </Tabs.Root> </div> ); } ``` --- # Text Gradient Renders text with a brand gradient fill. - Package: `@nexub/react` · Category: Inline Primitives · Status: stable - Import: `import { TextGradient } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/text-gradient ## Example: Default ```tsx import { TextGradient } from '@nexub/react'; export default function Example() { return <TextGradient className="text-headline-sm font-bold">Design system for ambitious teams</TextGradient>; } ``` ## Example: In heading ```tsx import { Heading, TextGradient } from '@nexub/react'; export default function Example() { return ( <Heading size="h2"> <TextGradient>Build faster, ship consistently</TextGradient> </Heading> ); } ``` --- # Text Paragraph text component with size, tone, and weight variants. - Package: `@nexub/react` · Category: Typography · Status: stable - Import: `import { Text } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/text ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `size` | `'body-lg' \| 'body' \| 'body-sm' \| 'caption' \| 'label'` | `'body'` | Controls the font size and line height. | | `tone` | `'default' \| 'secondary' \| 'muted' \| 'subtle' \| 'inverse' \| 'danger' \| 'success' \| 'warning'` | | Color tone applied to the text. The status tones (11.1) meet 4.5:1 on every surface. | | `weight` | `'regular' \| 'medium' \| 'semibold' \| 'bold'` | | Font weight of the text. | | `truncate` | `boolean` | | Truncates text with an ellipsis when it overflows. | | `lineClamp` | `number` | | Clamps the text to a maximum number of lines. | | `asChild` | `boolean` | | Merges props onto the immediate child element (Radix Slot). | ## Example: Default ```tsx import { Text } from '@nexub/react'; export default function Example() { return <Text>The Nexub design system provides accessible, token-driven components.</Text>; } ``` ## Example: Sizes ```tsx import { Text } from '@nexub/react'; export default function Example() { return ( <div className="flex flex-col gap-1.5 items-start"> <Text size="body-lg">Body Large — spacious reading.</Text> <Text size="body">Body — default paragraph.</Text> <Text size="body-sm">Body Small — compact content.</Text> <Text size="caption">Caption — supporting info.</Text> </div> ); } ``` ## Example: Tones ```tsx import { Text } from '@nexub/react'; export default function Example() { return ( <div className="flex flex-col gap-1.5 items-start"> <Text tone="default">Default</Text> <Text tone="secondary">Secondary</Text> <Text tone="muted">Muted</Text> <Text tone="subtle">Subtle</Text> <Text tone="danger">Danger</Text> <Text tone="success">Success</Text> <Text tone="warning">Warning</Text> </div> ); } ``` --- # Textarea A multi-line text input with configurable resize behaviour, size, and validation states. - Package: `@nexub/react` · Category: Form & Input · Status: stable - Import: `import { Textarea } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/textarea ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `placeholder` | `string` | | Placeholder text shown when the field is empty. | | `disabled` | `boolean` | | Disables the textarea. | | `invalid` | `boolean` | | Applies error styling to indicate a validation failure. | | `rows` | `number` | | Initial visible row count. | | `resize` | `'none' \| 'vertical' \| 'horizontal' \| 'both'` | `'vertical'` | Controls resize handle visibility. | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Controls font size and padding. | ## Example: Default ```tsx import { Textarea } from '@nexub/react'; export default function Example() { return <div className="w-70"><Textarea placeholder="Enter your message…" /></div>; } ``` ## Example: Sizes ```tsx import { Textarea } from '@nexub/react'; export default function Example() { return ( <div className="flex flex-col gap-2 items-start w-70"> <Textarea size="sm" placeholder="Small" rows={2} /> <Textarea size="md" placeholder="Medium" rows={3} /> <Textarea size="lg" placeholder="Large" rows={4} /> </div> ); } ``` ## Example: Invalid ```tsx import { Textarea } from '@nexub/react'; export default function Example() { return <div className="w-70"><Textarea invalid placeholder="This field has an error" /></div>; } ``` --- # Thinking Indicator Shows the assistant is working before the first token arrives: a morphing shape and a shimmering label. - Package: `@nexub/react` · Category: AI · Status: beta - Import: `import { ThinkingIndicator } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/thinking-indicator ## When to use - The gap between sending a prompt and the first token of the reply. - Tool calls or retrieval steps inside a reply, with a label naming the step. ## When not to use - Once text is streaming: StreamingText’s caret already shows progress. Replace the indicator, don’t stack them. - General loading outside AI surfaces: use Spinner or Skeleton. ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `label` | `ReactNode \| null` | `messages.thinking ('Thinking')` | Visible text. `null` hides it; "Thinking" is still announced. | | `size` | `'sm' \| 'md'` | `'md'` | Shape and text size. | | `messages` | `Partial<{ thinking: string }>` | | Local override for the default text. | ## Example: Default ```tsx import { ThinkingIndicator } from '@nexub/react'; export default function Example() { return <ThinkingIndicator />; } ``` ## Example: Custom label and sizes Name the step when you know it. `label={null}` keeps only the shape. ```tsx import { ThinkingIndicator } from '@nexub/react'; export default function Example() { return ( <div className="flex flex-col gap-4 items-start"> <ThinkingIndicator label="Searching 4 sources" /> <ThinkingIndicator size="sm" /> <ThinkingIndicator size="sm" label={null} /> </div> ); } ``` ## Accessibility - Roles: status - A polite live region: the label is announced once when it mounts. Changing the label announces the new step. - Render it only while waiting and remove it when tokens start, so it is not announced again. - With reduced motion the shape and shimmer are static. Related: [streaming-text](streaming-text.md), [spinner](spinner.md), [conversation](conversation.md) --- # Time Picker A time field on the native time input: 12 or 24 hours from the reader’s locale, and the platform picker on phones. - Package: `@nexub/react` · Category: Form & Input · Status: beta - Import: `import { TimePicker } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/time-picker ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `value / defaultValue / onValueChange` | `string` | | 24-hour `"HH:mm"`, whatever the display format. | | `minuteStep` | `number` | `1` | Minutes per step for the arrow keys and the picker. | | `min / max / required / name` | `string \| boolean` | | Native attributes; Form validates them. | ## Example: Reminder time ```tsx import { FormField, TimePicker } from '@nexub/react'; export default function Example() { return ( <FormField.Root name="reminder" className="w-40"> <FormField.Label>Remind me at</FormField.Label> <FormField.Control> <TimePicker defaultValue="09:00" minuteStep={15} /> </FormField.Control> </FormField.Root> ); } ``` ## Accessibility - `ArrowUp / ArrowDown`: Changes the focused segment (hour, minute, AM/PM). - `ArrowLeft / ArrowRight`: Moves between segments. - Native `<input type="time">`: screen readers announce each segment, and phones open their own time picker. Related: [date-time-picker](date-time-picker.md), [date-picker](date-picker.md) --- # Time Slot Picker Pick one time from a list of slots, for booking flows. - Package: `@nexub/react` · Category: Form Controls · Status: alpha - Import: `import { TimeSlotPicker } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/time-slot-picker ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `slots` (required) | `{ value: string; label?: string; disabled?: boolean; hint?: string }[]` | | The times. `value` is `HH:mm` or an ISO date-time; the label defaults to the time in the provider locale. | | `value / defaultValue / onValueChange` | `string` | | The selected slot value. | | `groupBy` | `'none' \| 'period'` | `'none'` | `period` adds Morning, Afternoon and Evening headings. | | `columns` | `2 \| 3 \| 4 \| 'auto'` | `'auto'` | Slots per row. `auto` fits as many as the width allows; 3 and 4 drop to fewer where the picker is narrow. | | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Slot height. `md` and `lg` are at least 44px tall. | | `invalid / disabled / readOnly / required` | `boolean` | | Group states. Inside `FormField.Control` they come from the field. | | `name` | `string` | | Submits the selected value with a form. | | `emptyState` | `ReactNode` | `'No times available'` | Shown when `slots` is empty. | ## Example: Default ```tsx import * as React from 'react'; import { TimeSlotPicker } from '@nexub/react'; const slots = [ { value: '09:00' }, { value: '09:30' }, { value: '10:00', disabled: true }, { value: '10:30' }, { value: '11:00', hint: 'Last one' }, { value: '11:30' }, ]; export default function Example() { const [time, setTime] = React.useState('09:30'); return ( <div className="flex w-96 max-w-full flex-col gap-3"> <TimeSlotPicker aria-label="Start time" slots={slots} value={time} onValueChange={setTime} /> <p aria-live="polite" className="text-body-sm text-on-surface-muted"> Selected: {time} </p> </div> ); } ``` ## Example: Grouped by time of day ```tsx import * as React from 'react'; import { FormField, TimeSlotPicker } from '@nexub/react'; const slots = ['08:30', '10:00', '11:30', '13:00', '14:30', '16:00', '17:30', '19:00'].map((value) => ({ value, disabled: value === '13:00', })); export default function Example() { return ( <FormField.Root name="time" className="w-96 max-w-full"> <FormField.Control> <TimeSlotPicker aria-label="Appointment time" slots={slots} groupBy="period" columns={3} /> </FormField.Control> <FormField.Description>Times are shown in the venue’s time zone.</FormField.Description> </FormField.Root> ); } ``` ## Accessibility - `Tab`: Moves into the group, to the selected slot. - `Arrow keys`: Move to and select the next available slot. - A radio group: give it an `aria-label` or `aria-labelledby` (it defaults to "Choose a time"). - Unavailable slots are struck through and read as "9:30 AM, unavailable". - A slot is named by its time; `hint` is its description. Related: [radio-card](radio-card.md), [date-picker](date-picker.md), [segmented-control](segmented-control.md) --- # Toast Imperative toast notifications using the toast object. Render <Toaster /> once in your layout. - Package: `@nexub/react` · Category: Feedback · Status: stable - Import: `import { Toast } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/toast ## When to use - Confirming a non-blocking action (file saved, message sent) - Reporting a background event the user should know about - Providing brief feedback that disappears automatically - Offering an undo action immediately after a destructive operation ## When not to use - Critical errors that block the user — use Alert or AlertDialog - Information the user must read and acknowledge — use Dialog - Persistent status that should remain visible — use Alert - Long messages with multiple lines of text ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `Toaster expand` | `boolean` | `false` | Always show toasts as a list. By default they collapse into a stack that fans out on hover or focus, which also pauses their timers. | | `Toaster position` | `'top-start' \| 'top-center' \| 'top-end' \| 'bottom-start' \| 'bottom-center' \| 'bottom-end'` | `'top-end'` | Where the stack sits (5.1). Start and end follow the reading direction; bottom positions stack upward. | | `Toaster visibleToasts` | `number` | `3` | How many toasts show at once. Older ones are hidden visually but stay in the live region. | | `toast.success(title, opts?)` (required) | `string` | | Show a success toast with an optional options object. | | `toast.error(title, opts?)` (required) | `string` | | Show an error toast. | | `toast.warning(title, opts?)` (required) | `string` | | Show a warning toast. | | `toast.info(title, opts?)` (required) | `string` | | Show an info toast. | | `toast.custom(title, opts?)` (required) | `string` | | Show a default/custom toast. | | `toast.undoable(title, opts)` (required) | `UndoableToastOptions` | | A toast with an Undo action (beta, 1.7.0). Undo calls `opts.onUndo`; any other close (timer, swipe, close button, `toast.dismiss`) calls `opts.onCommit`, exactly once. Returns the toast id. | | `undoable opts` | `{ onUndo; onCommit?; undoLabel?; description?; duration? }` | | `undoLabel` defaults to the `undo` message ("Undo"). Commit the change in `onCommit`, not before showing the toast. | | `opts.description` | `string` | | Secondary supporting text below the title. | | `opts.duration` | `number` | `5000` | Time in ms before auto-dismiss. Use Infinity to persist. | | `opts.action` | `{ label: string; onClick: () => void }` | | Renders an action button inside the toast. | ## Example: Default ```tsx import { Button, toast } from '@nexub/react'; // The docs root layout already renders <Toaster />; a second one doubles every toast. export default function Example() { return ( <Button variant="outlined" onClick={() => toast.custom('Changes saved', { description: 'Your profile has been updated.' })}> Show toast </Button> ); } ``` ## Example: Variants ```tsx import { Button, toast } from '@nexub/react'; export default function Example() { return ( <div className="flex gap-2 flex-wrap items-center justify-center"> <Button variant="outlined" size="sm" onClick={() => toast.success('Saved successfully!')}>Success</Button> <Button variant="outlined" size="sm" onClick={() => toast.error('Something went wrong.')}>Error</Button> <Button variant="outlined" size="sm" onClick={() => toast.warning('Review required.')}>Warning</Button> <Button variant="outlined" size="sm" onClick={() => toast.info('New update available.')}>Info</Button> </div> ); } ``` ## Example: With action ```tsx import { Button, toast } from '@nexub/react'; export default function Example() { return ( <Button variant="outlined" onClick={() => toast.custom('File deleted', { description: 'The file was moved to trash.', action: { label: 'Undo', onClick: () => {} }, }) } > Delete with undo </Button> ); } ``` ## Example: Undoable delete Hide the item right away; delete it for real only when the toast closes without Undo. ```tsx import * as React from 'react'; import { Button, toast } from '@nexub/react'; export default function Example() { const [hidden, setHidden] = React.useState(false); const remove = () => { setHidden(true); toast.undoable('Invoice deleted', { description: 'INV-2041', onUndo: () => setHidden(false), onCommit: () => {}, }); }; return hidden ? ( <Button variant="text" onClick={() => setHidden(false)}>Restore demo</Button> ) : ( <Button variant="outlined" tone="danger" onClick={remove}>Delete INV-2041</Button> ); } ``` --- # Toggle Group Group of toggle buttons where one or many can be active. - Package: `@nexub/react` · Category: Interactive · Status: stable - Import: `import { ToggleGroup } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/toggle-group ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `type` (required) | `'single' \| 'multiple'` | | Controls whether one or multiple items can be active at a time. | | `value` | `string \| string[]` | | The controlled active value(s). | | `variant` | `'default' \| 'outline'` | | Visual style applied to all toggle items in the group. | ## Example: Single ```tsx import { ToggleGroup } from '@nexub/react'; export default function Example() { return ( <ToggleGroup.Root type="single" defaultValue="left"> <ToggleGroup.Item value="left">Left</ToggleGroup.Item> <ToggleGroup.Item value="center">Center</ToggleGroup.Item> <ToggleGroup.Item value="right">Right</ToggleGroup.Item> </ToggleGroup.Root> ); } ``` ## Example: Multiple ```tsx import { ToggleGroup } from '@nexub/react'; export default function Example() { return ( <ToggleGroup.Root type="multiple" defaultValue={['bold', 'italic']}> <ToggleGroup.Item value="bold">Bold</ToggleGroup.Item> <ToggleGroup.Item value="italic">Italic</ToggleGroup.Item> <ToggleGroup.Item value="underline">Underline</ToggleGroup.Item> </ToggleGroup.Root> ); } ``` --- # Toggle Pressable toggle button built on Radix UI Toggle. - Package: `@nexub/react` · Category: Interactive · Status: stable - Import: `import { Toggle } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/toggle ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `pressed` | `boolean` | | The controlled pressed state. | | `defaultPressed` | `boolean` | | The initial pressed state when uncontrolled. | | `variant` | `'default' \| 'outline'` | | Visual style of the toggle button. | | `size` | `'sm' \| 'md' \| 'lg'` | | Size of the toggle button. | | `disabled` | `boolean` | | Disables the toggle when true. | ## Example: Default ```tsx import { Toggle } from '@nexub/react'; export default function Example() { return <Toggle>Bold</Toggle>; } ``` ## Example: Outline variants ```tsx import { Toggle } from '@nexub/react'; export default function Example() { return ( <div className="flex gap-2 flex-wrap items-center justify-center"> <Toggle variant="outline">Italic</Toggle> <Toggle variant="outline" defaultPressed>Bold</Toggle> </div> ); } ``` --- # Tool Call One tool call: its name and status, expandable to input and output. - Package: `@nexub/react` · Category: AI · Status: beta - Import: `import { ToolCall } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/tool-call ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `name` (required) | `string` | | Tool name. | | `status` (required) | `'running' \| 'done' \| 'failed'` | | Shown as a badge. | | `input` | `unknown` | | Arguments, shown as JSON. | | `output` | `unknown` | | Result, as text or JSON. | ## Example: Tool call ```tsx import { ToolCall } from '@nexub/react'; export default function Example() { return ( <div className="flex w-full flex-col gap-2"> <ToolCall name="search_invoices" status="done" input={{ customer: 'Acme', status: 'unpaid' }} output={{ found: 3, total: '$4,120' }} open /> <ToolCall name="draft_email" status="running" input={{ to: 'ap@acme.example', template: 'reminder' }} /> </div> ); } ``` ## Accessibility - A native `<details>` disclosure: opens with Enter or Space. Related: [message-bubble](message-bubble.md), [thinking-indicator](thinking-indicator.md) --- # Toolbar A row of buttons and toggles with one tab stop and arrow-key movement, built on Radix. - Package: `@nexub/react` · Category: Actions · Status: stable - Import: `import { Toolbar } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/toolbar ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `floating` | `boolean` | | A glass capsule for the control layer above content, e.g. editor or selection actions. | | `placement` | `'bottom'` | | With `floating`: pin it to the bottom centre of the viewport. | | `orientation / loop / dir` | `Radix Toolbar props` | | Arrow-key direction and wrapping. | | `aria-label` | `string` | | Name the toolbar, e.g. "Text formatting". | | `Toolbar.Button` | `compound` | | An action button. | | `Toolbar.ToggleGroup / ToggleItem` | `compound` | | A set of toggles (`type="single" \| "multiple"`, `value`). Icon-only items need `aria-label`. | | `Toolbar.Separator` | `compound` | | A divider between groups. | ## Example: Default ```tsx import { Toolbar } from '@nexub/react'; export default function Example() { return ( <Toolbar.Root aria-label="Text formatting"> <Toolbar.ToggleGroup type="multiple" aria-label="Text style"> <Toolbar.ToggleItem value="bold" aria-label="Bold"><strong>B</strong></Toolbar.ToggleItem> <Toolbar.ToggleItem value="italic" aria-label="Italic"><em>I</em></Toolbar.ToggleItem> <Toolbar.ToggleItem value="underline" aria-label="Underline"><span className="underline">U</span></Toolbar.ToggleItem> </Toolbar.ToggleGroup> <Toolbar.Separator /> <Toolbar.ToggleGroup type="single" defaultValue="left" aria-label="Alignment"> <Toolbar.ToggleItem value="left" aria-label="Align left">L</Toolbar.ToggleItem> <Toolbar.ToggleItem value="center" aria-label="Align centre">C</Toolbar.ToggleItem> <Toolbar.ToggleItem value="right" aria-label="Align right">R</Toolbar.ToggleItem> </Toolbar.ToggleGroup> <Toolbar.Separator /> <Toolbar.Button>Clear formatting</Toolbar.Button> </Toolbar.Root> ); } ``` ## Example: Floating ```tsx import { Toolbar } from '@nexub/react'; import { Copy, Pencil, Trash2 } from '@nexub/icons'; export default function Example() { return ( <Toolbar.Root floating aria-label="Selection"> <Toolbar.Button><Pencil size="sm" aria-hidden="true" />Edit</Toolbar.Button> <Toolbar.Button><Copy size="sm" aria-hidden="true" />Duplicate</Toolbar.Button> <Toolbar.Separator /> <Toolbar.Button><Trash2 size="sm" aria-hidden="true" />Delete</Toolbar.Button> </Toolbar.Root> ); } ``` ## Accessibility - Roles: toolbar - `Tab`: Moves into and out of the toolbar (one tab stop). - `Arrow Left / Right`: Moves between controls. - `Enter / Space`: Activates a button or toggles an item. Related: [toggle-group](toggle-group.md), [button-group](button-group.md), [action-bar](action-bar.md) --- # Tooltip Floating label that appears on hover. Built on Radix UI Tooltip. - Package: `@nexub/react` · Category: Overlays · Status: stable - Import: `import { Tooltip } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/tooltip ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `content` (required) | `React.ReactNode` | | Content shown inside the tooltip. | | `side` | `'top' \| 'right' \| 'bottom' \| 'left'` | `'top'` | Preferred side to open. | | `delayDuration` | `number` | `700` | Delay in ms before tooltip opens. | ## Example: Default ```tsx import { TooltipProvider, Tooltip, Button } from '@nexub/react'; export default function Example() { return ( <TooltipProvider> <Tooltip label="This is a tooltip" side="top"> <Button variant="outlined">Hover me</Button> </Tooltip> </TooltipProvider> ); } ``` ## Example: Sides ```tsx import { TooltipProvider, Tooltip, Button } from '@nexub/react'; export default function Example() { return ( <TooltipProvider> <Tooltip label="This is a tooltip" side="top"> <Button variant="outlined">Hover me</Button> </Tooltip> </TooltipProvider> ); } ``` --- # Top Nav A sticky app header: logo, main navigation links and trailing actions. - Package: `@nexub/react` · Category: Navigation · Status: stable - Import: `import { TopNav } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/top-nav ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `surface` | `'solid' \| 'glass'` | | Glass material on the bar — see Foundations → Materials. | | `scrollEdge` | `'soft' \| 'hard'` | | `soft` dissolves scrolling content under the bar (no divider); `hard` is an opaque band. Default: a divider. | | `TopNav.Logo / Menu / Actions` | `compound` | | The logo slot, the `<nav>` of links (scrolls sideways on narrow screens) and the end-aligned actions. | | `TopNavItem active` | `boolean` | | Marks the current page (`aria-current="page"`). | | `TopNavItem asChild` | `boolean` | | Use your router `<Link>` instead of an `<a>`. | ## Example: Default ```tsx import { Avatar, IconButton, Logo, TopNav } from '@nexub/react'; import { Bell } from '@nexub/icons'; export default function Example() { return ( <TopNav.Root className="static w-full"> <TopNav.Logo><Logo size="sm" /></TopNav.Logo> <TopNav.Menu> <TopNav.Item href="#" active>Overview</TopNav.Item> <TopNav.Item href="#">Projects</TopNav.Item> <TopNav.Item href="#">Reports</TopNav.Item> </TopNav.Menu> <TopNav.Actions> <IconButton variant="ghost" label="Notifications"><Bell size="sm" /></IconButton> <Avatar size="sm" name="Jane Smith" /> </TopNav.Actions> </TopNav.Root> ); } ``` ## Accessibility - Roles: banner, navigation - `TopNav.Root` is a `<header>`; `TopNav.Menu` is a `<nav>` named with the localised "Main navigation". Related: [app-shell](app-shell.md), [sidebar](sidebar.md), [navigation-menu](navigation-menu.md), [logo](logo.md) --- # Tree View A keyboard-friendly hierarchy (ARIA tree) with lazy children and tri-state checkboxes. - Package: `@nexub/react` · Category: Navigation · Status: beta - Import: `import { TreeView } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/tree-view ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `nodes` (required) | `TreeNode[]` | | `{ id, label, textValue?, icon?, children?, hasChildren?, disabled?, trailing?, href? }`. `trailing` (11.5) is meta at the row end, e.g. a count or a date. `href` (11.5) makes the row a link: click and Enter follow it, Cmd/Ctrl-click and middle-click open a new tab. | | `aria-label / aria-labelledby` (required) | `string` | | Names the tree. | | `expanded / defaultExpanded / onExpandedChange` | `string[]` | | Open node ids. | | `selected / defaultSelected / onSelectedChange` | `string \| null` | | Single selection, set by click, Enter or Space. | | `onActivate` | `(node) => void` | | 11.5. Opens a node: Enter or double-click. Separate from selection, which click and Space set (Enter selects too). Disabled nodes never activate. | | `renderActions` | `(node) => ReactNode` | | 11.5. Row actions, shown on hover and focus and always on touch screens. Their space is always reserved, so rows never shift. Tab from the focused row reaches them; the item is named by its label and `trailing` only. | | `ref` | `Ref<TreeViewHandle>` | | 11.5. `scrollToNode(id, { focus? })` opens the node's ancestors, then scrolls its row into view (and focuses it). | | `checkable` | `boolean` | | Checkboxes instead of selection. A parent is checked when all its children are and mixed when some are. | | `checked / defaultChecked / onCheckedChange` | `string[]` | | Every checked id, parents included. | | `onLoadChildren` | `(node) => Promise` | | Called when a `hasChildren` node without `children` opens. Load them and pass the new `nodes`; the item is `aria-busy` meanwhile. | ## Example: Lazy loading and selection ```tsx 'use client'; import * as React from 'react'; import { TreeView, type TreeNode } from '@nexub/react'; export default function Example() { const [nodes, setNodes] = React.useState<TreeNode[]>([ { id: 'eng', label: 'Engineering', children: [ { id: 'web', label: 'Web', children: [{ id: 'ada', label: 'Ada Lovelace' }, { id: 'alan', label: 'Alan Turing' }] }, { id: 'mobile', label: 'Mobile', hasChildren: true }, ], }, { id: 'design', label: 'Design', children: [{ id: 'grace', label: 'Grace Hopper' }] }, ]); const [selected, setSelected] = React.useState<string | null>('ada'); // Pretend server call: fills Mobile's children the first time it opens. const load = async (node: TreeNode) => { await new Promise((r) => setTimeout(r, 700)); const fill = (list: TreeNode[]): TreeNode[] => list.map((n) => n.id === node.id ? { ...n, children: [{ id: 'linus', label: 'Linus Torvalds' }, { id: 'margaret', label: 'Margaret Hamilton' }] } : { ...n, children: n.children && fill(n.children) }, ); setNodes(fill); }; return ( <div className="flex w-full max-w-xs flex-col gap-2"> <TreeView aria-label="Teams" nodes={nodes} defaultExpanded={['eng', 'web']} selected={selected} onSelectedChange={setSelected} onLoadChildren={load} /> <p className="text-body-sm text-on-surface-muted">Selected: {selected ?? 'none'}</p> </div> ); } ``` ## Example: Checkboxes ```tsx 'use client'; import * as React from 'react'; import { TreeView, type TreeNode } from '@nexub/react'; const nodes: TreeNode[] = [ { id: 'reports', label: 'Reports', children: [ { id: 'revenue', label: 'Revenue' }, { id: 'churn', label: 'Churn' }, ], }, { id: 'settings', label: 'Settings', children: [{ id: 'billing', label: 'Billing' }, { id: 'members', label: 'Members' }] }, ]; export default function Example() { const [checked, setChecked] = React.useState<string[]>(['revenue']); return ( <div className="flex w-full max-w-xs flex-col gap-2"> <TreeView aria-label="Permissions" nodes={nodes} checkable defaultExpanded={['reports', 'settings']} checked={checked} onCheckedChange={setChecked} /> <p className="text-body-sm text-on-surface-muted">Granted: {checked.join(', ') || 'nothing'}</p> </div> ); } ``` ## Example: Actions, meta, links and scrollToNode ```tsx 'use client'; import * as React from 'react'; import { MoreHorizontal } from '@nexub/icons'; import { Button, IconButton, TreeView, type TreeNode, type TreeViewHandle } from '@nexub/react'; const folders: TreeNode[] = [ { id: 'inbox', label: 'Inbox', trailing: '12', children: [ { id: 'work', label: 'Work', trailing: '3', href: '#work' }, { id: 'projects', label: 'Projects', children: [ { id: 'atlas', label: 'Atlas', trailing: 'Mar 4', href: '#atlas' }, { id: 'orbit', label: 'Orbit', trailing: 'Feb 12', href: '#orbit' }, ], }, ], }, { id: 'sent', label: 'Sent', href: '#sent' }, { id: 'archive', label: 'Archive', trailing: '1,204', href: '#archive' }, ]; export default function Example() { const tree = React.useRef<TreeViewHandle>(null); const [opened, setOpened] = React.useState<string | null>(null); return ( <div className="flex w-full max-w-xs flex-col gap-2"> <TreeView ref={tree} aria-label="Folders" nodes={folders} defaultExpanded={['inbox']} onActivate={(node) => setOpened(String(node.label))} renderActions={(node) => ( <IconButton size="xs" variant="ghost" label={`More for ${String(node.label)}`}> <MoreHorizontal size="sm" /> </IconButton> )} /> <Button size="sm" variant="outlined" onClick={() => tree.current?.scrollToNode('orbit', { focus: true })}> Reveal Orbit </Button> <p className="text-body-sm text-on-surface-muted">Opened: {opened ?? 'none (press Enter or double-click)'}</p> </div> ); } ``` ## Accessibility - Roles: tree, treeitem with aria-level, aria-setsize, aria-posinset, aria-expanded, group - `ArrowDown / ArrowUp`: Next or previous visible item. - `ArrowRight`: Opens a closed item, or moves to its first child. Mirrored in RTL. - `ArrowLeft`: Closes an open item, or moves to its parent. Mirrored in RTL. - `Home / End`: First or last visible item. - `Enter`: Selects the item (or toggles its checkbox), calls `onActivate` and follows a link node. - `Space`: Selects the item, or toggles its checkbox. - `Tab`: From the focused item to its row actions (`renderActions`), then out of the tree. - `Type a letter`: Moves to the next item starting with the typed text. - The tree is one tab stop (roving tabindex); it returns to the last focused or the selected item. Related: [data-table](data-table.md), [sidebar](sidebar.md) --- # Truncate Text clipped to one or more lines, with the full text in a tooltip only while it is clipped. - Package: `@nexub/react` · Category: Typography · Status: alpha - Import: `import { Truncate } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/truncate ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `lines` | `number` | `1` | Lines shown before the text is clipped. | | `as` | `React.ElementType` | `'span'` | The element to render. | | `tooltip` | `boolean` | `true` | Show the full text in a tooltip while it is clipped. Needs string children. | ## Example: Default ```tsx import { Truncate } from '@nexub/react'; export default function Example() { return ( <div className="flex w-56 max-w-full flex-col gap-2 text-body-md"> <Truncate>Quarterly infrastructure invoice for the Singapore and Frankfurt regions</Truncate> <Truncate>Short text</Truncate> </div> ); } ``` ## Example: Several lines ```tsx import { Truncate } from '@nexub/react'; export default function Example() { return ( <Truncate lines={2} as="p" className="w-56 text-body-md"> Quarterly infrastructure invoice for the Singapore and Frankfurt regions, including premium support, data transfer and reserved capacity. </Truncate> ); } ``` ## Accessibility - Clipped text is a tab stop, so keyboard users can read the tooltip. Text that fits adds no tab stop and no tooltip. - The tooltip needs string children; other children are clipped only. Related: [text](text.md), [tooltip](tooltip.md) --- # Usage Bar A compact used-of-limit bar with its label inline, for table cells and fact grids. - Package: `@nexub/react` · Category: Data Display · Status: alpha - Import: `import { UsageBar } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/usage-bar ## When to use - A usage column in a table (seats per workspace, quota per key). - A row in a DescriptionList or fact grid. ## When not to use - The headline of a tile: use UsageTile. - A task moving toward done: use Progress. ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `used` (required) | `number` | | The amount used. | | `limit` (required) | `number \| null` | | The limit. `null` or `Infinity` shows the value and "Unlimited", no bar. | | `label` | `ReactNode \| false` | `"used / limit"` | The inline text beside the bar. `false` hides it. | | `aria-label` | `string` | | Names the meter, e.g. "Seats". Without it the meter is named by its value. | | `size` | `'sm' \| 'md'` | `'sm'` | Bar thickness and label size. | | `warnAt` | `number` | `0.8` | Share of the limit that turns the bar to the warning tone; at or over the limit it is the danger tone. | | `valueFormat` | `(value: number) => string` | `toLocaleString` | Formats the value and the limit. | ## Example: Levels ```tsx import { UsageBar } from '@nexub/react'; export default function Example() { return ( <div className="flex w-full max-w-xs flex-col gap-3"> <UsageBar aria-label="Seats" used={18} limit={50} /> <UsageBar aria-label="Seats" used={42} limit={50} /> <UsageBar aria-label="Seats" used={50} limit={50} /> <UsageBar aria-label="Projects" used={7} limit={null} /> </div> ); } ``` ## Example: In a table ```tsx import { Table, UsageBar } from '@nexub/react'; const workspaces = [ { name: 'Marketing', seats: 18, limit: 25 }, { name: 'Finance', seats: 9, limit: 10 }, { name: 'Support', seats: 30, limit: 30 }, ]; export default function Example() { return ( <Table.Root className="w-full max-w-120"> <Table.Header> <Table.Row> <Table.Head>Workspace</Table.Head> <Table.Head>Seats</Table.Head> </Table.Row> </Table.Header> <Table.Body> {workspaces.map((w) => ( <Table.Row key={w.name}> <Table.Cell>{w.name}</Table.Cell> <Table.Cell> <UsageBar aria-label={`${w.name} seats`} used={w.seats} limit={w.limit} /> </Table.Cell> </Table.Row> ))} </Table.Body> </Table.Root> ); } ``` ## Accessibility - Roles: A `meter` with `aria-valuenow` as the percentage and `aria-valuetext` such as "42 of 50, 84% used"; the inline label is hidden from assistive tech so it is not read twice. Related: [usage-tile](usage-tile.md), [progress](progress.md), [table](table.md) --- # Usage Tile Used of limit: the value, the limit and a bar that warns near and at the limit. - Package: `@nexub/react` · Category: Data Display · Status: alpha - Import: `import { UsageTile } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/usage-tile ## When to use - Plan limits on a billing or settings page: seats, storage, API calls. - A dashboard tile where the limit matters as much as the number. ## When not to use - A table cell or fact grid: use UsageBar. - A task moving toward done: use Progress. - A number with its change over time: use KpiTile or StatCard. ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `label` (required) | `ReactNode` | | What is being used, e.g. "Seats". Also names the meter. | | `used` (required) | `number \| null` | | The amount used. `null` or undefined shows the empty state. | | `limit` (required) | `number \| null` | | The limit. `null` or `Infinity` shows "Unlimited" and no bar. | | `warnAt` | `number` | `0.8` | Share of the limit that turns the bar to the warning tone. At or over the limit it is the danger tone. | | `valueFormat` | `(value: number) => string` | `toLocaleString` | Formats the value and the limit, e.g. `(n) => `${n} GB``. | | `note` | `ReactNode` | | An extra line under the bar, e.g. "Resets on 1 May". | | `action` | `ReactNode` | | A control beside the label, e.g. an Upgrade link. | | `loading / emptyState / errorState` | `boolean / ReactNode / ReactNode` | | The data states, same as KpiTile: a skeleton, the empty content, or the error content in place of the value. | ## Example: Under, near and at the limit ```tsx import { UsageTile } from '@nexub/react'; export default function Example() { return ( <div className="grid w-full max-w-3xl grid-cols-1 gap-4 sm:grid-cols-3"> <UsageTile label="Seats" used={12} limit={50} /> <UsageTile label="Storage" used={8.6} limit={10} valueFormat={(n) => `${n} GB`} /> <UsageTile label="API calls" used={100000} limit={100000} /> </div> ); } ``` ## Example: Unlimited, note and action ```tsx import { Button, UsageTile } from '@nexub/react'; export default function Example() { return ( <div className="grid w-full max-w-2xl grid-cols-1 gap-4 sm:grid-cols-2"> <UsageTile label="Projects" used={42} limit={null} note="Included in your plan" /> <UsageTile label="Seats" used={46} limit={50} note="Billed per seat each month" action={<Button size="sm" variant="text">Add seats</Button>} /> </div> ); } ``` ## Accessibility - Roles: The bar is a `meter` named by the label, with `aria-valuetext` such as "42 of 50, 84% used". - The level is written out ("80% used", "Limit reached"), so colour is never the only signal. Related: [usage-bar](usage-bar.md), [kpi-tile](kpi-tile.md), [progress](progress.md), [stat-card](stat-card.md) --- # Visually Hidden Content for screen readers only: hidden on screen but still read out (Radix). - Package: `@nexub/react` · Category: Inline Primitives · Status: stable - Import: `import { VisuallyHidden } from '@nexub/react';` - Docs: https://nexub-ds-docs.pages.dev/components/visually-hidden ## When to use - Extra context a sighted user gets from layout, e.g. "(opens in a new tab)" ## When not to use - Naming an icon button: `IconButton` takes a `label` - Hiding content from everyone: use `hidden` ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `children` | `ReactNode` | | The text to read out. | | `asChild` | `boolean` | | Hide your own element instead of a `<span>`. | ## Example: Label an icon ```tsx import { Link, VisuallyHidden } from '@nexub/react'; export default function Example() { return ( <Link href="https://example.com" target="_blank" rel="noreferrer"> Status page <VisuallyHidden> (opens in a new tab)</VisuallyHidden> </Link> ); } ``` Related: [icon-button](icon-button.md) --- # ActivityFeed Chronological list of activity events with avatar, description, and timestamp. - Package: `@nexub/patterns` · Category: Data · Status: stable - Import: `import { ActivityFeed } from '@nexub/patterns';` - Docs: https://nexub-ds-docs.pages.dev/patterns/activity-feed ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `ActivityFeedItem title` (required) | `React.ReactNode` | | Activity event title. Block content is fine (a `div` since 11.5). | | `ActivityFeedItem description` | `React.ReactNode` | | Supporting description. Block content is fine (a `div` since 11.5). | | `ActivityFeedItem timestamp` | `ReactNode \| Date` | | Text as given (e.g. "2 hours ago"), or (11.5) a `Date`: shown in `<time dateTime>` as relative text, a short date after a week, with the full date in a tooltip on hover or focus. | | `ActivityFeedItem actions` | `React.ReactNode` | | 11.5. Trailing controls, e.g. an IconButton or a menu trigger. | | `ActivityFeedItem tone` | `'neutral' \| 'info' \| 'success' \| 'warning' \| 'danger'` | | 11.5. A coloured dot in place of the avatar, or a badge on it. Decorative: say what happened in the title. | | `ActivityFeedGroup label` (required) | `React.ReactNode` | | 11.5. `ActivityFeed.Group` header, e.g. "Today"; it names the group’s list. | | `ActivityFeedGroup headingLevel` | `2 \| 3 \| 4 \| 5 \| 6` | | 11.5. Renders the header as a heading for heading navigation. Default: a plain `div`. | | `ActivityFeedItem avatar` | `React.ReactNode` | | Avatar element for the actor. | ## Example: Default ```tsx import { ActivityFeed } from '@nexub/patterns'; export default function Example() { return ( <div className="w-85"> <ActivityFeed.Root> <ActivityFeed.Item title="Sarah K. created an invoice" description="Invoice #1042 for Acme Corp" timestamp="2 min ago" /> <ActivityFeed.Item title="James L. approved a request" description="Budget increase for Q2" timestamp="15 min ago" /> <ActivityFeed.Item title="Maria R. added a comment" description="On the design review document" timestamp="1 hr ago" /> </ActivityFeed.Root> </div> ); } ``` ## Example: Groups, tones and actions `ActivityFeed.Group` headers, `Date` timestamps (focus one for the full date), `tone` dots and a menu per item. ```tsx import { ActivityFeed } from '@nexub/patterns'; import { IconButton } from '@nexub/react'; import { MoreHorizontal } from '@nexub/icons'; export default function Example() { const minutesAgo = (n: number) => new Date(Date.now() - n * 60_000); const more = ( <IconButton size="xs" label="More actions"> <MoreHorizontal className="size-4" aria-hidden="true" /> </IconButton> ); return ( <div className="w-full max-w-md"> <ActivityFeed.Root> <ActivityFeed.Group label="Today"> <ActivityFeed.Item tone="success" title="Deploy to production finished" timestamp={minutesAgo(5)} actions={more} /> <ActivityFeed.Item tone="danger" title="Contacts import failed" description="Row 12 is missing an email." timestamp={minutesAgo(42)} actions={more} /> </ActivityFeed.Group> <ActivityFeed.Group label="Yesterday"> <ActivityFeed.Item tone="info" title="Maria R. joined the workspace" timestamp={minutesAgo(26 * 60)} /> </ActivityFeed.Group> </ActivityFeed.Root> </div> ); } ``` --- # AuthCard Authentication layout pattern. Wraps sign-in, sign-up, and reset flows in a centered card. - Package: `@nexub/patterns` · Category: Auth · Status: stable - Import: `import { AuthCard } from '@nexub/patterns';` - Docs: https://nexub-ds-docs.pages.dev/patterns/auth-card ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `title` (required) | `string` | | Card heading (e.g. "Sign in to Nexub"). | | `description` | `ReactNode` | | Subheading text. 11.5: any content, e.g. the address in bold; was a string. | | `logo` | `React.ReactNode` | | Logo or brand mark above the title. | | `footer` | `React.ReactNode` | | Footer content (e.g. "Don't have an account?"). | | `children` (required) | `React.ReactNode` | | Form content. | | `logoAlign` | `'start' \| 'center'` | `'center'` | 11.5: where the logo sits. | ## Example: Sign in ```tsx import { AuthCard } from '@nexub/patterns'; import { Label, Input, Button } from '@nexub/react'; export default function Example() { return ( <div className="w-90"> <AuthCard title="Sign in" description="Welcome back — enter your credentials to continue."> <div className="flex flex-col gap-3 items-start"> <div className="flex flex-col gap-1 items-start"> <Label htmlFor="auth-email">Email</Label> <Input id="auth-email" type="email" placeholder="you@company.com" /> </div> <div className="flex flex-col gap-1 items-start"> <Label htmlFor="auth-pass">Password</Label> <Input id="auth-pass" type="password" placeholder="••••••••" /> </div> <Button variant="filled" className="w-full">Sign in</Button> </div> </AuthCard> </div> ); } ``` --- # Bento Grid A grid of card tiles in mixed sizes. Responds to its own width: 1 column, 2 at 480px, 4 at 768px. - Package: `@nexub/patterns` · Category: Layout · Status: beta - Import: `import { BentoGrid } from '@nexub/patterns';` - Docs: https://nexub-ds-docs.pages.dev/patterns/bento-grid ## When to use - Overview pages where a few items deserve more room than the rest. ## When not to use - Lists the user scans in order: dense packing can move tiles out of reading order. - Equal-weight items: use Grid. ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `BentoGrid children` (required) | `ReactNode` | | `BentoTile`s. Dense packing back-fills gaps left by large tiles, so visual order can differ from source order. | | `BentoTile size` | `'1x1' \| '2x1' \| '1x2' \| '2x2'` | `'1x1'` | Tile span, columns × rows. Two-wide spans apply from 2 columns up. | | `...Card props` | `CardProps` | | A tile is a surface Card (`variant` is fixed); `tone`, `surface` and `effect` pass through. | ## Example: Dashboard ```tsx import { BentoGrid, BentoTile } from '@nexub/patterns'; function BentoStat({ label, value }: { label: string; value: string }) { return ( <BentoTile className="flex flex-col justify-between"> <span className="text-label-md text-on-surface-variant">{label}</span> <span className="text-title-lg text-on-surface">{value}</span> </BentoTile> ); } export default function Example() { const bars = ['40%', '65%', '50%', '80%', '72%', '90%', '60%']; return ( <BentoGrid className="w-full"> <BentoTile size="2x2" className="flex flex-col gap-3"> <h3 className="text-title-sm text-on-surface">Revenue, last 7 days</h3> <div role="img" aria-label={`Bar chart: ${bars.join(', ')}`} className="flex flex-1 items-end gap-2"> {bars.map((h, i) => ( <div key={i} className="flex-1 rounded-shape-min bg-primary-container" style={{ height: h }} /> ))} </div> </BentoTile> <BentoStat label="Active users" value="12,480" /> <BentoStat label="Conversion" value="3.2%" /> <BentoTile size="2x1" className="flex items-center text-body-md text-on-surface-variant"> 3 invoices awaiting approval. </BentoTile> <BentoStat label="Churn" value="0.8%" /> <BentoStat label="NPS" value="61" /> </BentoGrid> ); } ``` Related: [card](card.md), [stat-card](stat-card.md) --- # Conversation Chat layout: a scrolling message list that follows new content, with a sticky composer underneath. - Package: `@nexub/patterns` · Category: AI · Status: beta - Import: `import { Conversation } from '@nexub/patterns';` - Docs: https://nexub-ds-docs.pages.dev/patterns/conversation ## When to use - A full chat or assistant view: messages above, composer below. ## When not to use - A single question and answer: a PromptInput and a MessageBubble in normal flow are enough. - Comment threads that don’t follow new content: use ActivityFeed. ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `children` | `ReactNode` | | The messages, usually MessageBubbles. | | `composer` | `ReactNode` | | Sticky slot under the list, usually a PromptInput. | | `autoScroll` | `boolean` | `true` | Follow new content while the reader is at the bottom. Scrolling up stops following and shows "Jump to latest". | | `announce` | `boolean` | `false` | Make the list a polite `role="log"`. Only for whole-message updates: with token streaming it announces every chunk. | | `maxHeight` | `number \| string` | | 11.5: cap the height so it works in normal flow without a fixed-height parent. It grows with its messages up to this, then the list scrolls and follows. Without it, it fills its parent (`h-full`). | | `messages` | `Partial<ConversationMessages>` | | Overrides for `jumpToLatest` and `conversation`. | ## Example: Mini chat Send a message: it shows Thinking, then streams a cited reply. Stop or Escape ends the reply early. ```tsx import * as React from 'react'; import { type PromptInputStatus, PromptInput, MessageBubble, ThinkingIndicator, StreamingText, Citation, type CitationSource } from '@nexub/react'; import { Conversation } from '@nexub/patterns'; const CITATION_SOURCES: CitationSource[] = [ { title: 'Choosing a heat pump', url: 'https://example.com/guides/heat-pumps', snippet: 'Air-source pumps suit most homes with a garden or outside wall.' }, { title: 'Grants for home heating', url: 'https://example.org/grants', domain: 'example.org' }, { title: 'Running costs compared', url: 'https://example.net/costs' }, ]; type ChatMessage = { id: number; from: 'user' | 'assistant'; text: string }; const CHAT_REPLY = 'Air-source heat pumps work in most homes and run at roughly the cost of gas.'; const CHAT_SOURCE = CITATION_SOURCES[0]!; export default function Example() { const [messages, setMessages] = React.useState<ChatMessage[]>([]); const [status, setStatus] = React.useState<PromptInputStatus>('idle'); const timer = React.useRef<ReturnType<typeof setTimeout>>(undefined); React.useEffect(() => () => clearTimeout(timer.current), []); function send(text: string) { const id = Date.now(); setMessages((m) => [...m, { id, from: 'user', text }, { id: id + 1, from: 'assistant', text: '' }]); setStatus('submitting'); timer.current = setTimeout(() => { setStatus('streaming'); stream(id + 1, 0); }, 800); } function stream(id: number, length: number) { setMessages((m) => m.map((msg) => (msg.id === id ? { ...msg, text: CHAT_REPLY.slice(0, length) } : msg))); if (length >= CHAT_REPLY.length) return setStatus('idle'); timer.current = setTimeout(() => stream(id, length + 4), 50); } function stop() { clearTimeout(timer.current); setStatus('idle'); } const last = messages[messages.length - 1]; return ( <Conversation className="h-105 w-full" composer={<PromptInput placeholder="Ask about heat pumps" status={status} onSubmit={send} onStop={stop} />} > {messages.map((msg) => msg.from === 'user' ? ( <MessageBubble key={msg.id} from="user">{msg.text}</MessageBubble> ) : ( <MessageBubble key={msg.id} from="assistant"> {status === 'submitting' && msg === last ? ( <ThinkingIndicator /> ) : ( <> <StreamingText as="span" text={msg.text} streaming={status === 'streaming' && msg === last} /> {msg.text === CHAT_REPLY && <Citation index={1} source={CHAT_SOURCE} />} </> )} </MessageBubble> ), )} </Conversation> ); } ``` ## Example: In normal flow No fixed-height parent: `maxHeight="20rem"` lets it grow with its messages, then scroll. ```tsx import * as React from 'react'; import { PromptInput, MessageBubble } from '@nexub/react'; import { Conversation } from '@nexub/patterns'; type ChatMessage = { id: number; from: 'user' | 'other'; text: string }; export default function Example() { const [messages, setMessages] = React.useState<ChatMessage[]>([ { id: 1, from: 'other', text: 'Morning! Did the invoices go out?' }, ]); return ( <div className="w-full"> <Conversation maxHeight="20rem" composer={ <PromptInput placeholder="Reply to Grace" onSubmit={(text) => setMessages((m) => [...m, { id: Date.now(), from: 'user', text }])} /> } > {messages.map((msg) => msg.from === 'other' ? ( <MessageBubble key={msg.id} from="other" name="Grace Hopper"> {msg.text} </MessageBubble> ) : ( <MessageBubble key={msg.id} from="user"> {msg.text} </MessageBubble> ), )} </Conversation> </div> ); } ``` ## Accessibility - Roles: region (default) or log (with `announce`) - `Tab`: The message list is focusable so keyboard users can scroll it. - Keep focus in the composer while a reply streams; don’t move it to the new message. - The list is named "Conversation". Leave `announce` off while streaming tokens and announce the finished reply once instead. - With reduced motion, "Jump to latest" scrolls instantly. Related: [message-bubble](message-bubble.md), [prompt-input](prompt-input.md), [streaming-text](streaming-text.md) --- # CTABand The closing call to action on a primary band: the hero gradient in marketing mode. Server component. - Package: `@nexub/marketing` · Category: Marketing · Status: beta - Import: `import { CtaBand } from '@nexub/marketing';` - Docs: https://nexub-ds-docs.pages.dev/patterns/cta-band ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `title` (required) | `React.ReactNode` | | The heading (h2). | | `description` | `React.ReactNode` | | One supporting line. | | `actions` | `React.ReactNode` | | Buttons. On the band use `variant="filled" tone="neutral"` or an outlined button. | | `division` | `DivisionKey` | | Sets `data-division` on the section: the band takes the division fill. Load `@nexub/themes/divisions`. | ## Example: Default ```tsx import { Button } from '@nexub/react'; import { CTABand } from '@nexub/marketing'; export default function Example() { return ( <div data-mode="marketing" className="w-full"> <CTABand title="Start running your company on Nexub" description="Free for 30 days. No card needed." actions={<Button variant="filled" tone="neutral" size="lg">Create an account</Button>} /> </div> ); } ``` ## Example: Divisions With `division` the band takes the division fill and a SectionHeader eyebrow the division colour. Load `@nexub/themes/divisions`. ```tsx import { Button } from '@nexub/react'; import { CTABand, SectionHeader } from '@nexub/marketing'; const divisions = [ ['os', 'Nexub OS'], ['commerce', 'Nexub Commerce'], ['fintech', 'Nexub Fintech'], ['intelligence', 'Nexub Intelligence'], ['autonomous', 'Nexub Autonomous'], ] as const; // Needs @nexub/themes/divisions. Each division page sets `division` on its sections. export default function Example() { return ( <div data-mode="marketing" className="w-full"> {divisions.map(([key, name]) => ( <div key={key} className="pt-10"> <SectionHeader division={key} eyebrow={name} title={`Start with ${name}`} level={3} /> <CTABand division={key} title={`Try ${name} free for 30 days`} actions={<Button variant="filled" tone="neutral" size="lg">Create an account</Button>} /> </div> ))} </div> ); } ``` --- # Error Summary Lists a form’s errors after a failed submit, with a link to each field. useFormErrors wires the fields to their messages. - Package: `@nexub/patterns` · Category: Forms · Status: beta - Import: `import { ErrorSummary } from '@nexub/patterns';` - Docs: https://nexub-ds-docs.pages.dev/patterns/error-summary ## When to use - Forms validated on submit, especially long ones where some errors are off screen. - Alongside inline messages, never instead of them. ## When not to use - Live validation while typing: pass a new array per submit, not per keystroke, or the summary steals focus. - A single field: the inline message is enough. ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `errors` (required) | `{ id: string; message: string }[]` | | One entry per invalid field; `id` is the field’s DOM id. Renders nothing when empty. | | `title` | `ReactNode` | `'There is a problem'` | Heading; it also labels the summary. | | `onFocusField` | `(id: string) => void` | | Called after a link moves focus to its field. | | `useFormErrors(map)` (required) | `Record<string, string \| null \| undefined \| false>` | | Takes `{ fieldId: message }`. Falsy messages are skipped. | | `→ errors` | `ErrorSummaryItem[]` | | The list for `ErrorSummary`. Stable for the same map object. | | `→ fieldProps(id)` | `function` | | Spread on the input: `id`, plus `aria-invalid` and `aria-describedby="${id}-error"` when it has an error. | | `→ errorProps(id)` | `function` | | Spread on the inline message: `id="${id}-error"`, the same id FormField.Error uses. | ## Example: Validate on submit Submit empty to see the summary. A new map per submit moves focus to the summary; links jump to each field. ```tsx import * as React from 'react'; import { type FormErrorMap, useFormErrors, ErrorSummary } from '@nexub/patterns'; import { Label, Input, FormError, Button } from '@nexub/react'; export default function Example() { const [submitted, setSubmitted] = React.useState<FormErrorMap>({}); const { errors, fieldProps, errorProps } = useFormErrors(submitted); const submit = (e: React.FormEvent<HTMLFormElement>) => { e.preventDefault(); const data = new FormData(e.currentTarget); setSubmitted({ 'es-name': String(data.get('name')).trim() ? undefined : 'Enter your name', 'es-email': /^[^\s@]+@[^\s@.]+(?:\.[^\s@.]+)+$/.test(String(data.get('email'))) ? undefined : 'Enter an email address, like name@example.com', }); }; return ( <form noValidate onSubmit={submit} className="flex flex-col gap-3 items-stretch w-85"> <ErrorSummary errors={errors} /> <div className="flex flex-col gap-1 items-stretch"> <Label htmlFor="es-name">Name</Label> <Input name="name" {...fieldProps('es-name')} invalid={Boolean(submitted['es-name'])} /> {submitted['es-name'] && <FormError {...errorProps('es-name')}>{submitted['es-name']}</FormError>} </div> <div className="flex flex-col gap-1 items-stretch"> <Label htmlFor="es-email">Email</Label> <Input name="email" type="email" {...fieldProps('es-email')} invalid={Boolean(submitted['es-email'])} /> {submitted['es-email'] && <FormError {...errorProps('es-email')}>{submitted['es-email']}</FormError>} </div> <Button type="submit">Create account</Button> </form> ); } ``` ## Accessibility - Roles: alert - Takes focus whenever it receives a new, non-empty `errors` array, so screen readers read it and keyboard users start from it. - Each link scrolls its field into view and focuses it. - An `alert` labelled by its heading. Fields get `aria-invalid` and `aria-describedby` pointing at their inline message. Related: [form-field](form-field.md), [input](input.md), [alert](alert.md) --- # FAQ Questions and answers in an Accordion, one open at a time. Client component. - Package: `@nexub/marketing` · Category: Marketing · Status: beta - Import: `import { Faq } from '@nexub/marketing';` - Docs: https://nexub-ds-docs.pages.dev/patterns/faq ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `items` (required) | `{ question, answer }[]` | | The questions; answers can hold links. | | `header` | `React.ReactNode` | | A SectionHeader, usually. | ## Example: Default ```tsx import { FAQ, SectionHeader } from '@nexub/marketing'; export default function Example() { return ( <div data-mode="marketing" className="w-full"> <FAQ header={<SectionHeader title="Questions" />} items={[ { question: 'Which countries do you support?', answer: 'Singapore, India, Indonesia, Malaysia and Vietnam.' }, { question: 'Can I switch plans later?', answer: 'Yes, at any time. We prorate the difference.' }, { question: 'Is my data secure?', answer: 'Data is encrypted at rest and in transit, and stored in the region you choose.' }, ]} /> </div> ); } ``` --- # FeatureSplit Text and a check list beside a visual; `reverse` swaps the sides on wide screens. Server component. - Package: `@nexub/marketing` · Category: Marketing · Status: beta - Import: `import { FeatureSplit } from '@nexub/marketing';` - Docs: https://nexub-ds-docs.pages.dev/patterns/feature-split ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `title` (required) | `React.ReactNode` | | The heading (h2). | | `visual` (required) | `React.ReactNode` | | Screenshot or illustration. | | `eyebrow` | `React.ReactNode` | | A string becomes a gradient EyebrowChip. | | `description` | `React.ReactNode` | | Body copy. | | `points` | `string[]` | | Benefit lines, shown as a check list. | | `actions` | `React.ReactNode` | | Buttons. | | `reverse` | `boolean` | `false` | Visual on the left on wide screens. | ## Example: Default ```tsx import { Card } from '@nexub/react'; import { FeatureSplit } from '@nexub/marketing'; export default function Example() { return ( <div data-mode="marketing" className="w-full"> <FeatureSplit eyebrow="Payroll" title="Pay your team on time, every time" description="Run payroll in minutes with tax and statutory filings handled for you." points={['CPF, EPF and BPJS filed for you', 'Payslips in every employee’s language', 'Approvals on your phone']} visual={<Card variant="showcase" accent="payub" className="aspect-[4/3] w-full" role="img" aria-label="Payroll screenshot" />} /> </div> ); } ``` --- # FilterBar Search + filter toolbar pattern for data-heavy list or table views. - Package: `@nexub/patterns` · Category: Data · Status: stable - Import: `import { FilterBar } from '@nexub/patterns';` - Docs: https://nexub-ds-docs.pages.dev/patterns/filter-bar ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `search` | `boolean` | `true` | 11.3: `false` leaves the search field out, for a bar of filters and actions only. | | `searchPlaceholder` | `string` | `'Search…'` | Placeholder text for the search input. | | `searchValue` | `string` | | Controlled search value. | | `onSearch` | `(value: string) => void` | | Callback when search value changes. | | `searchLabel` | `string` | `'Search'` | Accessible name of the search field (5.1). Defaults to the localised `search` message. | | `filters` | `React.ReactNode` | | Filter controls rendered to the right of search. | | `activeCount` | `number` | `0` | Applied filters; above 0 shows "N filters" (5.5). `countFilters(group)` counts a FilterBuilder query. | | `onClearAll` | `() => void` | | Shows a Clear all button next to the count (5.5). | | `actions` | `React.ReactNode` | | Action buttons (e.g. "Export") rendered on the far right. | ## Example: Default ```tsx import { FilterBar } from '@nexub/patterns'; import { Badge } from '@nexub/react'; export default function Example() { return ( <div className="w-full max-w-120"> <FilterBar searchPlaceholder="Search users…" filters={ <div className="flex gap-2 flex-wrap items-center justify-center"> <Badge tone="neutral">Status: All</Badge> <Badge tone="neutral">Plan: All</Badge> </div> } /> </div> ); } ``` ## Example: Without search `search={false}`. ```tsx import { FilterBar } from '@nexub/patterns'; import { Badge, Button } from '@nexub/react'; export default function Example() { return ( <div className="w-full max-w-120"> <FilterBar search={false} filters={<Badge tone="neutral">Status: Open</Badge>} actions={<Button variant="outlined" size="sm">Export</Button>} /> </div> ); } ``` --- # Hero The page hero: ambient backdrop, eyebrow, display headline (the page's one h1), lead, actions and a visual. Server component. - Package: `@nexub/marketing` · Category: Marketing · Status: beta - Import: `import { Hero } from '@nexub/marketing';` - Docs: https://nexub-ds-docs.pages.dev/patterns/hero ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `title` (required) | `React.ReactNode` | | The headline, rendered as the h1. | | `eyebrow` | `React.ReactNode` | | A string becomes a gradient EyebrowChip. | | `description` | `React.ReactNode` | | The lead paragraph. | | `actions` | `React.ReactNode` | | One `Button variant="hero"` and one outlined button, usually. | | `visual` | `React.ReactNode` | | Product shot or illustration. Beside the text on wide screens with `align="start"`. | | `align` | `'center' \| 'start'` | `'center'` | Text alignment and layout. | | `division` | `DivisionKey` | | Sets `data-division` on the section: a string eyebrow takes the division colour. Load `@nexub/themes/divisions`. | ## Example: Default ```tsx import { Button } from '@nexub/react'; import { Hero } from '@nexub/marketing'; import { ArrowRight } from '@nexub/icons'; export default function Example() { return ( <div data-mode="marketing" className="w-full"> <Hero eyebrow="Now in Vietnam" title="Run your whole company in one place" description="Payroll, bookkeeping and compliance for growing teams across Southeast Asia and India." actions={ <> <Button variant="hero" size="lg" trailingIcon={<ArrowRight size={16} />}>Start free</Button> <Button variant="outlined" size="lg">Book a demo</Button> </> } /> </div> ); } ``` --- # HowItWorks Numbered steps in an ordered list. Server component. - Package: `@nexub/marketing` · Category: Marketing · Status: beta - Import: `import { HowItWorks } from '@nexub/marketing';` - Docs: https://nexub-ds-docs.pages.dev/patterns/how-it-works ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `steps` (required) | `{ title, description, icon? }[]` | | The steps; the number shows unless an icon is given. | | `header` | `React.ReactNode` | | A SectionHeader, usually. | ## Example: Default ```tsx import { HowItWorks, SectionHeader } from '@nexub/marketing'; export default function Example() { return ( <div data-mode="marketing" className="w-full"> <HowItWorks header={<SectionHeader title="Up and running in a day" />} steps={[ { title: 'Create your account', description: 'Sign up with your company details.' }, { title: 'Invite your team', description: 'Add people and their bank details.' }, { title: 'Run your first payroll', description: 'Review, approve and pay.' }, ]} /> </div> ); } ``` --- # InfoList Key–value list for displaying structured metadata or details. - Package: `@nexub/patterns` · Category: Data · Status: stable - Import: `import { InfoList } from '@nexub/patterns';` - Docs: https://nexub-ds-docs.pages.dev/patterns/info-list ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `InfoListItem label` (required) | `string` | | The key label. | | `value` (required) | `React.ReactNode` | | The displayed value. | ## Example: Default ```tsx import { InfoList } from '@nexub/patterns'; import { Badge } from '@nexub/react'; export default function Example() { return ( <div className="w-70"> <InfoList.Root> <InfoList.Item label="Plan" value="Pro" /> <InfoList.Item label="Seats" value="12 / 50" /> <InfoList.Item label="Renewal" value="Jan 15, 2026" /> <InfoList.Item label="Status" value={<Badge tone="success" size="sm">Active</Badge>} /> </InfoList.Root> </div> ); } ``` --- # List Detail The list-detail layout: side by side at 720px+ of its own width (a container query), one pane at a time below. - Package: `@nexub/patterns` · Category: Layout · Status: beta - Import: `import { ListDetail } from '@nexub/patterns';` - Docs: https://nexub-ds-docs.pages.dev/patterns/list-detail ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `list / detail` (required) | `ReactNode` | | The two panes. | | `showDetail` | `boolean` | `false` | When narrow, show the detail instead of the list (set it on selection). | | `onBack` | `() => void` | | Back button, shown only when narrow. | | `listWidth` | `'sm' \| 'md' \| 'lg'` | `'md'` | Fixed list width when both panes show (288 / 320 / 400px). | ## Example: Default ```tsx import * as React from 'react'; import { Button } from '@nexub/react'; import { ListDetail } from '@nexub/patterns'; export default function Example() { const [selected, setSelected] = React.useState<number | null>(0); const items = ['Quarterly report', 'Design review', 'Invoice #4821']; return ( <div className="w-full h-60 border border-outline-variant rounded-shape-container overflow-hidden"> <ListDetail showDetail={selected !== null} onBack={() => setSelected(null)} list={ <ul className="p-2 m-0 list-none"> {items.map((m, i) => ( <li key={m}> <Button variant={selected === i ? 'tonal' : 'text'} onClick={() => setSelected(i)} className="w-full justify-start"> {m} </Button> </li> ))} </ul> } detail={<div className="text-title-md p-5">{selected === null ? 'Nothing selected' : items[selected]}</div>} /> </div> ); } ``` --- # LogoStrip A row of customer logos under the hero, scrolling sideways (paused on hover and focus) or wrapped. Server component. - Package: `@nexub/marketing` · Category: Marketing · Status: beta - Import: `import { LogoStrip } from '@nexub/marketing';` - Docs: https://nexub-ds-docs.pages.dev/patterns/logo-strip ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `label` | `React.ReactNode` | | e.g. "Trusted by 2,000+ teams". | | `scroll` | `boolean` | `true` | Scroll the logos (marketing mode only); off gives a wrapped row. | | `children` (required) | `React.ReactNode` | | The logos. Give each its alt text. | ## Example: Default ```tsx import { LogoStrip } from '@nexub/marketing'; const customers = ['Acme', 'Globex', 'Initech', 'Umbrella', 'Hooli', 'Vandelay']; export default function Example() { return ( <div data-mode="marketing" className="w-full"> <LogoStrip label="Trusted by 2,000+ teams"> {customers.map((name) => ( <span key={name} className="text-title-lg text-on-surface-muted">{name}</span> ))} </LogoStrip> </div> ); } ``` --- # MarketingFooter The site footer: a tools strip, the logo, link columns and the legal line. Server component. - Package: `@nexub/marketing` · Category: Marketing · Status: beta - Import: `import { MarketingFooter } from '@nexub/marketing';` - Docs: https://nexub-ds-docs.pages.dev/patterns/marketing-footer ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `columns` (required) | `{ title, links: { label, href }[] }[]` | | Link columns, each a labelled nav. | | `logo` | `React.ReactNode` | | Logo. | | `tagline` | `React.ReactNode` | | A line under the logo. | | `tools` | `React.ReactNode[]` | | Tools or integrations, scrolling in a strip. | | `toolsLabel` | `string` | `'Works with'` | Label of the tools strip. | | `bottom` | `React.ReactNode` | | Copyright and legal links. | ## Example: Default ```tsx import { Logo } from '@nexub/react'; import { MarketingFooter } from '@nexub/marketing'; export default function Example() { return ( <div data-mode="marketing" className="w-full"> <MarketingFooter logo={<Logo size="sm" />} tagline="The operating system for growing companies." tools={['Slack', 'Xero', 'Google Workspace', 'Stripe', 'QuickBooks', 'WhatsApp']} columns={[ { title: 'Products', links: [{ label: 'Payub', href: '#payub' }, { label: 'Bookub', href: '#bookub' }, { label: 'Leap', href: '#leap' }] }, { title: 'Company', links: [{ label: 'About', href: '#about' }, { label: 'Careers', href: '#careers' }] }, { title: 'Resources', links: [{ label: 'Help centre', href: '#help' }, { label: 'Status', href: '#status' }] }, ]} bottom="© 2026 Nexub Pte. Ltd., Singapore" /> </div> ); } ``` --- # MarketingNav The site header: logo, links with mega-menus, a country switcher and actions. Below `lg` the links move into a side sheet. - Package: `@nexub/marketing` · Category: Marketing · Status: beta - Import: `import { MarketingNav } from '@nexub/marketing';` - Docs: https://nexub-ds-docs.pages.dev/patterns/marketing-nav ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `logo` (required) | `React.ReactNode` | | Logo, wrapped in a link to `logoHref`. | | `items` (required) | `MarketingNavItem[]` | | Links; an item with `items` opens a mega-menu of links with descriptions; one with `columns` (`MarketingNavColumn[]`: `title`, `href`, `description`, `accent`, `links`) opens a grouped mega-menu, with optional `footer` links and a `feature` card. A link's `badge` shows after its label and is part of its accessible name. | | `countries` | `MarketingCountry[]` | | Country sites: `{ code, label, href }`. The switcher shows when there are two or more. | | `country` | `string` | | Current country code. | | `actions` | `React.ReactNode` | | Sign in / Get started buttons. | | `logoHref` | `string` | `'/'` | Where the logo links. | | `menuLabel` | `string` | `'Open menu'` | Accessible name of the mobile menu button. | ## Example: Default ```tsx import { Button, Logo } from '@nexub/react'; import { MarketingNav } from '@nexub/marketing'; export default function Example() { return ( <div data-mode="marketing" className="w-full"> <MarketingNav logo={<Logo size="sm" />} items={[ { label: 'Products', items: [ { label: 'Payub', href: '#payub', description: 'Payroll and HR' }, { label: 'Bookub', href: '#bookub', description: 'Bookkeeping' }, { label: 'Leap', href: '#leap', description: 'Company formation' }, { label: 'Founderub', href: '#founderub', description: 'Founder tools' }, ], }, { label: 'Pricing', href: '#pricing' }, { label: 'Customers', href: '#customers' }, ]} countries={[ { code: 'SG', label: 'Singapore', href: '#sg' }, { code: 'IN', label: 'India', href: '#in' }, { code: 'ID', label: 'Indonesia', href: '#id' }, { code: 'MY', label: 'Malaysia', href: '#my' }, { code: 'VN', label: 'Vietnam', href: '#vn' }, ]} country="SG" actions={ <> <Button variant="text" size="sm" asChild><a href="#signin">Sign in</a></Button> <Button variant="filled" size="sm" asChild><a href="#start">Get started</a></Button> </> } /> </div> ); } ``` ## Example: Grouped mega-menu An item with `columns` opens a panel as wide as the container: up to 5 columns (3 + 2 below `xl`), each a labelled list whose title can link to the division page, with an optional `footer` strip and `feature` card. In the side sheet each column is an accordion section. `accent` tints a heading with the division colour (load `@nexub/themes/divisions`). ```tsx import { Button, Card, CardLink, Logo } from '@nexub/react'; import { MarketingNav, type MarketingNavItem } from '@nexub/marketing'; // The nexub.com header: Products (the five divisions), Solutions and Resources. export const items: MarketingNavItem[] = [ { label: 'Products', columns: [ { title: 'Nexub OS', href: '#os', accent: 'os', links: [ { label: 'Leap', href: '#leap' }, { label: 'People', href: '#people' }, { label: 'PayHub', href: '#payhub' }, { label: 'Contracts', href: '#contracts' }, { label: 'Book Hub', href: '#book-hub' }, { label: 'Forms', href: '#forms', badge: 'Early access' }, { label: 'Founder Hub', href: '#founder-hub' }, ], }, { title: 'Nexub Commerce', href: '#commerce', accent: 'commerce', links: [{ label: 'Commerce', href: '#commerce-app', badge: 'Coming to Indonesia' }], }, { title: 'Nexub Fintech', href: '#fintech', accent: 'fintech', links: [ { label: 'Money', href: '#money', badge: 'Coming soon' }, { label: 'Capital', href: '#capital', badge: 'Coming soon' }, ], }, { title: 'Nexub Intelligence', href: '#intelligence', accent: 'intelligence', links: [ { label: 'Mind', href: '#mind' }, { label: 'Go', href: '#go' }, { label: 'Bring your own AI key', href: '#byok' }, ], }, { title: 'Nexub Autonomous', href: '#autonomous', accent: 'autonomous', links: [ { label: 'Command Hub', href: '#command-hub' }, { label: 'Runner', href: '#runner' }, { label: 'Robotics & logistics', href: '#robotics', badge: 'In research' }, ], }, ], footer: [ { label: 'All products', href: '#products' }, { label: 'Nexub Account', href: '#account' }, { label: 'Integrations', href: '#integrations' }, ], }, { label: 'Solutions', columns: [ { title: 'By stage', links: [ { label: 'Starting up', href: '#starting-up', description: 'Incorporate and open for business' }, { label: 'Growing', href: '#growing', description: 'Hire, pay and stay compliant' }, { label: 'Scaling', href: '#scaling', description: 'Many entities, one view' }, ], }, { title: 'By industry', links: [ { label: 'Retail and e-commerce', href: '#retail' }, { label: 'Professional services', href: '#services' }, { label: 'Food and beverage', href: '#fnb' }, { label: 'Logistics', href: '#logistics' }, ], }, { title: 'By need', links: [ { label: 'Payroll', href: '#payroll' }, { label: 'Bookkeeping', href: '#bookkeeping' }, { label: 'Company secretary', href: '#cosec' }, { label: 'Fundraising', href: '#fundraising' }, ], }, ], feature: ( <Card variant="surface" className="flex h-full flex-col gap-2 p-5"> <p className="m-0 text-label-md text-on-surface-muted">Customer story</p> <p className="m-0 text-title-md text-on-surface"> <CardLink href="#story">How a 40-person studio closes its books in two days</CardLink> </p> </Card> ), }, { label: 'Resources', columns: [ { title: 'Learn', links: [ { label: 'Guides', href: '#guides' }, { label: 'Blog', href: '#blog' }, { label: 'Webinars', href: '#webinars' }, ], }, { title: 'Tools', links: [ { label: 'Payroll calculator', href: '#calculator' }, { label: 'Company name check', href: '#name-check' }, { label: 'Templates', href: '#templates' }, ], }, { title: 'Help', links: [ { label: 'Help centre', href: '#help' }, { label: 'Contact sales', href: '#sales' }, { label: 'System status', href: '#status' }, ], }, ], }, { label: 'Pricing', href: '#pricing' }, ]; export default function Example() { // Room for the open panel: the docs preview clips what overflows it. return ( <div data-mode="marketing" className="min-h-[34rem] w-full"> <MarketingNav logo={<Logo size="sm" />} items={items} countries={[ { code: 'SG', label: 'Singapore', href: '#sg' }, { code: 'MY', label: 'Malaysia', href: '#my' }, { code: 'IN', label: 'India', href: '#in' }, { code: 'ID', label: 'Indonesia', href: '#id' }, { code: 'VN', label: 'Vietnam', href: '#vn' }, ]} country="SG" actions={ <> <Button variant="text" size="sm" asChild><a href="#signin">Sign in</a></Button> <Button variant="filled" size="sm" asChild><a href="#start">Get started</a></Button> </> } /> </div> ); } ``` --- # NotificationCenter A bell with an unread count that opens the notification list. - Package: `@nexub/patterns` · Category: Feedback · Status: beta - Import: `import { NotificationCenter } from '@nexub/patterns';` - Docs: https://nexub-ds-docs.pages.dev/patterns/notification-center ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `notifications` (required) | `{ id, title, description?, timestamp?, read?, icon?, href? }[]` | | Newest first. Your app owns them and their read state. | | `onOpen` | `(id) => void` | | A notification was opened; mark it read here. | | `onDismiss` | `(id) => void` | | Shows a dismiss button per item. | | `onMarkAllRead` | `() => void` | | Shows "Mark all as read" while some are unread. | | `emptyText` | `ReactNode` | `"You’re all caught up"` | Shown with no notifications. | ## Example: Inbox ```tsx 'use client'; import * as React from 'react'; import { NotificationCenter, type NotificationCenterItem } from '@nexub/patterns'; export default function Example() { const [items, setItems] = React.useState<NotificationCenterItem[]>([ { id: '1', title: 'Deploy failed on main', description: 'Build step "test" exited with 1.', timestamp: '2 min ago' }, { id: '2', title: 'Invoice #1042 paid', timestamp: '1 h ago' }, { id: '3', title: 'Ada commented on Q4 plan', timestamp: 'Yesterday', read: true }, ]); const markRead = (id?: string) => setItems((list) => list.map((n) => (!id || n.id === id ? { ...n, read: true } : n))); return ( <NotificationCenter notifications={items} onOpen={(id) => markRead(id)} onDismiss={(id) => setItems((list) => list.filter((n) => n.id !== id))} onMarkAllRead={() => markRead()} /> ); } ``` ## Accessibility - The bell reads "Notifications, 3 unread"; the count badge is decorative. - The list opens in a popover labelled by its heading; Escape closes it and focus returns to the bell. - Each item’s title is its link or button, stretched over the whole item. Related: [notification-item](notification-item.md) --- # NotificationItem Single notification row for notification panels or dropdowns. - Package: `@nexub/patterns` · Category: Feedback · Status: stable - Import: `import { NotificationItem } from '@nexub/patterns';` - Docs: https://nexub-ds-docs.pages.dev/patterns/notification-item ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `title` (required) | `string` | | Notification title. | | `description` | `string` | | Supporting text. | | `timestamp` | `string` | | Relative time string. | | `read` | `boolean` | `false` | Unread items get a tinted background and an "Unread" dot. | | `icon` | `ReactNode` | | Icon or avatar before the text. | | `href / onSelect` | `string / () => void` | | Makes the whole item a link or a button (6.6). | | `onDismiss` | `() => void` | | Shows a dismiss button. | ## Example: Default ```tsx import { NotificationItem } from '@nexub/patterns'; export default function Example() { return ( <div className="w-85"> <NotificationItem title="New team member" description="Sarah joined your workspace." timestamp="2 min ago" read={false} /> <NotificationItem title="Invoice paid" description="Invoice #1042 was paid successfully." timestamp="1 hr ago" read /> </div> ); } ``` --- # PlanCard Pricing plan card with feature checklist, badge, and CTA button. - Package: `@nexub/patterns` · Category: Marketing · Status: stable - Import: `import { PlanCard } from '@nexub/patterns';` - Docs: https://nexub-ds-docs.pages.dev/patterns/plan-card ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `name` (required) | `string` | | Plan name (e.g. "Pro"). | | `price` (required) | `string` | | Price string (e.g. "$49/mo"). | | `description` | `string` | | Short plan description. | | `features` | `string[]` | | List of included features. | | `highlighted` | `boolean` | `false` | Applies brand accent styling for recommended plans. | | `badge` | `string` | | Label for the plan badge (e.g. "Most Popular"). | | `cta` | `string` | `'Get started'` | CTA button label. | | `onSelect` | `() => void` | | CTA button click handler. | ## Example: Default ```tsx import { PlanCard } from '@nexub/patterns'; export default function Example() { return ( <div className="w-70"> <PlanCard name="Pro" price="$49" period="/ month" description="For growing teams that need more power." features={['Unlimited seats', 'Advanced analytics', 'Priority support']} cta="Get started" onSelect={() => {}} /> </div> ); } ``` --- # PricingTable Plans side by side with a monthly / yearly switch, built on PlanCard and SegmentedControl. Client component. - Package: `@nexub/marketing` · Category: Marketing · Status: beta - Import: `import { PricingTable } from '@nexub/marketing';` - Docs: https://nexub-ds-docs.pages.dev/patterns/pricing-table ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `plans` (required) | `PricingPlan[]` | | Each plan: `name`, `price: { monthly, yearly }` per month, `features`, `cta`, and `href` or `onSelect`; `highlighted` and `badge` optional. | | `currency` (required) | `string` | | ISO 4217 code. | | `locale` | `string` | | BCP 47 locale for the prices. | | `defaultPeriod` | `'monthly' \| 'yearly'` | `'monthly'` | Billing period shown first. | | `periodLabels` | `Record<BillingPeriod, string>` | | Labels of the switch. | | `perMonthLabel` | `string` | `'/month'` | Shown after each price. | | `header` | `React.ReactNode` | | A SectionHeader, usually. | ## Example: Default ```tsx import { PricingTable, SectionHeader } from '@nexub/marketing'; export default function Example() { return ( <div data-mode="marketing" className="w-full"> <PricingTable header={<SectionHeader title="Simple pricing" description="Save two months with yearly billing." />} currency="SGD" locale="en-SG" plans={[ { name: 'Starter', price: { monthly: 29, yearly: 24 }, features: ['Up to 10 people', 'Payroll', 'Email support'], cta: 'Start free', href: '#starter' }, { name: 'Growth', price: { monthly: 79, yearly: 66 }, features: ['Up to 100 people', 'Payroll and HR', 'Bookkeeping'], cta: 'Start free', href: '#growth', highlighted: true, badge: 'Most popular' }, { name: 'Scale', price: { monthly: 199, yearly: 166 }, features: ['Unlimited people', 'All products', 'Dedicated manager'], cta: 'Talk to sales', href: '#scale' }, ]} /> </div> ); } ``` --- # ProductGrid Product cards in a grid; each card is one link with the product's accent. Server component. - Package: `@nexub/marketing` · Category: Marketing · Status: beta - Import: `import { ProductGrid } from '@nexub/marketing';` - Docs: https://nexub-ds-docs.pages.dev/patterns/product-grid ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `header` | `React.ReactNode` | | A SectionHeader, usually. | | `ProductCard name` (required) | `string` | | Product name, the card's link text. | | `ProductCard description` (required) | `React.ReactNode` | | One line on what it does. | | `ProductCard href` (required) | `string` | | The product page. | | `ProductCard icon` | `React.ReactNode` | | The product mark. | | `ProductCard accent` | `ProductKey \| DivisionKey` | | Coloured top edge and tint in marketing mode. Keys beyond the four original apps need `@nexub/themes/products` or `@nexub/themes/divisions`. | | `ProductCard division` | `DivisionKey` | | The card's division: sets `data-division` and, without `accent`, tints the card. | | `division` | `DivisionKey` | | Sets `data-division` on the grid. | | `ProductCard linkLabel` | `string` | `'Learn more'` | The visual link cue. | ## Example: Default ```tsx import { BookubMark, FounderubMark, LeapMark, PayubMark } from '@nexub/icons'; import { ProductCard, ProductGrid, SectionHeader } from '@nexub/marketing'; export default function Example() { return ( <div data-mode="marketing" className="w-full"> <ProductGrid header={<SectionHeader eyebrow="Platform" title="One account, four products" />}> <ProductCard name="Leap" description="Incorporate and stay compliant." href="#leap" accent="leap" icon={<LeapMark size={24} />} /> <ProductCard name="Bookub" description="Bookkeeping that closes itself." href="#bookub" accent="bookub" icon={<BookubMark size={24} />} /> <ProductCard name="Payub" description="Payroll and HR in one place." href="#payub" accent="payub" icon={<PayubMark size={24} />} /> <ProductCard name="Founderub" description="Cap table and fundraising." href="#founderub" accent="founderub" icon={<FounderubMark size={24} />} /> </ProductGrid> </div> ); } ``` ## Example: Divisions `division` tints a card with one of the five division colours. Load `@nexub/themes/divisions`. ```tsx import { ProductCard, ProductGrid, SectionHeader } from '@nexub/marketing'; // Needs @nexub/themes/divisions. export default function Example() { return ( <div data-mode="marketing" className="w-full"> <ProductGrid header={<SectionHeader eyebrow="Divisions" title="Five divisions, one account" />}> <ProductCard name="Nexub OS" description="Run the company: people, payroll, books and contracts." href="#os" division="os" /> <ProductCard name="Nexub Commerce" description="Sell online and in store." href="#commerce" division="commerce" /> <ProductCard name="Nexub Fintech" description="Accounts and credit for growing companies." href="#fintech" division="fintech" /> <ProductCard name="Nexub Intelligence" description="AI that knows your business." href="#intelligence" division="intelligence" /> <ProductCard name="Nexub Autonomous" description="Agents that run the routine work." href="#autonomous" division="autonomous" /> </ProductGrid> </div> ); } ``` --- # SectionHeader Eyebrow, headline and lead that open a section. Server component. - Package: `@nexub/marketing` · Category: Marketing · Status: beta - Import: `import { SectionHeader } from '@nexub/marketing';` - Docs: https://nexub-ds-docs.pages.dev/patterns/section-header ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `title` (required) | `React.ReactNode` | | The section heading (h2 by default). | | `eyebrow` | `React.ReactNode` | | A string becomes a gradient EyebrowChip. | | `description` | `React.ReactNode` | | The lead paragraph. | | `align` | `'center' \| 'start'` | `'center'` | Alignment. | | `level` | `2 \| 3` | `2` | Heading level. | | `division` | `DivisionKey` | | Sets `data-division` on the section: a string eyebrow takes the division colour. Load `@nexub/themes/divisions`. | ## Example: Default ```tsx import { SectionHeader } from '@nexub/marketing'; export default function Example() { return ( <div data-mode="marketing" className="w-full py-10"> <SectionHeader eyebrow="Platform" title="Everything your company needs" description="Four products on one account, one login and one bill." /> </div> ); } ``` --- # SettingsSection Grouped settings panel with title, description, and action area. - Package: `@nexub/patterns` · Category: Layout · Status: stable - Import: `import { SettingsSection } from '@nexub/patterns';` - Docs: https://nexub-ds-docs.pages.dev/patterns/settings-section ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `title` (required) | `string` | | Section heading. | | `description` | `string` | | Supporting description for the section. | | `children` (required) | `React.ReactNode` | | Settings controls. | | `actions` | `React.ReactNode` | | Primary action (e.g. save button). | ## Example: Default ```tsx import { SettingsSection } from '@nexub/patterns'; import { Switch } from '@nexub/react'; export default function Example() { return ( <div className="w-full max-w-140"> <SettingsSection title="Notifications" description="Control how and when you receive notifications."> <div className="flex flex-col gap-3 items-start"> {['Email alerts', 'Push notifications'].map((item) => ( <div key={item} className="flex items-center justify-between"> <span className="text-body-sm text-on-surface">{item}</span> <Switch defaultChecked /> </div> ))} </div> </SettingsSection> </div> ); } ``` --- # StatBand A band of headline numbers that count up as they scroll into view. StatBandItem is named apart from the StatCard pattern. Server component. - Package: `@nexub/marketing` · Category: Marketing · Status: beta - Import: `import { StatBand } from '@nexub/marketing';` - Docs: https://nexub-ds-docs.pages.dev/patterns/stat-band ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `title` | `React.ReactNode` | | A heading above the stats. | | `StatBandItem value` (required) | `number \| string` | | A number counts up from zeros when it scrolls into view; the server HTML keeps the real value. | | `StatBandItem label` (required) | `React.ReactNode` | | What the number counts. | | `StatBandItem prefix / suffix` | `string` | | E.g. "$" or "+". | | `StatBandItem tone` | `ToneValue` | `'info'` | The number's colour (accent roles, AA as large text). | | `StatBandItem format` | `Intl.NumberFormatOptions` | | Number formatting. | ## Example: Default ```tsx import { StatBand, StatBandItem } from '@nexub/marketing'; export default function Example() { return ( <div data-mode="marketing" className="w-full"> <StatBand title="Teams run on Nexub"> <StatBandItem value={2000} suffix="+" label="Companies" /> <StatBandItem value={5} label="Countries" tone="success" /> <StatBandItem value={98} suffix="%" label="On-time payroll" tone="payub" /> <StatBandItem value={4.9} label="Average rating" tone="founderub" format={{ minimumFractionDigits: 1 }} /> </StatBand> </div> ); } ``` --- # StatCard Metric display card showing a KPI value, label, optional delta, and icon. - Package: `@nexub/patterns` · Category: Data · Status: stable - Import: `import { StatCard } from '@nexub/patterns';` - Docs: https://nexub-ds-docs.pages.dev/patterns/stat-card ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `label` (required) | `string` | | Metric name label. | | `value` (required) | `React.ReactNode` | | Primary metric value. | | `delta` | `string` | | Change value (e.g. "+12.5%"). | | `deltaType` | `'increase' \| 'decrease' \| 'neutral'` | | Semantic direction of the delta. | | `sentiment` | `'positive' \| 'negative' \| 'neutral'` | | Colour of the delta, independent of the arrow. Defaults from `deltaType`; use it when a decrease is good news (e.g. churn down). | | `icon` | `React.ReactNode` | | Icon displayed in the card header. | | `category` | `'accent' \| 'blue' \| 'amber' \| 'emerald' \| 'pink' \| 'violet' \| 'cyan' \| 'red' \| 'lime'` | | Puts the icon on a tinted chip of this colour and colours the trend line to match. | | `trend` | `number[]` | | Recent values, drawn as a small trend line beside the delta. | | `trendLabel` | `string` | | Accessible summary of the trend. Without it the line is decorative. | | `description` | `string` | | Additional context below the value. | | `animate` | `boolean` | `false` | Roll the digits when a number or string `value` changes (NumberTicker), announced politely. The first render never animates. | | `size` | `'md' \| 'sm'` | `'md'` | Since 11.3. `sm` is the compact tile: less padding and a smaller value. | | `note` | `ReactNode` | | Since 11.3. An extra line inside the tile, under the change. | | `tone` | `'default' \| 'bad-when-high'` | `'default'` | Since 11.3. `bad-when-high` inverts the derived colour, so an increase shows the danger tone (costs, churn, errors). `sentiment` still wins. | | `change` | `number` | | Since 11.3. The change as a number: sets the arrow from its sign and the text from `changeFormat`. Ignored when `delta` is set. | | `changeFormat` | `'percent' \| 'absolute' \| ((change: number) => string)` | `'percent'` | Since 11.3. `percent` takes a fraction (0.125 → +12.5%); `absolute` signs the number (−12). | | `changeLabel` | `ReactNode` | | Since 11.3. Text after the change, e.g. "vs last month". | ## Example: Default ```tsx import { StatCard } from '@nexub/patterns'; export default function Example() { return ( <div className="w-60"> <StatCard label="Total Revenue" value="$48,295" delta="+12.5%" deltaType="increase" description="vs last month" /> </div> ); } ``` ## Example: With icon ```tsx import { StatCard } from '@nexub/patterns'; export default function Example() { return ( <div className="flex gap-3 flex-wrap items-center justify-center"> <StatCard label="Users" value="2,841" delta="+8.3%" deltaType="increase" /> <StatCard label="Churn" value="3.2%" delta="-0.4%" deltaType="decrease" /> </div> ); } ``` ## Example: Animated ```tsx import * as React from 'react'; import { StatCard } from '@nexub/patterns'; import { Button } from '@nexub/react'; export default function Example() { const [orders, setOrders] = React.useState(1284); return ( <div className="flex flex-col gap-3 items-stretch w-60"> <StatCard label="Orders today" value={orders.toLocaleString('en-US')} animate /> <Button size="sm" variant="outlined" onClick={() => setOrders((o) => o + Math.ceil(Math.random() * 40))}> New orders </Button> </div> ); } ``` ## Example: Category and trend ```tsx import { StatCard } from '@nexub/patterns'; import { Wallet } from '@nexub/icons'; export default function Example() { return ( <div className="w-65"> <StatCard label="Saved" value="S$2,400" delta="12%" deltaType="increase" icon={<Wallet size={16} />} category="emerald" trend={[10, 12, 13, 15, 16, 19, 22]} trendLabel="Last 7 weeks, rising" /> </div> ); } ``` ## Example: Compact, absolute change and bad-when-high ```tsx import { StatCard } from '@nexub/patterns'; export default function Example() { return ( <div className="grid w-full max-w-2xl grid-cols-1 gap-4 sm:grid-cols-3"> <StatCard size="sm" label="Revenue" value="S$84,320" change={0.125} changeLabel="vs last month" /> <StatCard size="sm" label="Cloud costs" value="S$12,400" change={0.08} tone="bad-when-high" changeLabel="vs last month" note="Includes a one-off migration" /> <StatCard size="sm" label="Open tickets" value="42" change={-12} changeFormat="absolute" tone="bad-when-high" changeLabel="since Monday" /> </div> ); } ``` --- # StatusPage A whole page for one state: not found, server error, maintenance, offline or no access. - Package: `@nexub/patterns` · Category: Feedback · Status: alpha - Import: `import { StatusPage } from '@nexub/patterns';` - Docs: https://nexub-ds-docs.pages.dev/patterns/status-page ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `kind` (required) | `'notFound' \| 'serverError' \| 'maintenance' \| 'offline' \| 'noAccess'` | | Which state. Sets the default text and illustration. `serverError` and `offline` are announced as alerts. | | `title` | `React.ReactNode` | | Overrides the localised title (the one h1). | | `description` | `React.ReactNode` | | Overrides the localised description. | | `code` | `string` | | A small line above the title, e.g. "404". | | `actions` | `React.ReactNode` | | Buttons under the text. Replaces the default Retry or Back to home. | | `illustration` | `React.ReactNode` | | Art above the text. Defaults to the Illustration for the kind; `null` hides it. | | `onRetry` | `() => void` | | Shows a Retry button for `serverError` and `offline`. | | `homeHref` | `string` | | Shows a "Back to home" link for `notFound` and `noAccess`. | | `fullScreen` | `boolean` | `false` | At least as tall as the viewport. | | `as` | `'main' \| 'div' \| 'section'` | `'main'` | Landmark element. Use `div` inside an app shell that already renders `<main>`. | ## Example: Not found ```tsx import { StatusPage } from '@nexub/patterns'; export default function Example() { return <StatusPage as="div" kind="notFound" code="404" homeHref="/" />; } ``` ## Example: Server error with Retry ```tsx import { StatusPage } from '@nexub/patterns'; // Call your data layer's refetch here. const retry = () => {}; export default function Example() { return <StatusPage as="div" kind="serverError" code="500" onRetry={retry} />; } ``` --- # StatusSteps A read-only list of steps showing where something stands: done, current, upcoming or a problem. - Package: `@nexub/patterns` · Category: Data · Status: alpha - Import: `import { StatusSteps } from '@nexub/patterns';` - Docs: https://nexub-ds-docs.pages.dev/patterns/status-steps ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `steps` (required) | `{ id?: string; title: ReactNode; description?: ReactNode; status: 'done' \| 'current' \| 'upcoming' \| 'error'; timestamp?: ReactNode; action?: ReactNode }[]` | | The steps, first to last. | | `aria-label` (required) | `string` | | Names the list. `aria-labelledby` works too. | | `size` | `'sm' \| 'md'` | `'md'` | Marker, type and spacing. | ## Example: Application review ```tsx import { StatusSteps } from '@nexub/patterns'; export default function Example() { return ( <div className="w-full max-w-sm"> <StatusSteps aria-label="Application progress" steps={[ { id: 'submitted', title: 'Submitted', status: 'done', timestamp: <time dateTime="2026-03-12">12 Mar</time> }, { id: 'review', title: 'Under review', status: 'current', description: 'Usually takes two working days.' }, { id: 'approved', title: 'Approved', status: 'upcoming' }, ]} /> </div> ); } ``` ## Example: With a problem ```tsx import { StatusSteps } from '@nexub/patterns'; import { Button } from '@nexub/react'; export default function Example() { return ( <div className="w-full max-w-sm"> <StatusSteps aria-label="Application progress" steps={[ { id: 'submitted', title: 'Submitted', status: 'done', timestamp: <time dateTime="2026-03-12">12 Mar</time> }, { id: 'documents', title: 'Documents need another look', status: 'error', description: 'The proof of address is older than three months.', action: <Button size="sm" variant="tonal">Upload again</Button>, }, { id: 'approved', title: 'Approved', status: 'upcoming' }, ]} /> </div> ); } ``` Related: [stepper](stepper.md), [progress](progress.md), [activity-feed](activity-feed.md) --- # TestimonialGrid Customer quotes in product-coloured cards, with an optional star rating. Server component. - Package: `@nexub/marketing` · Category: Marketing · Status: beta - Import: `import { TestimonialGrid } from '@nexub/marketing';` - Docs: https://nexub-ds-docs.pages.dev/patterns/testimonial-grid ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `header` | `React.ReactNode` | | A SectionHeader, usually. | | `TestimonialCard quote` (required) | `React.ReactNode` | | The quote. | | `TestimonialCard name` (required) | `string` | | Who said it. | | `TestimonialCard role` | `React.ReactNode` | | Job title and company. | | `TestimonialCard avatarSrc` | `string` | | Photo; initials otherwise. | | `TestimonialCard rating` | `number` | | Stars out of 5, announced as "Rated n out of 5". | | `TestimonialCard accent` | `ProductKey \| DivisionKey` | | The product the customer uses. | ## Example: Default ```tsx import { SectionHeader, TestimonialCard, TestimonialGrid } from '@nexub/marketing'; export default function Example() { return ( <div data-mode="marketing" className="w-full"> <TestimonialGrid header={<SectionHeader eyebrow="Customers" title="Loved by finance teams" />}> <TestimonialCard accent="payub" rating={5} name="Priya Nair" role="Head of People, Kopi Labs" quote="Payroll used to take two days. Now it takes twenty minutes." /> <TestimonialCard accent="bookub" rating={5} name="Daniel Tan" role="CFO, Harbourline" quote="Our books close on the third working day, every month." /> <TestimonialCard accent="leap" rating={5} name="Linh Pham" role="Founder, Sonvo" quote="We incorporated in Singapore without leaving Hanoi." /> </TestimonialGrid> </div> ); } ``` --- # UserCard User profile card displaying avatar, name, role, and optional actions. - Package: `@nexub/patterns` · Category: People · Status: stable - Import: `import { UserCard } from '@nexub/patterns';` - Docs: https://nexub-ds-docs.pages.dev/patterns/user-card ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `name` (required) | `string` | | User display name. | | `email` | `string` | | User email address. | | `role` | `string` | | Job title or role label. | | `avatarSrc` | `string` | | URL for avatar image. | | `actions` | `React.ReactNode` | | Action buttons or menu. | ## Example: Default ```tsx import { UserCard } from '@nexub/patterns'; export default function Example() { return ( <div className="w-75"> <UserCard name="Alex Johnson" email="alex@example.com" role="Admin" avatarFallback="AJ" /> </div> ); } ``` --- # WelcomeBanner A greeting at the top of a home or dashboard page: what is new, or the next step for a new account. - Package: `@nexub/patterns` · Category: Data · Status: alpha - Import: `import { WelcomeBanner } from '@nexub/patterns';` - Docs: https://nexub-ds-docs.pages.dev/patterns/welcome-banner ## Props | Prop | Type | Default | Description | | --- | --- | --- | --- | | `title` (required) | `React.ReactNode` | | The greeting, e.g. "Welcome back, Mei". | | `description` | `React.ReactNode` | | One or two lines under the title. | | `actions` | `React.ReactNode` | | One or two buttons. | | `media` | `React.ReactNode` | | Decorative art on the trailing side. Hidden on phones. | | `onDismiss` | `() => void` | | Shows a close button. Keep the dismissed state in your app. | | `level` | `2 \| 3` | `2` | Heading level of the title. | ## Example: Default ```tsx import { WelcomeBanner } from '@nexub/patterns'; import { Button } from '@nexub/react'; export default function Example() { return ( <div className="w-full max-w-2xl"> <WelcomeBanner title="Welcome back, Mei" description="Two bills are due this week." actions={<Button>Review bills</Button>} /> </div> ); } ``` ## Example: With art and dismiss ```tsx import * as React from 'react'; import { WelcomeBanner } from '@nexub/patterns'; import { Button, IconChip } from '@nexub/react'; import { Wallet } from '@nexub/icons'; export default function Example() { const [open, setOpen] = React.useState(true); if (!open) return <Button variant="tonal" onClick={() => setOpen(true)}>Show the banner again</Button>; return ( <div className="w-full max-w-2xl"> <WelcomeBanner title="Finish setting up your account" description="Add a bank account to send and receive money." actions={ <> <Button>Add account</Button> <Button variant="text">Later</Button> </> } media={ <IconChip category="accent" size="lg" shape="circle"> <Wallet /> </IconChip> } onDismiss={() => setOpen(false)} /> </div> ); } ``` --- # @nexub/react-native React Native components and screen patterns for Nexub Design System. They use the same tokens, brands and prop names as `@nexub/react` on the web. **Native chrome, Nexub content.** The system draws the tab bar, stack header, back gesture, action sheets, pickers and iOS 26 Liquid Glass; Nexub themes them. Everything inside a screen (lists, cards, buttons, inputs, money) is drawn by Nexub, so it looks the same on iOS, Android and the web. Status: **alpha**. Built for Expo SDK 58+ / React Native 0.86+ (New Architecture). Works in Expo apps and bare React Native apps. ## Install ```bash npx expo install @nexub/react-native react-native-gesture-handler react-native-reanimated react-native-worklets react-native-svg react-native-safe-area-context expo-font ``` Optional peers. Add only what you use; without them the feature is a no-op or the component tells you what to install: | Package | Used by | |---|---| | `expo-haptics` | Semantic haptics on every control | | `expo-glass-effect` | Native Liquid Glass (`Surface material="glass"`) on iOS 26+ | | `expo-screen-capture` | `PrivacyShield preventCapture` | | `@react-native-community/datetimepicker` | `DateTimeField` | `@nexub/tokens`, `@nexub/core`, `@nexub/icons` and the fonts (Plus Jakarta Sans, Geist Mono; OFL) come with the package. ## Set up ```tsx import { useFonts } from 'expo-font'; import { Stack } from 'expo-router'; import { GestureHandlerRootView } from 'react-native-gesture-handler'; import { NexubNativeProvider, ToastProvider, nexubFonts, useNexubNavigation } from '@nexub/react-native'; function Screens() { const nav = useNexubNavigation(); // native stack in Nexub colours and type return <Stack screenOptions={nav.stack} />; } export default function RootLayout() { const [ready] = useFonts(nexubFonts); if (!ready) return null; return ( <GestureHandlerRootView style={{ flex: 1 }}> <NexubNativeProvider product="payub"> <ToastProvider> <Screens /> </ToastProvider> </NexubNativeProvider> </GestureHandlerRootView> ); } ``` `GestureHandlerRootView` at the root is required since 10.9: `BottomSheet`, `SwipeableRow`, `Slider` and toasts read their gestures on the UI thread through `react-native-gesture-handler` (3.0 or newer, now a required peer). `NexubNativeProvider` props: | Prop | Default | | |---|---|---| | `scheme` | `'system'` | `'light'`, `'dark'` or follow the OS | | `contrast` | `'system'` | follows iOS Increase Contrast / Android high-contrast text (re-read on foreground) | | `product` | none | `'leap' \| 'bookub' \| 'payub' \| 'founderub'`: remaps the tertiary family | | `seed`, `seedTarget` | none | white-label colour: regenerates the primary (or tertiary) family with contrast-safe tones | | `glass` | `'balanced'` | the user's glass dial; forced `'off'` under Reduce Transparency | | `haptics` | `true` | the user's haptics setting | | `fonts` | `'nexub'` | `'system'` to use the platform font | | `locale`, `dir`, `messages` | `'en'` | Intl locale, RTL (derived from the locale) and translated strings, same as web `NexubProvider` | Hooks: `useTheme()`, `useRoles()`, `useHaptics()`, `useNexubMessages()`, `useNexubNavigation()`. ## Components Names and props match `@nexub/react` where a web twin exists. - **Primitives:** `Text`, `Heading`, `Pressable` (state layer, 0.97 press spring, haptic), `Surface` (tonal tiers, elevation, glass), `Box`, `Stack`, `Inline`, `Icon`, `ScreenContainer`. - **Actions:** `Button`, `IconButton`, `ButtonGroup`, `Link`. - **Data:** `Amount`, `Badge`, `Avatar`, `AvatarGroup`, `Divider`. - **Inputs:** `TextField`, `PasswordInput`, `SearchField`, `MoneyInput`, `Stepper`, `Checkbox`, `RadioGroup` / `Radio`, `Switch` (the platform switch), `SegmentedControl`, `Slider`, `Chip`, `FilterChip`, `Select`, `DateTimeField`, `OTPInput`, `NumericKeypad`, `ExpressiveMoneyInput`. - **Containers:** `Card`, `ListItem` (navigation, switch, checkbox, radio, button and value rows), `ListSection`, `Accordion`. - **Overlays:** `BottomSheet` (detents), `ActionSheet` (system sheet on iOS), `ContextMenu`, `Dialog`. - **Feedback:** `Banner`, `ToastProvider` / `useToast`, `Progress`, `LoadingIndicator`, `Skeleton`, `SkeletonSwap`, `EmptyState`, `ErrorState`, `OfflineBanner`, `Coachmark`. - **Mobile:** `SwipeableRow`, `RefreshControl`, `Carousel`, `PageIndicator`, `StickyFooter`, `SensitiveValue`, `PrivacyShield`, `FAB` (Android only by default). - **Navigation helpers:** `nexubStackOptions`, `nexubNavigationTheme`, `nexubTabsOptions`. - **Motion:** `nxEnter`, `nxExit`, `nxLayout` (Reanimated layout animations) and `nxSpring` (a `withSpring` config), built from the same spring tokens as the web. `<Animated.View entering={nxEnter('up')} exiting={nxExit('down')} layout={nxLayout()} />`. Toast, Banner, `ListSection` rows, `SwipeableRow`, `Chip`, the `SegmentedControl` pill and `Amount` (`animate`) already use them. In a `FlatList`, pass `nxLayout()` as `itemLayoutAnimation`. Icons: `import { Search } from '@nexub/icons/native'`. These are the same names as `@nexub/icons`. Colour them with `<Icon icon={Search} color="primary" />`. The Nexub marks are there too: `NexubMark` (`variant="color"` for the brand gradient), `LeapMark`, `BookubMark`, `PayubMark`, `FounderubMark`, and `ACRA`, `IRAS`, `MCA`, `GST`. ## Patterns `import { SignInScreen, AmountStep, ActivityList } from '@nexub/react-native/patterns'`. Each pattern is a screen template that takes data and callbacks, so it works with any router. - **Auth:** `AuthScreen`, `SignInScreen`, `VerifyCodeScreen`, `LockScreen`. - **Money:** `FlowStep`, `AmountStep`, `ReviewStep`, `ActivityList`, `TransactionDetail`, `ResultScreen`. - **App:** `OnboardingScreen`, `PermissionPrimer`, `SettingsScreen`, `ProfileHeader`, `AppearanceSection`, `NotificationsInbox`, `SearchScreen`, `ChatScreen`, `PaywallScreen`, `AppSwitcherSheet`. ## Rules the components follow - **Touch targets:** every control reaches 44pt (`hitSlop` on smaller visuals). Primary actions use `size="lg"` (48). - **Text scaling:** every role scales with the system text size. iOS follows Apple's Dynamic Type curve per role, and display and headline roles are capped so they don't push content off screen. - **Screen readers:** - A list row is one element ("Amazon, −$42.50, today"). - Swipe and long-press actions are also accessibility actions. - Masked values read as "hidden". - Toasts are announced. - **Haptics are semantic** (`selection`, `toggleOn`/`toggleOff`, `confirm`, `reject`, `warning`, `snap`), never on plain taps, and never the only feedback. - **Motion:** M3 springs. Enter rides the spatial spring; exit is quicker on the effects spring and never overshoots. Every preset follows the OS Reduce Motion setting. - **Glass:** for the control layer only, never content. It is native Liquid Glass on iOS 26+, solid elsewhere and whenever the user turns transparency down. - **Security:** `OTPInput` uses one field, so SMS autofill works. `PasswordInput` sets the platform autofill hints. `SensitiveValue` re-masks when the app backgrounds. `PrivacyShield` covers the app-switcher snapshot. The library makes no network calls and stores nothing. ## Testing your app The library's own tests use Jest (jest-expo) and React Native Testing Library. In your Jest setup, stub `react-native-reanimated`'s APIs, add `react-native-gesture-handler/jestSetup` and use `react-native-safe-area-context/jest/mock`; `packages/react-native/jest.setup.js` in the repo shows the pattern. ## Links - Docs: https://nexub-ds-docs.pages.dev/getting-started/react-native - Plan and decisions: [MOBILE_PLAN.md](https://github.com/Nexub-AI/nexub-ds/blob/development/MOBILE_PLAN.md) - Web components: `@nexub/react`