pick-ui-library

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Picking The Right Library

挑选合适的前端库

A lookup skill. When invoked with a task ("I need toasts", "what should I use for drag and drop?"), match the task to the curated list below and recommend the library. These are deliberate, taste-driven picks — don't substitute alternatives outside this list unless the user asks for one or the task genuinely isn't covered.
这是一个查询类技能。当用户给出任务(如“我需要消息提示组件”、“拖拽功能应该用什么库?”)时,将任务与下方的精选列表匹配并推荐对应的库。这些推荐是经过审慎选择、带有主观偏好的——除非用户要求替代方案或任务确实未被列表覆盖,否则不要推荐列表外的其他库。

How to use this

使用方法

  1. Identify the task, not the library the user named. "I need to show a dropdown" is a UI-primitives task (base-ui), even if they asked about something else.
  2. Check what's already installed. Look at
    package.json
    first. If the project already uses a listed library, use it. If it uses a competitor (e.g. react-window instead of Virtuoso), flag the recommendation but don't churn the dependency without being asked.
  3. Recommend one library, state what it's for in one sentence, and install/wire it up if that's part of the request. Don't present a menu of options when the list has a clear answer.
  4. If the task isn't covered by the list, say so explicitly and recommend from your own knowledge — but be clear you've left the curated list.
  1. 明确任务类型,而非用户提到的库。例如,“我需要展示下拉菜单”属于UI基础组件任务(应推荐base-ui),即便用户提到了其他库。
  2. 检查已安装的库。先查看
    package.json
    。如果项目已使用列表中的某个库,就继续使用该库。如果项目使用了竞品(如用react-window而非Virtuoso),需在推荐时说明这一点,但未经用户请求不要更换依赖。
  3. 仅推荐一个库,用一句话说明其用途,如果用户要求,可协助安装和配置。当列表中有明确答案时,不要提供多个选项。
  4. 如果任务未被列表覆盖,需明确告知用户,并根据自身知识推荐,但要说明已超出精选列表范围。

The list

精选列表

UI components & primitives

UI组件与基础组件

TaskLibrary
Unstyled, accessible UI components (dialogs, popovers, menus, selects…)base-ui
Command menus (⌘K palettes)cmdk
Toasts / notificationsSonner
One-time password / verification code inputsinput-otp
Customizable GUIs / control panelsLevadialkit is an alternative
任务
无样式、可访问的UI组件(对话框、弹出层、菜单、选择器等)base-ui
命令菜单(⌘K面板)cmdk
消息提示/通知Sonner
一次性密码/验证码输入框input-otp
可自定义的GUI/控制面板Levadialkit 是替代方案

Motion & visuals

动效与视觉效果

TaskLibrary
General-purpose animation (springs, layout animations, enter/exit)motion (Framer Motion)
Animating numbers (counters, prices, stats)NumberFlow
Animated text componentstorph
3D globesCobe
Dynamic OG images (HTML/CSS → SVG/PNG)Satori
Syntax highlightingshiki
Reach for motion when you need springs, layout animations, exit animations, or gesture-driven values. A simple hover or fade doesn't need it — plain CSS transitions are the right tool there.
任务
通用动画(弹簧动画、布局动画、入场/退场动画)motion (Framer Motion)
数字动画(计数器、价格、统计数据)NumberFlow
动画文本组件torph
3D地球组件Cobe
动态OG图片(HTML/CSS → SVG/PNG)Satori
语法高亮shiki
当你需要弹簧动画、布局动画、退场动画或手势驱动的数值动画时,选择motion。简单的悬停或淡入淡出效果不需要它——纯CSS过渡是更合适的工具。

Charts

图表

TaskLibrary
Real-time / streaming chartsLiveline
General charts (static or interactive dashboards)recharts
The split: if data points arrive live and the chart scrolls with time, use Liveline. Everything else is recharts.
任务
实时/流式图表Liveline
通用图表(静态或交互式仪表盘)recharts
区分标准:如果数据点实时更新且图表随时间滚动,使用Liveline。其他所有场景都使用recharts。

Interaction & performance

交互与性能

TaskLibrary
Drag and dropdnd kit
Virtualization (long lists, large tables)Virtuoso
任务
拖拽功能dnd kit
虚拟化(长列表、大型表格)Virtuoso

State & styling

状态管理与样式处理

TaskLibrary
State managementzustand
Constructing
className
strings conditionally
clsx
Type-safe, variant-driven styling for Tailwindcva
Theme switching / dark mode (no flash on load)next-themes
The styling split: clsx for ad-hoc conditional classes; cva when a component has real variants (size, intent, state) that deserve a typed API. They compose — cva uses clsx-style inputs internally.
任务
状态管理zustand
条件拼接
className
字符串
clsx
Tailwind的类型安全、变体驱动样式工具cva
主题切换/暗黑模式(加载无闪烁)next-themes
样式工具区分:clsx用于临时条件类;当组件有明确的变体(尺寸、用途、状态)且需要类型化API时,使用cva。二者可以组合使用——cva内部采用clsx风格的输入方式。

Common mismatches to catch

需要注意的常见错误匹配

  • Toasts built by hand or with a modal library → Sonner exists for exactly this.
  • A
    <div>
    -based dropdown/dialog with manual focus handling
    → base-ui, which handles accessibility, focus trapping, and dismissal.
  • Animating a number by re-rendering text → NumberFlow handles digit transitions properly.
  • Rendering a 1,000+ row list directly → Virtuoso before reaching for pagination hacks.
  • A
    useState
    -per-component web of props for shared state
    → zustand.
  • Template-literal className ternaries three conditions deep → clsx (or cva if it's variant-shaped).
  • 手动实现消息提示或使用模态框库 → Sonner正是为此场景设计的。
  • 基于
    <div>
    的下拉菜单/对话框,手动处理焦点
    → 使用base-ui,它会处理可访问性、焦点捕获和关闭逻辑。
  • 通过重新渲染文本实现数字动画 → NumberFlow能正确处理数字过渡效果。
  • 直接渲染1000+行的列表 → 优先使用Virtuoso,而非分页技巧。
  • 每个组件用
    useState
    来维护共享状态,导致props层层传递
    → 使用zustand。
  • 三层条件判断的模板字符串className → 使用clsx(如果是变体样式则用cva)。