@alexandernygard/components

中文文档
0.6.0发布于 2026/10/29MITTypeScriptES Module近 30 天下载 1771

Alex Nygård's React component library: shadcn/ui + Radix + Tailwind 4, with a cool Nordic theme.

原始使用文档
文档目录5 节
  1. Use it in an app
  2. The look
  3. What's in it
  4. Develop
  5. Publish

@alexandernygard/components

The React components behind my apps: 63 shadcn/ui components on Radix, styled with Tailwind 4 and one shared theme. Storybook is the workbench.

Svelte apps use @alexandernygard/components-svelte, which has the same components and theme. Both read their colours, type and fonts from @alexandernygard/tokens.

Use it in an app

pnpm add @alexandernygard/components

With Tailwind 4 (lommebok, interior-designer and any new Vite app). Import the theme after Tailwind. It adds the tokens and fonts and points Tailwind at the package so the classes get generated:

@import "tailwindcss";
@import "@alexandernygard/components/theme.css";

Without Tailwind, import the precompiled stylesheet once:

import "@alexandernygard/components/styles.css"

Then:

import { Button, Card, CardHeader, CardTitle, TooltipProvider, Toaster } from "@alexandernygard/components"

Wrap the app in TooltipProvider if it uses tooltips, and render <Toaster /> once if it uses toasts. toast() is exported too, so there's no need to install sonner. Dark mode is the dark class on <html>. Peer dependencies are react and react-dom 18.3 or 19.

Every module is its own file and the package is marked side-effect free, so an app only bundles what it imports. Charts (recharts), syntax highlighting (shiki) and the carousel stay out unless you use them.

The look

  • Colours. Snow #f5f7f8, granite #18212b, frost #dde3e8, and one accent, cloudberry #f2a922. Cloudberry only marks on or selected states: checkboxes, switches, radios, sliders, progress, the active tab, pressed toggles, the active sidebar item and the focus ring.
  • Type. Libron, from @alexandernygard/libron, for everything. Titles in cards, dialogs, sheets, drawers, empty states, field legends and questionnaires use font-heading, so an app can give titles a different face by overriding --font-heading.
  • Shape. Corners grow with size: 4px for checkboxes, 8px for controls, 12px for cards, 16px for dialogs, fully round for badges and switches. Shadows are layered and tinted with the ink colour.
  • Status. positive, warning, info and destructive tokens. Badge and Alert have matching variants.

To override a token in an app:

:root {
  --highlight: #3fa36b;
  --ring: #2f8556;
}

What's in it

Accordion, Alert, Alert dialog, Aspect ratio, Attachment, Avatar, Badge, Breadcrumb, Bubble, Button, Button group, Calendar, Card, Carousel, Chart, Checkbox, Code block, Collapsible, Combobox, Command, Context menu, Dialog, Direction, Drawer, Dropdown menu, Empty, Field, Hover card, Illustration, Input, Input group, Input OTP, Item, Kbd, Label, Marker, Menubar, Message, Message scroller, Native select, Navigation menu, Pagination, Popover, Progress, Questionnaire, Radio group, Resizable, Scroll area, Select, Separator, Sheet, Sidebar, Skeleton, Slider, Sonner (toasts), Spinner, Switch, Table, Tabs, Textarea, Toggle, Toggle group, Tool call, Tool value, Tool views, Tooltip, Trace.

Bubble, Message, Message scroller, Marker, Attachment, Trace, Tool call, Code block and Questionnaire cover assistant and chat interfaces. ToolViewsProvider sets how each tool's input and output are shown, and ToolTrace renders tool calls from @alexandernygard/ai-kit with those views.

Develop

This package lives in a pnpm workspace. Run these from packages/react, or from the repo root with pnpm --filter @alexandernygard/components <script>.

pnpm install
pnpm dev              # Storybook on http://localhost:6006
pnpm typecheck
pnpm build            # dist/: ES modules, .d.ts, theme.css, styles.css, fonts.css
pnpm build-storybook  # static Storybook in storybook-static/
  • Components live in src/components/ui/. They are shadcn's radix-nova sources with theme edits, so shadcn add <name> works. Don't pass --overwrite to update an existing component, or you lose the edits.
  • After adding a component, run node scripts/gen-index.mjs to export it, then add a story in src/stories/components/.
  • Tokens and fonts live in packages/tokens, shared with the Svelte library. src/styles/shadcn.css is vendored from the shadcn package (custom variants, scroll-fade, shimmer).
  • Stories are grouped as Foundations (tokens, type, radius, elevation), Components, and Patterns (app shell, settings page, assistant chat).

Publish

Releases go through Changesets from the repo root. See Publish in the root README.

版本与发布记录

@alexandernygard/components 共发布 11 个版本,首次发布于 2026/10/18;过去 12 个月发布了 11 个版本。

版本发布日期距今
0.6.0latest2026/10/2910 天前
0.5.02026/10/2811 天前
0.4.02026/10/2712 天前
0.3.02026/10/2217 天前
0.2.02026/10/2019 天前
0.1.42026/10/1920 天前

关于 @alexandernygard/components 的常见问题

@alexandernygard/components 是什么?

Alex Nygård's React component library: shadcn/ui + Radix + Tailwind 4, with a cool Nordic theme.

如何安装 @alexandernygard/components?

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

@alexandernygard/components 支持 TypeScript 吗?

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

@alexandernygard/components 支持 ESM 还是 CommonJS?

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

@alexandernygard/components 可以商用吗?

@alexandernygard/components 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@alexandernygard/components 的下载量有多少?

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

@alexandernygard/components 还在维护吗?

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