114k

更新日志

RSS

最新更新与公告。

2026 年 3 月 - shadcn/cli v4

我们发布了 shadcn/cli 第 4 版。它更强大、更易用,专为你和你的编码代理打造。下面是全部新内容。

shadcn/skills

shadcn/skills gives coding agents the context they need to work with your components and registry correctly. It covers both Radix and Base UI primitives, updated APIs, component patterns and registry workflows. The skill also knows how to use the shadcn CLI, when to invoke it and which flags to pass. Agents make fewer mistakes and produce code that actually matches your design system.

你可以让你的代理执行类似这样的任务:

  • "create a new vite monorepo"
  • "find me a hero from tailark, add it to the homepage, animate the text using an animation from react-bits"
  • "install and configure a sign in page from @clerk"
pnpm dlx skills add shadcn/ui

引入 --preset

预设会把你整个设计系统配置打包成一个短代码。颜色、主题、图标库、字体、圆角,一串字符串全部包含。

shadcn/create 中构建你的预设,实时预览,准备好后复制代码即可。

pnpm dlx shadcn@latest init --preset a1Dg5eFl

你可以用它从自定义配置脚手架项目、与团队共享,或者发布到你的 registry 中。把它放进提示词里,让你的代理知道从哪里开始。它也可以在 Claude、Codex、v0、Replit 之间通用。

切换预设

当你在处理新应用时,可能需要试几次才能找到喜欢的方案,所以我们把切换预设做得非常简单。只需在应用中运行 init --preset,CLI 就会帮你重新配置一切,包括组件。

pnpm dlx shadcn@latest init --preset ad3qkJ7

Skills + 预设

你的代理知道如何使用预设。你可以脚手架项目、切换设计系统、尝试新方案。

  • "create a new next app using --preset adtk27v"
  • "let's try --preset adtk27v"

全新的 shadcn/create

为了帮助你构建自定义预设,我们重建了 shadcn/create。它现在包含一个 UI 组件库,可用于预览你的预设。在开始构建之前,就能看到颜色、字体和圆角如何作用于真实组件。

新增 --dry-run--diff--view 参数

在任何内容写入之前,先检查 registry 会向你的项目添加什么。你可以自己查看负载,也可以把它传给编码代理再检查一次。

pnpm dlx shadcn@latest add button --dry-run
npx shadcn@latest add button --diff
npx shadcn@latest add button --view

更新 primitives

你可以使用 --diff 参数检查 registry 更新。或者让你的代理执行:“检查 @shadcn 的更新并与我的本地修改合并”。

pnpm dlx shadcn@latest add button --diff

shadcn init --template

shadcn init 现在可以为 Next.js、Vite、Laravel、React Router、Astro 和 TanStack Start 脚手架完整项目模板。Next.js 和 Vite 还包含深色模式。

pnpm dlx shadcn@latest init

Select a template › - Use arrow-keys. Return to submit.
❯ Next.js
  Vite
  TanStack Start
  React Router
  Astro
  Laravel

Use --monorepo to set up a monorepo.

pnpm dlx shadcn@latest init -t next --monorepo

shadcn init --base

选择你的 primitives。使用 --base 即可用 Radix 或 Base UI 启动项目。

pnpm dlx shadcn@latest init --base radix

shadcn info

info 命令现在会显示完整信息:框架、版本、CSS 变量、已安装哪些组件,以及每个组件的文档和示例在哪里。它非常适合为编码代理提供处理项目所需的上下文。

pnpm dlx shadcn@latest info

shadcn docs

直接从 CLI 获取任意 UI 组件的文档、代码和示例。它会给你的编码代理提供正确使用 primitives 所需的上下文。

pnpm dlx shadcn@latest docs combobox

combobox
  - docs      https://ui.shadcn.com/docs/components/radix/combobox
  - examples  https://raw.githubusercontent.com/shadcn-ui/ui/refs/heads/main/apps/v4/registry/bases/radix/examples/combobox-example.tsx
  - api       https://base-ui.com/react/components/combobox

