@aphrody/m3-primitives

中文文档
1.4.7发布于 2026/10/23Apache-2.0 AND MITTypeScriptES Module近 30 天下载 2017

Material Design 3 React primitives: the SpaceUI (@spacedrive/primitives) component set rebuilt on the M3 roles, shape, typescale, state layers and motion of the aphrody design system.

原始使用文档
文档目录5 节
  1. Styles
  2. Usage
  3. Components
  4. Coming from @spacedrive/primitives
  5. Development

@aphrody/m3-primitives

Material Design 3 React primitives (buttons, fields, menus, dialogs, cards, toasts) on Base UI, rebuilt from SpaceUI's @spacedrive/primitives.

bun add @aphrody/m3-primitives @aphrody/m3-theme @aphrody/m3-tokens react react-dom tailwindcss
import {
  Button,
  Card,
  CardContent,
  CardHeader,
  CardTitle,
  Input,
} from "@aphrody/m3-primitives";

export function Welcome() {
  return (
    <Card variant="elevated">
      <CardHeader>
        <CardTitle>Welcome</CardTitle>
      </CardHeader>
      <CardContent>
        <Input placeholder="Your name" icon="person" />
        <Button variant="filled">Get started</Button>
      </CardContent>
    </Card>
  );
}

License: Apache-2.0 AND MIT (LICENSE, LICENSE.spaceui). Install guide: docs/material/m3/INSTALL.md.

The SpaceUI set (MIT, (c) Spacedrive) is rebuilt on the M3 system: colour roles and state layers, the 10-step shape scale, the typescale, the focus ring, elevation, Material Symbols and the easings of @aphrody/m3-motion. Base UI (@base-ui/react) is the headless layer: it owns behaviour, keyboard interaction, focus management and accessibility, and drives the M3 enter / exit motion through its data-starting-style / data-ending-style attributes. Every upstream export and prop still works; the Radix-era props (asChild, checked="indeterminate", delayDuration, forceMount, onSelect, array slider values) are mapped onto Base UI, and Base UI props are accepted as well.

Fusion rules, token mapping and the Material Web equivalents of each component: SPACEUI-M3-FUSION.md. Peers: react and react-dom 18 or 19, tailwindcss 4.1+.

Styles

The components are styled with M3 Tailwind utilities (bg-surface-container, text-on-surface-variant, rounded-full, text-label-large, hover:bg-on-surface/8), so the app compiles them with Tailwind v4:

@import "tailwindcss";
@import "@aphrody/m3-tokens/m3-tokens.css"; /* shape, typescale, elevation, motion, state */
@import "@aphrody/m3-theme/spaceui.css"; /* SpaceUI themes as M3 schemes — or tokens.css */
@import "@aphrody/m3-theme/tailwind.css"; /* M3 utilities */
@source "../node_modules/@aphrody/m3-primitives/dist";

Icons use the Material Symbols font: import @aphrody/m3-fonts/fonts-symbols.css, or, with @aphrody/material-web installed, register it once:

import { ensureMaterialSymbols } from "@aphrody/material-web/icon/material-symbols.js";
ensureMaterialSymbols();

Usage

import {
  Button,
  Card,
  CardContent,
  CardHeader,
  CardTitle,
  Icon,
  Input,
} from "@aphrody/m3-primitives";

export function Welcome() {
  return (
    <Card variant="elevated">
      <CardHeader>
        <CardTitle>Welcome</CardTitle>
      </CardHeader>
      <CardContent className="space-y-4">
        <Input placeholder="Your name" icon="person" />
        <Button variant="filled">
          <Icon name="arrow_forward" size={18} /> Get started
        </Button>
      </CardContent>
    </Card>
  );
}

Components

GroupComponentsM3 anatomy
ActionsButton (filled, tonal, outlined, text, elevated + the SpaceUI variants), CircleButton, CircleButtonGroup, ShinyButton, ShinyToggle, FilterButton, SelectPill, SelectTriggerButtonCommon buttons, icon buttons, connected group, filter chip
SelectionCheckBox, RadixCheckbox, Switch, Slider, RadioGroupRoot/Item, ToggleGroup, OptionListCheckbox, switch, slider, radio, segmented button
Text inputInput, SearchInput, PasswordInput, TextArea, Label, SearchBar, NumberStepper, SelectOutlined / filled text fields, search bar, exposed dropdown menu
NavigationTabsRoot/List/Trigger/Content, TabBar, SpaceItemPrimary tabs, navigation-drawer item
Menus and overlaysDialog (+ dialogManager, useDialog), Popover, Tooltip, Kbd, DropdownMenu, ContextMenu, DropdownBasic dialog, menus, plain tooltip
Feedbacktoast, Toaster, Loader, ProgressBar, CircularProgress, Banner, InfoBanner, BadgeSnackbar, progress indicators, banners, badges and assist chips
ContainmentCard (elevated, filled, outlined), Divider, Collapsible, Resizable, LayoutCard, GridLayoutCards, divider, expansion panel
TypeCategoryHeading, ScreenHeading, ShortcutTitle small, headline small, key chips
FormsForm, ErrorMessage, errorStyles, zError supporting text
HelpersIcon, renderIcon, IconSource, PHOSPHOR_TO_SYMBOL, m3StateLayer, m3FocusRing, tw, surface class names, key symbols

Sizes: the default (md/unset) is the M3 baseline height; smaller sizes are M3 density steps.

Coming from @spacedrive/primitives

Rename the import. Phosphor icon props still compile (they accept an IconSource: a Material Symbols name, an element or a component). Visible differences: M3 heights (inputs default to 56, icon buttons to 40), pill-shaped buttons, secondary-container selection, Material Symbols glyphs, Select opens below its field, Collapsible draws an expand_more indicator (indicator={false} to opt out).

Development

bun run typecheck
bun test          # happy-dom preloaded by bunfig.toml
bun run build     # Bun.build + declarations

版本与发布记录

@aphrody/m3-primitives 共发布 13 个版本,首次发布于 2026/09/25;过去 12 个月发布了 13 个版本。

版本发布日期距今
1.4.7latest2026/10/2315 天前
1.4.42026/10/1820 天前
3.3.112026/10/1028 天前
3.3.92026/10/1029 天前
3.3.82026/10/0929 天前
3.3.72026/10/071 个月前

关于 @aphrody/m3-primitives 的常见问题

@aphrody/m3-primitives 是什么?

Material Design 3 React primitives: the SpaceUI (@spacedrive/primitives) component set rebuilt on the M3 roles, shape, typescale, state layers and motion of the aphrody design system.

如何安装 @aphrody/m3-primitives?

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

@aphrody/m3-primitives 支持 TypeScript 吗?

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

@aphrody/m3-primitives 支持 ESM 还是 CommonJS?

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

@aphrody/m3-primitives 可以商用吗?

@aphrody/m3-primitives 使用 Apache-2.0 AND MIT 许可。声明的许可为 Apache-2.0 AND MIT,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

@aphrody/m3-primitives 的下载量有多少?

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

@aphrody/m3-primitives 还在维护吗?

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