@allfitone/react

中文文档
0.16.0发布于 2026/11/05UNLICENSEDTypeScriptES Module近 30 天下载 1761

React and Next.js adapters for the Allfit One design system.

原始使用文档

@allfitone/react

React and Next.js adapters for the Allfit One foundations. Import explicit subpaths so applications only include the capabilities they use.

import { BrandLockup, ProductLockup } from "@allfitone/react/brand";
import { BackIcon, FoundationIcon } from "@allfitone/react/icons";
import { semanticColor } from "@allfitone/react/tokens";
import "@allfitone/react/tokens.css";
import "@allfitone/react/app.css";
import "@allfitone/react/styles.css";

import { Button } from "@allfitone/react/components/button";
import { Dialog } from "@allfitone/react/components/dialog";
import { AnimatedBrandLockup } from "@allfitone/react/components/animated-brand-lockup";

<ProductLockup product="studio" surface="dark" title="Allfit Studio" />;

Entry points

  • @allfitone/react/brand: accessible master-brand logo plus Space, Studio, and Backoffice SVG wordmark and shared-logo lockup components.
  • @allfitone/react/icons: semantic Lucide icon component and icon metadata.
  • @allfitone/react/tokens: typed platform-neutral token values.
  • @allfitone/react/tokens.css: generated Web token variables and theme selectors.
  • @allfitone/react/app.css: application canvas, browser reset, and product-font bridge.
  • @allfitone/react/styles.css: compiled Tailwind 4 component utilities and the ALLFIT ONE shadcn bridge.
  • @allfitone/react/components/*: explicit component subpaths; there is no all-components barrel.
  • @allfitone/react/lib/utils: public cn class-composition utility.

The package root contains platform metadata only. This prevents accidental broad component imports and keeps bundle analysis predictable.

Component contract

The component API follows shadcn composition on Base UI while its visual variants, tokens, target sizes, focus treatment, and accessibility defaults belong to ALLFIT ONE. Import CSS once at the application root in this order: tokens.css, app.css, then styles.css. Change themes with data-afo-theme="dark|light" on the document element.

app.css keeps application-level visual decisions in the Design System. Products that load fonts with next/font should expose the generated family names as --afo-app-font-display and --afo-app-font-body:

const display = Barlow_Condensed({
  subsets: ["latin"],
  variable: "--afo-app-font-display",
  weight: ["500", "600", "700"],
});

const body = Manrope({
  subsets: ["latin"],
  variable: "--afo-app-font-body",
});

Available public component subpaths are:

  • actions: button and icon-button;
  • navigation: breadcrumb, navigation-menu, dropdown-menu, pagination, drawer, sidebar, workspace-shell, setup-shell, and command;
  • entry: access-shell for responsive, brand-led authentication and product-entry pages, setup-shell for multi-step activation and onboarding, device-gate for replacing compact-phone workspaces with device guidance, and site-shell for the shared header and footer of public product sites;
  • forms: field, label, input, and textarea;
  • selection: checkbox, radio-group, switch, toggle-group, select, combobox, date-picker, time-picker, calendar, tabs, and choice-card;
  • data display: table, data-table, avatar, badge, card, skeleton, and empty;
  • signature: accent-block, stat-strip, tick-ring, pulse-mark, and animated-brand-lockup;
  • overlays: dialog, alert-dialog, sheet, popover, tooltip, and the CommandDialog composition from command;
  • feedback: progress, alert, sonner, and spinner;
  • composition: collapsible and separator.

There is no all-components barrel. Import each component from its explicit @allfitone/react/components/{name} subpath.

SetupShell owns the responsive header, progress list, stage and split-panel hierarchy used by activation and setup flows. SetupProgressStep derives its completed icon and aria-current state from status; products provide only the index and label. Use SetupPanelTitle as="h2" when the panel sits below an existing page title.

ChoiceCard is one interactive surface, rendered as a button by default or through render for navigation. Compose its eyebrow, title, description and action slots inside it; do not place another interactive control inside the card.

Loading actions compose a named Spinner inside a disabled Button; components do not expose an isLoading prop. Icon-only actions use IconButton, whose TypeScript contract requires aria-label.

Table exposes comfortable and compact densities while preserving native table semantics. Use scrollAreaLabel when horizontal overflow is expected so keyboard users can reach the scroll region. Sorting is expressed with aria-sort on TableHead and a visually neutral TableSortButton; selected rows pair selected with a named Checkbox, and TableState provides loading, empty, and error compositions.

DataTable builds on those primitives with a TanStack-powered headless layer. Create the instance with useDataTable, then compose DataTableToolbar, DataTableFilterInput, DataTableViewOptions, DataTableSelectionBar, and DataTablePagination as needed. Pass TanStack state and on*Change options to control sorting, filters, visibility, selection, and pagination from a server-backed product screen.

Avatar keeps identity explicit across image loading and failure. Name the root with aria-label or aria-labelledby, include AvatarFallback, and use decorative only beside equivalent visible identity text. Presence states pair semantic color with distinct icons and labels; groups expose their remaining member count in words.

Command filters and ranks keyboard-first workspace destinations and actions. Give the root a descriptive label, compose a named input, grouped items, shortcuts, and an empty state, and provide stable item values. CommandDialog uses the same command children inside the public Dialog focus contract rather than introducing a separate global-search API. When a controlled global shortcut opens the dialog without DialogTrigger, retain the invoking element in a ref and pass it to finalFocus.

ToggleGroup composes two to seven compact pressed buttons for mode, locale, or filter choices. Its value, defaultValue, and onValueChange contracts always use arrays in both single and multiple modes. Give each group an accessible name. A single group can return an empty array when its active item is pressed again; consumers such as locale switchers that require one value must reject that empty change. Use Tabs when the choice controls panels and RadioGroup when exactly one form value must be submitted.

Combobox filters a predefined item collection and supports single or multiple selection, grouped rich options, removable chips, and async loading, empty, and error messages. Keep ComboboxStatus mounted and update its children when a remote request changes state. For async collections, retain any selected items in the items array so their labels remain available.

Calendar composes React DayPicker for single dates and ranges. Its public props support controlled selection, disabled matchers, locale and timezone configuration, multiple responsive months, and the canonical 44 px date grid. Import DateRange and Matcher types from the same component subpath.

DatePicker composes a typed field, Popover, and Calendar around one controlled or uncontrolled Date | undefined value. It keeps its accepted format visible, validates typed dates and disabled Calendar matchers, and exposes textual invalid or unavailable states without requiring a second parsing implementation in the product. formatLabel names the visible format in the product's language.

TimePicker is DatePicker's counterpart for a time of day. Its value is an HH:MM string on a 24-hour clock, with no date or timezone; the product combines it with both. Times can be typed or chosen from a list offered every step minutes, which opens on the current time and moves by arrow, page (one hour), Home and End keys. Every visible and announced word is a prop.

Alert provides info, success, warning, and danger callouts with an automatic semantic icon, title, description, and optional action. Static callouts stay silent by default; use live="polite" for status updates or live="assertive" for urgent failures inserted at runtime.

Progress composes a visible label and value with its track and indicator. Use value={null} for indeterminate operations, and pair domain-specific visible values with getAriaValueText. The full and compact variants share the same semantics and retain a static signal when reduced motion is enabled.

AnimatedBrandLockup is the opt-in web entrance for the canonical Allfit One lockup. It plays once, renders the final frame when reduced motion is requested, and can be replayed by changing replayKey. Static brand consumers should keep using BrandLockup from @allfitone/react/brand.

DeviceGate is a CSS-first composition for products that require tablet or desktop workspace. Compose the compact fallback before DeviceGateContent. Use DeviceGateActions for product-owned recovery actions such as copying a workspace link; the slot provides responsive layout but does not own clipboard, email, QR, or navigation behavior. Put the fallback accessible name on DeviceGateMain so its visible main remains the top-level landmark. The fallback replaces product content below 600px wide and on coarse-pointer landscape viewports below 600px high; no user-agent detection or client-side hydration is required. At 600px wide and above, tablet content remains available.

版本与发布记录

@allfitone/react 共发布 29 个版本,首次发布于 2026/07/25;过去 12 个月发布了 29 个版本。

版本发布日期距今
0.16.0latest2026/11/055 天前
0.15.12026/11/045 天前
0.15.02026/11/036 天前
0.14.42026/11/037 天前
0.14.32026/10/2911 天前
0.14.22026/10/101 个月前

其他发布通道:next → 0.1.0。

关于 @allfitone/react 的常见问题

@allfitone/react 是什么?

React and Next.js adapters for the Allfit One design system.

如何安装 @allfitone/react?

在项目目录运行 npm install @allfitone/react,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=19)、react-dom(>=19)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@allfitone/react 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@allfitone/react 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@allfitone/react 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@allfitone/react 可以商用吗?

@allfitone/react 使用 UNLICENSED 许可。作者声明为 UNLICENSED,即不授予公开使用许可(与公共领域的 Unlicense 不同)。使用前需获得作者授权。以上为概括,不构成法律意见,请以许可原文为准。

@allfitone/react 的下载量有多少?

根据 npm 官方下载统计,@allfitone/react 在 2026/10/06 – 2026/11/04 这 30 天内被下载 1,761 次,日均约 59 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@allfitone/react 还在维护吗?

最新版本 0.16.0 发布于 2026/11/05(5 天前);至今共发布 29 个版本,其中过去 12 个月发布了 29 个;首次发布于 2026/07/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。