registry:baseregistry:font

Registries 现在可以使用 registry:base 以单个载荷分发整个设计系统。组件、依赖、CSS 变量、字体、配置,一次安装全部就绪。

字体现在是一级 registry 类型。安装和配置字体的方式与安装组件相同。

font-inter.json
{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "font-inter",
  "type": "registry:font",
  "font": {
    "family": "'Inter Variable', sans-serif",
    "provider": "google",
    "import": "Inter",
    "variable": "--font-sans",
    "subsets": ["latin"]
  }
}
pnpm dlx shadcn@latest add font-inter

链接

2026 年 2 月 - 面向 Radix 和 Base UI 的 Blocks

所有 blocks 现在都同时提供 Radix 和 Base UI 版本。

  • 两套库的全部 blocks - 包括登录、注册、侧边栏和仪表盘在内的每个 block,现在都提供 Radix 和 Base UI 两个版本。
  • 相同的 CLI 工作流 - 运行 npx shadcn add,CLI 会根据你的项目配置拉取正确的 block 版本。

如果你已经通过 npx shadcn create 配置好了项目,blocks 会自动使用你选择的库,无需额外配置。

pnpm dlx shadcn@latest add login-01

blocks 页面浏览完整合集。

2026 年 2 月 - 统一的 Radix UI 包

new-york 样式现在使用统一的 radix-ui 包,而不是分别依赖多个 @radix-ui/react-* 包。

有什么变化

使用 new-york 样式添加组件时,现在会从 radix-ui 导入,而不是从独立包导入:

components/ui/dialog.tsx
- import * as DialogPrimitive from "@radix-ui/react-dialog"
+ import { Dialog as DialogPrimitive } from "radix-ui"

这样会让你的 package.json 更简洁,只保留一个 radix-ui 依赖,而不是多个 @radix-ui/react-* 包。

迁移现有项目

如果你有一个使用 new-york 样式的现有项目,可以使用 migrate 命令迁移到新的 radix-ui 包:

pnpm dlx shadcn@latest migrate radix

这会更新你 UI 组件中的所有导入,并把 radix-ui 添加到依赖中。

如果要迁移 ui 目录之外的组件,请使用 path 参数:

pnpm dlx shadcn@latest migrate radix src/components/custom

完成后,你可以从 package.json 中移除所有未使用的 @radix-ui/react-* 包。

更多细节请查看 migrate radix 文档

2026 年 1 月 - RTL 支持

shadcn/ui 现在对从右到左(RTL)布局提供一等公民级支持。你的组件会自动适配阿拉伯语、希伯来语和波斯语等语言。

这不仅适用于 shadcn/ui 组件,也适用于通过 shadcn registry 分发的任何组件。

"use client"

import * as React from "react"

我们对 RTL 的处理方式

传统上,支持 RTL 的组件库会直接把逻辑类内置进去。这意味着每个人都得使用 ms-4start-2 这样的类,即使他们只是在为 LTR 布局开发。

我们采用了不同的方法。shadcn CLI 会在安装时转换类,因此只有在真正需要时你才会看到逻辑类。如果你不是在构建 RTL 项目,你仍然可以使用 ml-4left-2 这样的熟悉类。启用 RTL 后,CLI 会帮你完成转换。

你不需要在真正需要之前就学习 RTL。

它是如何工作的

当你在 components.json 中把组件设置为 rtl: true 时,CLI 会自动把 ml-4text-left 这样的物理 CSS 类转换成 ms-4text-start 这样的逻辑等价类。

  • left-*right-* 这类物理定位类会变成 start-*end-*
  • ml-*pr-* 这类外边距与内边距类会变成 ms-*pe-*
  • text-left 这类文本对齐类会变成 text-start
  • 方向性属性会更新为逻辑值。
  • 支持的图标会通过 rtl:rotate-180 自动翻转。
  • slide-in-from-left 这类动画会变成 slide-in-from-start

每个组件的 RTL 示例

我们已经为每个组件添加了 RTL 示例。你可以在每个 组件页面 上找到实时预览和代码。

