# 组件库 ## 一句话概述 **基于 Radix UI 原语和 Tailwind CSS 构建的可复用 UI 组件综合集合,遵循 shadcn/ui 模式,提供一致、可访问和可定制的界面。** --- ## 概述 **位置**: `ccw/frontend/src/components/ui/` **用途**: 为构建 CCW 前端应用程序提供一致的 UI 组件集合。 **技术栈**: - **Radix UI**: 无样式、可访问的组件原语 - **Tailwind CSS**: 带自定义主题的实用优先样式 - **class-variance-authority (CVA)**: 类型安全的变体 props 管理 - **Lucide React**: 一致的图标系统 --- ## 实时演示:组件库展示 :::demo ComponentGallery # component-gallery.tsx /** * 组件库展示演示 * 所有 UI 组件的交互式展示 */ export function ComponentGallery() { const [selectedCategory, setSelectedCategory] = React.useState('all') const [buttonVariant, setButtonVariant] = React.useState('default') const [switchState, setSwitchState] = React.useState(false) const [checkboxState, setCheckboxState] = React.useState(false) const [selectedTab, setSelectedTab] = React.useState('variants') const categories = [ { id: 'all', label: '全部组件' }, { id: 'buttons', label: '按钮' }, { id: 'forms', label: '表单' }, { id: 'feedback', label: '反馈' }, { id: 'navigation', label: '导航' }, { id: 'overlays', label: '叠加层' }, ] const components = { buttons: [ { name: 'Button', variants: ['default', 'destructive', 'outline', 'secondary', 'ghost', 'link', 'gradient'] }, ], forms: [ { name: 'Input', type: 'text' }, { name: 'Textarea', type: 'textarea' }, { name: 'Select', type: 'select' }, { name: 'Checkbox', type: 'checkbox' }, { name: 'Switch', type: 'switch' }, ], feedback: [ { name: 'Badge', variants: ['default', 'secondary', 'success', 'warning', 'destructive'] }, { name: 'Progress', type: 'progress' }, { name: 'Alert', type: 'alert' }, ], navigation: [ { name: 'Tabs', type: 'tabs' }, { name: 'Breadcrumb', type: 'breadcrumb' }, ], overlays: [ { name: 'Dialog', type: 'dialog' }, { name: 'Drawer', type: 'drawer' }, { name: 'Dropdown', type: 'dropdown' }, ], } const buttonVariants = ['default', 'destructive', 'outline', 'secondary', 'ghost', 'link'] return (
{/* 标题 */}

UI 组件库

所有可用 UI 组件的交互式展示

{/* 分类过滤 */}
{categories.map((cat) => ( ))}
{/* 按钮部分 */} {(selectedCategory === 'all' || selectedCategory === 'buttons') && (

按钮

{/* 变体选择器 */}
{buttonVariants.map((variant) => ( ))}
{/* 按钮尺寸 */}
{/* 所有按钮变体 */}
)} {/* 表单部分 */} {(selectedCategory === 'all' || selectedCategory === 'forms') && (

表单组件

{/* 输入框 */}
{/* 文本区域 */}