تسجيل الدخول إلى حسابك
أدخل بريدك الإلكتروني أدناه لتسجيل الدخول إلى حسابك
"use client"

import * as React from "react"

CLI 更新

新项目:在 initcreate 命令中使用 --rtl 参数,即可从一开始启用 RTL。

pnpm dlx shadcn@latest init --rtl
pnpm dlx shadcn@latest create --rtl

现有项目:使用 migrate rtl 命令迁移你的组件。

pnpm dlx shadcn@latest migrate rtl

这会把 ui 目录中的所有组件转换为使用逻辑类。你也可以传入具体路径或 glob 模式。

试试看

点击下面的链接,在 v0 中打开一个支持 RTL 的 Next.js 项目。

Open in v0

链接

2026 年 1 月 - Inline Start 和 End 样式

我们已经更新了 Base UI 组件的样式,以支持 inline-startinline-end 侧边值。以下组件现在都支持这些值:

  • Tooltip
  • Popover
  • Combobox
  • Context Menu
  • Dropdown Menu
  • Hover Card
  • Menubar
  • Select

有什么变化

我们添加了新的 Tailwind 类来处理这些逻辑侧边值:

<PopoverPrimitive.Popup
  className={cn(
    "... data-[side=bottom]:slide-in-from-top-2
    data-[side=left]:slide-in-from-right-2
    data-[side=right]:slide-in-from-left-2
    data-[side=top]:slide-in-from-bottom-2
+   data-[side=inline-start]:slide-in-from-right-2
+   data-[side=inline-end]:slide-in-from-left-2 ...",
    className
  )}
/>

用法

<Popover>
  <PopoverTrigger>Open</PopoverTrigger>
  <PopoverContent side="inline-start">
    {/* 在 LTR 中从左侧打开,在 RTL 中从右侧打开 */}
  </PopoverContent>
</Popover>

LLM 提示词

可以让你的 LLM 通过下面的提示词来更新组件:

Add inline-start and inline-end support to my shadcn/ui components. Add the following Tailwind classes to each component:
 
| File | Component | Add Classes |
|------|-----------|-------------|
| tooltip.tsx | TooltipContent | `data-[side=inline-start]:slide-in-from-right-2 data-[side=inline-end]:slide-in-from-left-2` |
| tooltip.tsx | TooltipArrow | `data-[side=inline-start]:top-1/2! data-[side=inline-start]:-right-1 data-[side=inline-start]:-translate-y-1/2
data-[side=inline-end]:top-1/2! data-[side=inline-end]:-left-1 data-[side=inline-end]:-translate-y-1/2` |
| popover.tsx | PopoverContent | `data-[side=inline-start]:slide-in-from-right-2 data-[side=inline-end]:slide-in-from-left-2` |
| hover-card.tsx | HoverCardContent | `data-[side=inline-start]:slide-in-from-right-2 data-[side=inline-end]:slide-in-from-left-2` |
| select.tsx | SelectContent | `data-[side=inline-start]:slide-in-from-right-2 data-[side=inline-end]:slide-in-from-left-2
data-[align-trigger=true]:animate-none` and add `data-align-trigger={alignItemWithTrigger}` attribute |
| combobox.tsx | ComboboxContent | `data-[side=inline-start]:slide-in-from-right-2 data-[side=inline-end]:slide-in-from-left-2` |
| dropdown-menu.tsx | DropdownMenuContent | `data-[side=inline-start]:slide-in-from-right-2 data-[side=inline-end]:slide-in-from-left-2` |
| context-menu.tsx | ContextMenuContent | `data-[side=inline-start]:slide-in-from-right-2 data-[side=inline-end]:slide-in-from-left-2` |
| menubar.tsx | MenubarContent | `data-[side=inline-start]:slide-in-from-right-2 data-[side=inline-end]:slide-in-from-left-2` |
 
将这些类添加到现有的 `data-[side=top]`、`data-[side=bottom]`、`data-[side=left]`、`data-[side=right]` 类旁边。