The user wants me to create a responsive component library using Tailwind CSS with reusable utility classes. This should be a comprehensive showcase of various UI components that can be reused.
Let me create a beautiful, modern component library with:
- Navigation components
- Button variations
- Card components
- Form elements
- Modal/Dialog
- Badges & Tags
- Alerts/Notifications
- Progress bars
- Tabs
- Accordion
- Dropdown menus
- Tooltips
I'll make it:
- Visually stunning with a cohesive design system
- Fully responsive
- Interactive with meaningful animations
- Use a distinctive color palette (not the default purple/blue gradient)
- Include at least 3 dynamic elements
Let me design this with a sophisticated dark theme with warm accent colors, maybe an amber/gold accent on dark slate background for a premium feel.
Tailwind CSS 组件库
我将创建一个精美的响应式组件库,展示各种可复用的 UI 组件。设计采用深色主题配合琥珀色强调色,营造高级感。
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Flux UI - 组件库</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
<script>
tailwind.config = {
theme: {
extend: {
fontFamily: {
display: ['Space Grotesk', 'sans-serif'],
mono: ['JetBrains Mono', 'monospace'],
},
colors: {
surface: {
50: '#1a1d23',
100: '#14161a',
200: '#0f1114',
300: '#0a0b0d',
},
accent: {
DEFAULT: '#f59e0b',
light: '#fbbf24',
dark: '#d97706',
muted: 'rgba(245, 158, 11, 0.15)',
},
stroke: {
DEFAULT: 'rgba(255, 255, 255, 0.08)',
light: 'rgba(255, 255, 255, 0.12)',
}
}
}
}
}
</script>
<style>
:root {
--bg: #0a0b0d;
--fg: #f4f4f5;
--muted: #71717a;
--accent: #f59e0b;
--card: #14161a;
--border: rgba(255, 255, 255, 0.08);
}
* {
box-sizing: border-box;
}
html {
scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
html {
scroll-behavior: auto;
}
*, *::before, *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}
body {
font-family: 'Space Grotesk', sans-serif;
background: var(--bg);
color: var(--fg);
}
/* Custom scrollbar */
::-webkit-scrollbar {
width: 8px;
height: 8px;
}
::-webkit-scrollbar-track {
background: var(--card);
}
::-webkit-scrollbar-thumb {
background: var(--border);
border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
background: rgba(255, 255, 255, 0.15);
}
/* Background pattern */
.bg-grid {
background-image:
linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
background-size: 50px 50px;
}
/* Glow effects */
.glow-accent {
box-shadow: 0 0 40px rgba(245, 158, 11, 0.15);
}
/* Animation keyframes */
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes shimmer {
0% { background-position: -200% 0; }
100% { background-position: 200% 0; }
}
@keyframes pulse-ring {
0% { transform: scale(0.95); opacity: 1; }
50% { transform: scale(1); opacity: 0.5; }
100% { transform: scale(0.95); opacity: 1; }
}
.animate-fade-in-up {
animation: fadeInUp 0.6s ease-out forwards;
}
.animate-shimmer {
background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.1) 50%, transparent 100%);
background-size: 200% 100%;
animation: shimmer 2s infinite;
}
/* Stagger delays */
.stagger-1 { animation-delay: 0.1s; }
.stagger-2 { animation-delay: 0.2s; }
.stagger-3 { animation-delay: 0.3s; }
.stagger-4 { animation-delay: 0.4s; }
/* Focus styles */
.focus-ring:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 2px;
}
/* Interactive states */
.btn-press:active {
transform: scale(0.97);
}
/* Card hover effect */
.card-hover {
transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}
.card-hover:hover {
transform: translateY(-4px);
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
border-color: rgba(255, 255, 255, 0.12);
}
/* Tab indicator */
.tab-indicator {
position: absolute;
bottom: 0;
height: 2px;
background: var(--accent);
transition: left 0.3s ease, width 0.3s ease;
}
/* Copy notification */
.copy-toast {
position: fixed;
bottom: 2rem;
left: 50%;
transform: translateX(-50%) translateY(100px);
opacity: 0;
transition: transform 0.3s ease, opacity 0.3s ease;
z-index: 100;
}
.copy-toast.show {
transform: translateX(-50%) translateY(0);
opacity: 1;
}
</style>
</head>
<body class="bg-grid min-h-screen">
<!-- Navigation -->
<nav class="fixed top-0 left-0 right-0 z-50 bg-surface-300/80 backdrop-blur-xl border-b border-stroke">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex items-center justify-between h-16">
<div class="flex items-center gap-2">
<div class="w-8 h-8 rounded-lg bg-accent flex items-center justify-center">
<svg class="w-5 h-5 text-surface-300" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z" />
</svg>
</div>
<span class="font-display font-semibold text-lg">Flux UI</span>
</div>
<div class="hidden md:flex items-center gap-1">
<a href="#buttons" class="nav-link px-3 py-2 rounded-lg text-sm text-zinc-400 hover:text-white hover:bg-white/5 transition-all focus-ring">按钮</a>
<a href="#cards" class="nav-link px-3 py-2 rounded-lg text-sm text-zinc-400 hover:text-white hover:bg-white/5 transition-all focus-ring">卡片</a>
<a href="#forms" class="nav-link px-3 py-2 rounded-lg text-sm text-zinc-400 hover:text-white hover:bg-white/5 transition-all focus-ring">表单</a>
<a href="#feedback" class="nav-link px-3 py-2 rounded-lg text-sm text-zinc-400 hover:text-white hover:bg-white/5 transition-all focus-ring">反馈</a>
<a href="#navigation" class="nav-link px-3 py-2 rounded-lg text-sm text-zinc-400 hover:text-white hover:bg-white/5 transition-all focus-ring">导航</a>
</div>
<button id="mobile-menu-btn" class="md:hidden p-2 rounded-lg hover:bg-white/5 transition-colors focus-ring" aria-label="打开菜单">
<svg class="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16" />
</svg>
</button>
</div>
</div>
<!-- Mobile menu -->
<div id="mobile-menu" class="md:hidden hidden border-t border-stroke">
<div class="px-4 py-3 space-y-1">
<a href="#buttons" class="block px-3 py-2 rounded-lg text-sm text-zinc-400 hover:text-white hover:bg-white/5">按钮</a>
<a href="#cards" class="block px-3 py-2 rounded-lg text-sm text-zinc-400 hover:text-white hover:bg-white/5">卡片</a>
<a href="#forms" class="block px-3 py-2 rounded-lg text-sm text-zinc-400 hover:text-white hover:bg-white/5">表单</a>
<a href="#feedback" class="block px-3 py-2 rounded-lg text-sm text-zinc-400 hover:text-white hover:bg-white/5">反馈</a>
<a href="#navigation" class="block px-3 py-2 rounded-lg text-sm text-zinc-400 hover:text-white hover:bg-white/5">导航</a>
</div>
</div>
</nav>
<!-- Hero Section -->
<header class="pt-32 pb-20 px-4 relative overflow-hidden">
<div class="absolute inset-0 pointer-events-none">
<div class="absolute top-1/4 left-1/4 w-96 h-96 bg-accent/10 rounded-full blur-3xl"></div>
<div class="absolute bottom-1/4 right-1/4 w-96 h-96 bg-accent/5 rounded-full blur-3xl"></div>
</div>
<div class="max-w-4xl mx-auto text-center relative">
<div class="inline-flex items-center gap-2 px-3 py-1.5 rounded-full bg-accent-muted border border-accent/20 text-accent text-sm mb-6 animate-fade-in-up">
<span class="w-1.5 h-1.5 rounded-full bg-accent animate-pulse"></span>
v2.0 全新发布
</div>
<h1 class="font-display text-4xl sm:text-5xl lg:text-6xl font-bold mb-6 animate-fade-in-up stagger-1 opacity-0">
构建现代化界面的
<span class="text-transparent bg-clip-text bg-gradient-to-r from-accent-light to-accent">组件库</span>
</h1>
<p class="text-lg text-zinc-400 max-w-2xl mx-auto mb-8 animate-fade-in-up stagger-2 opacity-0">
精心设计的响应式组件,基于 Tailwind CSS,支持深色主题,无障碍访问,开箱即用。
</p>
<div class="flex flex-col sm:flex-row items-center justify-center gap-4 animate-fade-in-up stagger-3 opacity-0">
<button class="w-full sm:w-auto px-6 py-3 bg-accent hover:bg-accent-light text-surface-300 font-medium rounded-xl transition-all btn-press focus-ring glow-accent">
快速开始
</button>
<button class="w-full sm:w-auto px-6 py-3 bg-white/5 hover:bg-white/10 border border-stroke hover:border-stroke-light font-medium rounded-xl transition-all btn-press focus-ring">
查看 GitHub
</button>
</div>
</div>
</header>
<main class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 pb-24">
<!-- Buttons Section -->
<section id="buttons" class="mb-24 scroll-mt-24">
<div class="mb-8">
<h2 class="font-display text-2xl font-semibold mb-2">按钮</h2>
<p class="text-zinc-400">多种风格的按钮组件,支持不同尺寸和状态</p>
</div>
<div class="grid gap-6">
<!-- Primary Buttons -->
<div class="bg-surface-100 rounded-2xl border border-stroke p-6">
<h3 class="text-sm font-medium text-zinc-400 mb-4">主要按钮</h3>
<div class="flex flex-wrap items-center gap-4">
<button class="px-5 py-2.5 bg-accent hover:bg-accent-light text-surface-300 font-medium rounded-lg transition-all btn-press focus-ring">
默认按钮
</button>
<button class="px-5 py-2.5 bg-accent/20 hover:bg-accent/30 text-accent border border-accent/30 font-medium rounded-lg transition-all btn-press focus-ring">
轮廓按钮
</button>
<button class="px-5 py-2.5 bg-transparent hover:bg-accent/10 text-accent font-medium rounded-lg transition-all btn-press focus-ring">
文字按钮
</button>
<button class="px-5 py-2.5 bg-gradient-to-r from-accent to-accent-dark hover:from-accent-light hover:to-accent text-surface-300 font-medium rounded-lg transition-all btn-press focus-ring">
渐变按钮
</button>
</div>
</div>
<!-- Button Sizes -->
<div class="bg-surface-100 rounded-2xl border border-stroke p-6">
<h3 class="text-sm font-medium text-zinc-400 mb-4">按钮尺寸</h3>
<div class="flex flex-wrap items-center gap-4">
<button class="px-3 py-1.5 bg-accent hover:bg-accent-light text-surface-300 text-sm font-medium rounded-md transition-all btn-press focus-ring">
小型
</button>
<button class="px-5 py-2.5 bg-accent hover:bg-accent-light text-surface-300 font-medium rounded-lg transition-all btn-press focus-ring">
中型
</button>
<button class="px-8 py-3.5 bg-accent hover:bg-accent-light text-surface-300 text-lg font-medium rounded-xl transition-all btn-press focus-ring">
大型
</button>
</div>
</div>
<!-- Button States -->
<div class="bg-surface-100 rounded-2xl border border-stroke p-6">
<h3 class="text-sm font-medium text-zinc-400 mb-4">按钮状态</h3>
<div class="flex flex-wrap items-center gap-4">
<button class="px-5 py-2.5 bg-accent text-surface-300 font-medium rounded-lg transition-all btn-press focus-ring">
正常
</button>
<button class="px-5 py-2.5 bg-accent/50 text-surface-300/70 font-medium rounded-lg cursor-not-allowed" disabled>
禁用
</button>
<button class="px-5 py-2.5 bg-accent text-surface-300 font-medium rounded-lg inline-flex items-center gap-2 transition-all btn-press focus-ring">
<svg class="w-4 h-4 animate-spin" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
加载中
</button>
<button class="px-5 py-2.5 bg-accent text-surface-300 font-medium rounded-lg inline-flex items-center gap-2 transition-all btn-press focus-ring">
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" />
</svg>
带图标
</button>
</div>
</div>
<!-- Icon Buttons -->
<div class="bg-surface-100 rounded-2xl border border-stroke p-6">
<h3 class="text-sm font-medium text-zinc-400 mb-4">图标按钮</h3>
<div class="flex flex-wrap items-center gap-4">
<button class="p-2.5 bg-accent hover:bg-accent-light text-surface-300 rounded-lg transition-all btn-press focus-ring" aria-label="添加">
<svg class="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4" />
</svg>
</button>
<button class="p-2.5 bg-white/5 hover:bg-white/10 border border-stroke hover:border-stroke-light rounded-lg transition-all btn-press focus-ring" aria-label="设置">
<svg class="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" />
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
</svg>
</button>
<button class="p-2.5 bg-white/5 hover:bg-red-500/20 border border-stroke hover:border-red-500/30 hover:text-red-400 rounded-lg transition-all btn-press focus-ring" aria-label="删除">
<svg class="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
</svg>
</button>
<button class="p-2.5 bg-white/5 hover:bg-green-500/20 border border-stroke hover:border-green-500/30 hover:text-green-400 rounded-lg transition-all btn-press focus-ring" aria-label="下载">
<svg class="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" />
</svg>
</button>
</div>
</div>
</div>
</section>
<!-- Cards Section -->
<section id="cards" class="mb-24 scroll-mt-24">
<div class="mb-8">
<h2 class="font-display text-2xl font-semibold mb-2">卡片</h2>
<p class="text-zinc-400">灵活的卡片组件,适合展示内容和数据</p>
</div>
<div class="grid sm:grid-cols-2 lg:grid-cols-3 gap-6">
<!-- Basic Card -->
<div class="bg-surface-100 rounded-2xl border border-stroke p-6 card-hover">
<div class="w-12 h-12 bg-accent/20 rounded-xl flex items-center justify-center mb-4">
<svg class="w-6 h-6 text-accent" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z" />
</svg>
</div>
<h3 class="font-semibold text-lg mb-2">快速响应</h3>
<p class="text-zinc-400 text-sm">使用 Tailwind CSS 构建,确保组件在任何设备上都能完美展示。</p>
</div>
<!-- Feature Card -->
<div class="bg-surface-100 rounded-2xl border border-stroke p-6 card-hover">
<div class="w-12 h-12 bg-green-500/20 rounded-xl flex items-center justify-center mb-4">
<svg class="w-6 h-6 text-green-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z" />
</svg>
</div>
<h3 class="font-semibold text-lg mb-2">类型安全</h3>
<p class="text-zinc-400 text-sm">完整的 TypeScript 类型定义,提供出色的开发体验。</p>
</div>
<!-- Accessible Card -->
<div class="bg-surface-100 rounded-2xl border border-stroke p-6 card-hover">
<div class="w-12 h-12 bg-blue-500/20 rounded-xl flex items-center justify-center mb-4">
<svg class="w-6 h-6 text-blue-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" />
</svg>
</div>
<h3 class="font-semibold text-lg mb-2">无障碍</h3>
<p class="text-zinc-400 text-sm">遵循 WCAG 标准,确保所有用户都能无障碍使用。</p>
</div>
<!-- Stats Card -->
<div class="sm:col-span-2 lg:col-span-3 bg-surface-100 rounded-2xl border border-stroke p-6">
<h3 class="text-sm font-medium text-zinc-400 mb-6">数据统计卡片</h3>
<div class="grid grid-cols-2 md:grid-cols-4 gap-6">
<div class="text-center">
<div class="text-3xl font-bold text-accent mb-1" data-counter="12847">0</div>
<div class="text-sm text-zinc-400">活跃用户</div>
</div>
<div class="text-center">
<div class="text-3xl font-bold text-green-400 mb-1" data-counter="98.5">0</div>
<div class="text-sm text-zinc-400">满意度 %</div>
</div>
<div class="text-center">
<div class="text-3xl font-bold text-blue-400 mb-1" data-counter="342">0</div>
<div class="text-sm text-zinc-400">组件数量</div>
</div>
<div class="text-center">
<div class="text-3xl font-bold text-purple-400 mb-1" data-counter="56">0</div>
<div class="text-sm text-zinc-400">贡献者</div>
</div>
</div>
</div>
<!-- Profile Card -->
<div class="bg-surface-100 rounded-2xl border border-stroke overflow-hidden card-hover">
<div class="h-20 bg-gradient-to-r from-accent/30 to-accent-dark/30"></div>
<div class="px-6 pb-6 -mt-10">
<img src="https://api.dicebear.com/7.x/avataaars/svg?seed=Felix" alt="头像" class="w-20 h-20 rounded-2xl border-4 border-surface-100 bg-surface-50 mb-4">
<h3 class="font-semibold text-lg">张明</h3>
<p class="text-zinc-400 text-sm mb-4">高级前端工程师</p>
<div class="flex gap-2">
<button class="flex-1 px-4 py-2 bg-accent hover:bg-accent-light text-surface-300 text-sm font-medium rounded-lg transition-all btn-press focus-ring">
关注
</button>
<button class="flex-1 px-4 py-2 bg-white/5 hover:bg-white/10 border border-stroke text-sm font-medium rounded-lg transition-all btn-press focus-ring">
消息
</button>
</div>
</div>
</div>
<!-- Pricing Card -->
<div class="bg-surface-100 rounded-2xl border border-stroke p-6 relative overflow-hidden card-hover">
<div class="absolute top-4 right-4 px-2 py-1 bg-accent/20 text-accent text-xs font-medium rounded-md">热门</div>
<h3 class="font-semibold text-lg mb-1">专业版</h3>
<p class="text-zinc-400 text-sm mb-4">适合中小型团队</p>
<div class="mb-6">
<span class="text-4xl font-bold">¥99</span>
<span class="text-zinc-400">/月</span>
</div>
<ul class="space-y-3 mb-6">
<li class="flex items-center gap-2 text-sm">
<svg class="w-4 h-4 text-green-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
</svg>
无限组件使用
</li>
<li class="flex items-center gap-2 text-sm">
<svg class="w-4 h-4 text-green-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
</svg>
优先技术支持
</li>
<li class="flex items-center gap-2 text-sm">
<svg class="w-4 h-4 text-green-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
</svg>
每月更新
</li>
</ul>
<button class="w-full px-4 py-2.5 bg-accent hover:bg-accent-light text-surface-300 font-medium rounded-lg transition-all btn-press focus-ring">
立即订阅
</button>
</div>
<!-- Code Card -->
<div class="bg-surface-100 rounded-2xl border border-stroke p-6 card-hover">
<div class="flex items-center justify-between mb-4">
<h3 class="font-semibold">代码示例</h3>
<button class="copy-btn p-2 hover:bg-white/5 rounded-lg transition-colors focus-ring" data-code="btn-primary" aria-label="复制代码">
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z" />
</svg>
</button>
</div>
<pre class="bg-surface-200 rounded-xl p-4 text-sm font-mono overflow-x-auto"><code class="text-zinc-300"><span class="text-purple-400"><button</span> <span class="text-blue-400">class</span>=<span class="text-green-400">"btn-primary"</span><span class="text-purple-400">></span>
点击我
<span class="text-purple-400"></button></span></code></pre>
</div>
</div>
</section>
<!-- Forms Section -->
<section id="forms" class="mb-24 scroll-mt-24">
<div class="mb-8">
<h2 class="font-display text-2xl font-semibold mb-2">表单</h2>
<p class="text-zinc-400">表单元素和输入组件</p>
</div>
<div class="grid lg:grid-cols-2 gap-6">
<!-- Input Fields -->
<div class="bg-surface-100 rounded-2xl border border-stroke p-6">
<h3 class="text-sm font-medium text-zinc-400 mb-4">输入框</h3>
<div class="space-y-4">
<div>
<label class="block text-sm font-medium mb-2" for="input-default">默认输入</label>
<input type="text" id="input-default" placeholder="请输入内容..." class="w-full px-4 py-2.5 bg-surface-200 border border-stroke rounded-xl text-white placeholder-zinc-500 focus:border-accent focus:ring-1 focus:ring-accent outline-none transition-all">
</div>
<div>
<label class="block text-sm font-medium mb-2" for="input-icon">带图标</label>
<div class="relative">
<svg class="absolute left-4 top-1/2 -translate-y-1/2 w-5 h-5 text-zinc-500" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
</svg>
<input type="text" id="input-icon" placeholder="搜索..." class="w-full pl-12 pr-4 py-2.5 bg-surface-200 border border-stroke rounded-xl text-white placeholder-zinc-500 focus:border-accent focus:ring-1 focus:ring-accent outline-none transition-all">
</div>
</div>
<div>
<label class="block text-sm font-medium mb-2" for="input-error">错误状态</label>
<input type="text" id="input-error" value="无效的邮箱地址" class="w-full px-4 py-2.5 bg-surface-200 border border-red-500/50 rounded-xl text-white focus:ring-1 focus:ring-red-500 outline-none transition-all">
<p class="mt-2 text-sm text-red-400">请输入有效的邮箱地址</p>
</div>
<div>
<label class="block text-sm font-medium mb-2" for="input-success">成功状态</label>
<div class="relative">
<input type="text" id="input-success" value="username" class="w-full px-4 py-2.5 bg-surface-200 border border-green-500/50 rounded-xl text-white focus:ring-1 focus:ring-green-500 outline-none transition-all pr-12">
<svg class="absolute right-4 top-1/2 -translate-y-1/2 w-5 h-5 text-green-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
</svg>
</div>
</div>
</div>
</div>
<!-- Other Form Elements -->
<div class="bg-surface-100 rounded-2xl border border-stroke p-6">
<h3 class="text-sm font-medium text-zinc-400 mb-4">其他表单元素</h3>
<div class="space-y-4">
<!-- Select -->
<div>
<label class="block text-sm font-medium mb-2">下拉选择</label>
<select class="w-full px-4 py-2.5 bg-surface-200 border border-stroke rounded-xl text-white appearance-none cursor-pointer focus:border-accent focus:ring-1 focus:ring-accent outline-none transition-all" style="background-image: url('data:image/svg+xml;utf8,<svg fill=\"white\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M7 10l5 5 5-5z\"/></svg>'); background-repeat: no-repeat; background-position: right 1rem center; background-size: 1.5rem;">
<option>请选择...</option>
<option>选项一</option>
<option>选项二</option>
<option>选项三</option>
</select>
</div>
<!-- Textarea -->
<div>
<label class="block text-sm font-medium mb-2" for="textarea">文本域</label>
<textarea id="textarea" rows="3" placeholder="请输入详细描述..." class="w-full px-4 py-2.5 bg-surface-200 border border-stroke rounded-xl text-white placeholder-zinc-500 focus:border-accent focus:ring-1 focus:ring-accent outline-none transition-all resize-none"></textarea>
</div>
<!-- Checkbox -->
<div class="flex items-center gap-3">
<input type="checkbox" id="checkbox" class="w-5 h-5 bg-surface-200 border border-stroke rounded-md text-accent focus:ring-accent focus:ring-offset-0 cursor-pointer">
<label for="checkbox" class="text-sm cursor-pointer">记住我的登录状态</label>
</div>
<!-- Toggle -->
<div class="flex items-center justify-between">
<span class="text-sm">深色模式</span>
<button id="toggle-btn" type="button" role="switch" aria-checked="true" class="toggle-switch relative w-12 h-6 bg-accent rounded-full transition-colors focus-ring">
<span class="toggle-dot absolute top-1 left-1 w-4 h-4 bg-white rounded-full transition-transform translate-x-6"></span>
</button>
</div>
<!-- Radio Group -->
<div>
<label class="block text-sm font-medium mb-3">选择方案</label>
<div class="flex flex-wrap gap-2">
<label class="cursor-pointer">
<input type="radio" name="plan" class="peer sr-only" checked>
<span class="inline-block px-4 py-2 bg-surface-200 border border-stroke rounded-lg text-sm peer-checked:border-accent peer-checked:text-accent transition-all">基础版</span>
</label>
<label class="cursor-pointer">
<input type="radio" name="plan" class="peer sr-only">
<span class="inline-block px-4 py-2 bg-surface-200 border border-stroke rounded-lg text-sm peer-checked:border-accent peer-checked:text-accent transition-all">专业版</span>
</label>
<label class="cursor-pointer">
<input type="radio" name="plan" class="peer sr-only">
<span class="inline-block px-4 py-2 bg-surface-200 border border-stroke rounded-lg text-sm peer-checked:border-accent peer-checked:text-accent transition-all">企业版</span>
</label>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- Feedback Section -->
<section id="feedback" class="mb-24 scroll-mt-24">
<div class="mb-8">
<h2 class="font-display text-2xl font-semibold mb-2">反馈</h2>
<p class="text-zinc-400">向用户提供操作反馈的组件</p>
</div>
<div class="grid gap-6">
<!-- Alerts -->
<div class="bg-surface-100 rounded-2xl border border-stroke p-6">
<h3 class="text-sm font-medium text-zinc-400 mb-4">提示框</h3>
<div class="space-y-3">
<div class="flex items-start gap-3 p-4 bg-blue-500/10 border border-blue-500/20 rounded-xl">
<svg class="w-5 h-5 text-blue-400 mt-0.5 flex-shrink-0" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
<div>
<p class="font-medium text-blue-400">提示信息</p>
<p class="text-sm text-blue-400/80">这是一条普通的提示信息。</p>
</div>
</div>
<div class="flex items-start gap-3 p-4 bg-green-500/10 border border-green-500/20 rounded-xl">
<svg class="w-5 h-5 text-green-400 mt-0.5 flex-shrink-0" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
<div>
<p class="font-medium text-green-400">操作成功</p>
<p class="text-sm text-green-400/80">您的更改已保存。</p>
</div>
</div>
<div class="flex items-start gap-3 p-4 bg-yellow-500/10 border border-yellow-500/20 rounded-xl">
<svg class="w-5 h-5 text-yellow-400 mt-0.5 flex-shrink-0" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
</svg>
<div>
<p class="font-medium text-yellow-400">警告</p>
<p class="text-sm text-yellow-400/80">您的存储空间即将用尽。</p>
</div>
</div>
<div class="flex items-start gap-3 p-4 bg-red-500/10 border border-red-500/20 rounded-xl">
<svg class="w-5 h-5 text-red-400 mt-0.5 flex-shrink-0" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
<div>
<p class="font-medium text-red-400">错误</p>
<p class="text-sm text-red-400/80">操作失败,请稍后重试。</p>
</div>
</div>
</div>
</div>
<!-- Badges & Tags -->
<div class="bg-surface-100 rounded-2xl border border-stroke p-6">
<h3 class="text-sm font-medium text-zinc-400 mb-4">徽章和标签</h3>
<div class="flex flex-wrap gap-3">
<span class="px-2.5 py-1 bg-accent/20 text-accent text-xs font-medium rounded-md">默认</span>
<span class="px-2.5 py-1 bg-green-500/20 text-green-400 text-xs font-medium rounded-md">成功</span>
<span class="px-2.5 py-1 bg-blue-500/20 text-blue-400 text-xs font-medium rounded-md">信息</span>
<span class="px-2.5 py-1 bg-yellow-500/20 text-yellow-400 text-xs font-medium rounded-md">警告</span>
<span class="px-2.5 py-1 bg-red-500/20 text-red-400 text-xs font-medium rounded-md">错误</span>
<span class="px-2.5 py-1 bg-purple-500/20 text-purple-400 text-xs font-medium rounded-md">紫色</span>
<span class="inline-flex items-center gap-1 px-2.5 py-1 bg-surface-200 text-zinc-300 text-xs rounded-md">
可关闭
<button class="hover:text-white transition-colors" aria-label="关闭">
<svg class="w-3 h-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
</svg>
</button>
</span>
</div>
</div>
<!-- Progress -->
<div class="bg-surface-100 rounded-2xl border border-stroke p-6">
<h3 class="text-sm font-medium text-zinc-400 mb-4">进度条</h3>
<div class="space-y-4">
<div>
<div class="flex justify-between text-sm mb-2">
<span>项目进度</span>
<span class="text-accent">75%</span>
</div>
<div class="h-2 bg-surface-200 rounded-full overflow-hidden">
<div class="h-full w-3/4 bg-gradient-to-r from-accent to-accent-light rounded-full transition-all duration-500"></div>
</div>
</div>
<div>
<div class="flex justify-between text-sm mb-2">
<span>存储空间</span>
<span class="text-green-400">45%</span>
</div>
<div class="h-2 bg-surface-200 rounded-full overflow-hidden">
<div class="h-full w-[45%] bg-green-500 rounded-full transition-all duration-500"></div>
</div>
</div>
<div>
<div class="flex justify-between text-sm mb-2">
<span>警告</span>
<span class="text-yellow-400">90%</span>
</div>
<div class="h-2 bg-surface-200 rounded-full overflow-hidden">
<div class="h-full w-[90%] bg-yellow-500 rounded-full transition-all duration-500"></div>
</div>
</div>
</div>
</div>
<!-- Skeleton Loading -->
<div class="bg-surface-100 rounded-2xl border border-stroke p-6">
<h3 class="text-sm font-medium text-zinc-400 mb-4">骨架屏加载</h3>
<div class="flex items-start gap-4">
<div class="w-12 h-12 bg-surface-200 rounded-xl animate-pulse"></div>
<div class="flex-1 space-y-2">
<div class="h-4 bg-surface-200 rounded w-1/3 animate-pulse"></div>
<div class="h-3 bg-surface-200 rounded w-full animate-pulse"></div>
<div class="h-3 bg-surface-200 rounded w-2/3 animate-pulse"></div>
</div>
</div>
</div>
</div>
</section>
<!-- Navigation Section -->
<section id="navigation" class="mb-24 scroll-mt-24">
<div class="mb-8">
<h2 class="font-display text-2xl font-semibold mb-2">导航</h2>
<p class="text-zinc-400">页面导航和菜单组件</p>
</div>
<div class="grid gap-6">
<!-- Tabs -->
<div class="bg-surface-100 rounded-2xl border border-stroke p-6">
<h3 class="text-sm font-medium text-zinc-400 mb-4">标签页</h3>
<div class="tabs-container" data-tabs>
<div class="flex border-b border-stroke relative" role="tablist">
<button class="tab-btn px-4 py-2 text-sm font-medium text-accent transition-colors focus-ring" role="tab" data-tab="tab1" aria-selected="true">概览</button>
<button class="tab-btn px-4 py-2 text-sm font-medium text-zinc-400 hover:text-white transition-colors focus-ring" role="tab" data-tab="tab2" aria-selected="false">分析</button>
<button class="tab-btn px-4 py-2 text-sm font-medium text-zinc-400 hover:text-white transition-colors focus-ring" role="tab" data-tab="tab3" aria-selected="false">报告</button>
<button class="tab-btn px-4 py-2 text-sm font-medium text-zinc-400 hover:text-white transition-colors focus-ring" role="tab" data-tab="tab4" aria-selected="false">设置</button>
<div class="tab-indicator" style="width: 48px; left: 16px;"></div>
</div>
<div class="pt-4">
<div class="tab-panel" data-panel="tab1">
<p class="text-zinc-400">这是概览页面的内容。您可以在这里查看项目的整体情况。</p>
</div>
<div class="tab-panel hidden" data-panel="tab2">
<p class="text-zinc-400">这是分析页面的内容。详细的数据分析报告将在这里展示。</p>
</div>
<div class="tab-panel hidden" data-panel="tab3">
<p class="text-zinc-400">这是报告页面的内容。您可以生成和下载各种报告。</p>
</div>
<div class="tab-panel hidden" data-panel="tab4">
<p class="text-zinc-400">这是设置页面的内容。在这里配置您的偏好设置。</p>
</div>
</div>
</div>
</div>
<!-- Breadcrumb -->
<div class="bg-surface-100 rounded-2xl border border-stroke p-6">
<h3 class="text-sm font-medium text-zinc-400 mb-4">面包屑</h3>
<nav class="flex items-center gap-2 text-sm" aria-label="面包屑导航">
<a href="#" class="text-zinc-400 hover:text-white transition-colors">首页</a>
<svg class="w-4 h-4 text-zinc-500" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" />
</svg>
<a href="#" class="text-zinc-400 hover:text-white transition-colors">组件</a>
<svg class="w-4 h-4 text-zinc-500" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" />
</svg>
<span class="text-accent">导航</span>
</nav>
</div>
<!-- Pagination -->
<div class="bg-surface-100 rounded-2xl border border-stroke p-6">
<h3 class="text-sm font-medium text-zinc-400 mb-4">分页</h3>
<nav class="flex items-center justify-center gap-1" aria-label="分页导航">
<button class="p-2 text-zinc-400 hover:text-white hover:bg-white/5 rounded-lg transition-colors focus-ring" aria-label="上一页">
<svg class="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7" />
</svg>
</button>
<button class="w-10 h-10 text-zinc-400 hover:text-white hover:bg-white/5 rounded-lg transition-colors focus-ring">1</button>
<button class="w-10 h-10 bg-accent text-surface-300 font-medium rounded-lg">2</button>
<button class="w-10 h-10 text-zinc-400 hover:text-white hover:bg-white/5 rounded-lg transition-colors focus-ring">3</button>
<span class="px-2 text-zinc-500">...</span>
<button class="w-10 h-10 text-zinc-400 hover:text-white hover:bg-white/5 rounded-lg transition-colors focus-ring">10</button>
<button class="p-2 text-zinc-400 hover:text-white hover:bg-white/5 rounded-lg transition-colors focus-ring" aria-label="下一页">
<svg class="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" />
</svg>
</button>
</nav>
</div>
<!-- Dropdown -->
<div class="bg-surface-100 rounded-2xl border border-stroke p-6">
<h3 class="text-sm font-medium text-zinc-400 mb-4">下拉菜单</h3>
<div class="flex flex-wrap gap-4">
<div class="relative" data-dropdown>
<button class="dropdown-trigger px-4 py-2.5 bg-white/5 hover:bg-white/10 border border-stroke rounded-xl inline-flex items-center gap-2 transition-all focus-ring">
选项菜单
<svg class="w-4 h-4 transition-transform" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
</svg>
</button>
<div class="dropdown-menu absolute top-full left-0 mt-2 w-48 bg-surface-50 border border-stroke rounded-xl shadow-xl opacity-0 invisible translate-y-2 transition-all z-20">
<div class="p-1">
<button class="w-full px-3 py-2 text-left text-sm hover:bg-white/5 rounded-lg transition-colors flex items-center gap-2">
<svg class="w-4 h-4 text-zinc-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" />
</svg>
个人资料
</button>
<button class="w-full px-3 py-2 text-left text-sm hover:bg-white/5 rounded-lg transition-colors flex items-center gap-2">
<svg class="w-4 h-4 text-zinc-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" />
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
</svg>
设置
</button>
<div class="my-1 border-t border-stroke"></div>
<button class="w-full px-3 py-2 text-left text-sm text-red-400 hover:bg-red-500/10 rounded-lg transition-colors flex items-center gap-2">
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1" />
</svg>
退出登录
</button>
</div>
</div>
</div>
</div>
</div>
<!-- Accordion -->
<div class="bg-surface-100 rounded-2xl border border-stroke p-6">
<h3 class="text-sm font-medium text-zinc-400 mb-4">手风琴</h3>
<div class="space-y-2" data-accordion>
<div class="accordion-item border border-stroke rounded-xl overflow-hidden">
<button class="accordion-trigger w-full px-4 py-3 flex items-center justify-between bg-surface-200 hover:bg-surface-50 transition-colors focus-ring" aria-expanded="true">
<span class="font-medium">什么是 Flux UI?</span>
<svg class="accordion-icon w-5 h-5 text-zinc-400 transition-transform rotate-180" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
</svg>
</button>
<div class="accordion-content px-4 py-3 bg-surface-50 border-t border-stroke">
<p class="text-zinc-400 text-sm">Flux UI 是一个基于 Tailwind CSS 构建的现代化组件库,提供丰富的可复用组件,帮助您快速构建美观的用户界面。</p>
</div>
</div>
<div class="accordion-item border border-stroke rounded-xl overflow-hidden">
<button class="accordion-trigger w-full px-4 py-3 flex items-center justify-between bg-surface-200 hover:bg-surface-50 transition-colors focus-ring" aria-expanded="false">
<span class="font-medium">如何安装使用?</span>
<svg class="accordion-icon w-5 h-5 text-zinc-400 transition-transform" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
</svg>
</button>
<div class="accordion-content hidden px-4 py-3 bg-surface-50 border-t border-stroke">
<p class="text-zinc-400 text-sm">您可以通过 npm 安装 Flux UI,或者直接复制组件代码到您的项目中。所有组件都是独立的,无需额外依赖。</p>
</div>
</div>
<div class="accordion-item border border-stroke rounded-xl overflow-hidden">
<button class="accordion-trigger w-full px-4 py-3 flex items-center justify-between bg-surface-200 hover:bg-surface-50 transition-colors focus-ring" aria-expanded="false">
<span class="font-medium">是否支持自定义主题?</span>
<svg class="accordion-icon w-5 h-5 text-zinc-400 transition-transform" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
</svg>
</button>
<div class="accordion-content hidden px-4 py-3 bg-surface-50 border-t border-stroke">
<p class="text-zinc-400 text-sm">是的!Flux UI 完全基于 Tailwind CSS 构建,您可以通过修改 Tailwind 配置文件轻松自定义颜色、字体、间距等所有设计标记。</p>
</div>
</div>
</div>
</div>
</div>
</section>
</main>
<!-- Footer -->
<footer class="border-t border-stroke py-8">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex flex-col md:flex-row items-center justify-between gap-4">
<div class="flex items-center gap-2">
<div class="w-6 h-6 rounded bg-accent flex items-center justify-center">
<svg class="w-4 h-4 text-surface-300" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z" />
</svg>
</div>
<span class="font-display font-medium">Flux UI</span>
</div>
<p class="text-sm text-zinc-500">使用 Tailwind CSS 构建,专注于用户体验</p>
</div>
</div>
</footer>
<!-- Copy Toast -->
<div class="copy-toast px-4 py-2 bg-green-500 text-white rounded-lg shadow-lg flex items-center gap-2">
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
</svg>
已复制到剪贴板
</div>
<script>
// Initialize after DOM is ready
document.addEventListener('DOMContentLoaded', function() {
// Mobile menu toggle
const mobileMenuBtn = document.getElementById('mobile-menu-btn');
const mobileMenu = document.getElementById('mobile-menu');
if (mobileMenuBtn && mobileMenu) {
mobileMenuBtn.addEventListener('click', function() {
mobileMenu.classList.toggle('hidden');
});
// Close mobile menu when clicking a link
mobileMenu.querySelectorAll('a').forEach(function(link) {
link.addEventListener('click', function() {
mobileMenu.classList.add('hidden');
});
});
}
// Toggle switch
const toggleBtn = document.getElementById('toggle-btn');
if (toggleBtn) {
toggleBtn.addEventListener('click', function() {
const dot = toggleBtn.querySelector('.toggle-dot');
const isChecked = toggleBtn.getAttribute('aria-checked') === 'true';
toggleBtn.setAttribute('aria-checked', (!isChecked).toString());
if (isChecked) {
toggleBtn.classList.remove('bg-accent');
toggleBtn.classList.add('bg-surface-200');
dot.classList.remove('translate-x-6');
} else {
toggleBtn.classList.remove('bg-surface-200');
toggleBtn.classList.add('bg-accent');
dot.classList.add('translate-x-6');
}
});
}
// Tabs functionality
const tabsContainers = document.querySelectorAll('[data-tabs]');
tabsContainers.forEach(function(container) {
const tabs = container.querySelectorAll('.tab-btn');
const panels = container.querySelectorAll('.tab-panel');
const indicator = container.querySelector('.tab-indicator');
function updateIndicator(tab) {
if (indicator && tab) {
indicator.style.width = tab.offsetWidth + 'px';
indicator.style.left = tab.offsetLeft + 'px';
}
}
tabs.forEach(function(tab) {
tab.addEventListener('click', function() {
const targetId = tab.dataset.tab;
// Update tabs
tabs.forEach(function(t) {
t.classList.remove('text-accent');
t.classList.add('text-zinc-400');
t.setAttribute('aria-selected', 'false');
});
tab.classList.remove('text-zinc-400');
tab.classList.add('text-accent');
tab.setAttribute('aria-selected', 'true');
// Update panels
panels.forEach(function(panel) {
if (panel.dataset.panel === targetId) {
panel.classList.remove('hidden');
} else {
panel.classList.add('hidden');
}
});
updateIndicator(tab);
});
});
// Initialize indicator
const activeTab = container.querySelector('.tab-btn[aria-selected="true"]');
updateIndicator(activeTab);
});
// Dropdown functionality
const dropdowns = document.querySelectorAll('[data-dropdown]');
dropdowns.forEach(function(dropdown) {
const trigger = dropdown.querySelector('.dropdown-trigger');
const menu = dropdown.querySelector('.dropdown-menu');
const icon = trigger ? trigger.querySelector('svg') : null;
if (trigger && menu) {
trigger.addEventListener('click', function(e) {
e.stopPropagation();
const isOpen = menu.classList.contains('opacity-100');
// Close all other dropdowns
document.querySelectorAll('.dropdown-menu').forEach(function(m) {
m.classList.remove('opacity-100', 'visible', 'translate-y-0');
m.classList.add('opacity-0', 'invisible', 'translate-y-2');
});
document.querySelectorAll('.dropdown-trigger svg').forEach(function(i) {
if (i) i.classList.remove('rotate-180');
});
if (!isOpen) {
menu.classList.remove('opacity-0', 'invisible', 'translate-y-2');
menu.classList.add('opacity-100', 'visible', 'translate-y-0');
if (icon) icon.classList.add('rotate-180');
}
});
}
});
// Close dropdowns on outside click
document.addEventListener('click', function() {
document.querySelectorAll('.dropdown-menu').forEach(function(menu) {
menu.classList.remove('opacity-100', 'visible', 'translate-y-0');
menu.classList.add('opacity-0', 'invisible', 'translate-y-2');
});
document.querySelectorAll('.dropdown-trigger svg').forEach(function(icon) {
if (icon) icon.classList.remove('rotate-180');
});
});
// Accordion functionality
const accordions = document.querySelectorAll('[data-accordion]');
accordions.forEach(function(accordion) {
const items = accordion.querySelectorAll('.accordion-item');
items.forEach(function(item) {
const trigger = item.querySelector('.accordion-trigger');
const content = item.querySelector('.accordion-content');
const icon = item.querySelector('.accordion-icon');
if (trigger && content) {
trigger.addEventListener('click', function() {
const isOpen = trigger.getAttribute('aria-expanded') === 'true';
// Toggle current
trigger.setAttribute('aria-expanded', (!isOpen).toString());
if (isOpen) {
content.classList.add('hidden');
if (icon) icon.classList.remove('rotate-180');
} else {
content.classList.remove('hidden');
if (icon) icon.classList.add('rotate-180');
}
});
}
});
});
// Counter animation
const counters = document.querySelectorAll('[data-counter]');
const observerOptions = {
threshold: 0.5
};
const counterObserver = new IntersectionObserver(function(entries) {
entries.forEach(function(entry) {
if (entry.isIntersecting) {
const counter = entry.target;
const target = parseFloat(counter.dataset.counter);
const isDecimal = target % 1 !== 0;
const duration = 2000;
const startTime = performance.now();
function animate(currentTime) {
const elapsed = currentTime - startTime;
const progress = Math.min(elapsed / duration, 1);
// Easing function
const easeOutQuart = 1 - Math.pow(1 - progress, 4);
const current = target * easeOutQuart;
if (isDecimal) {
counter.textContent = current.toFixed(1);
} else {
counter.textContent = Math.floor(current).toLocaleString();
}
if (progress < 1) {
requestAnimationFrame(animate);
}
}
requestAnimationFrame(animate);
counterObserver.unobserve(counter);
}
});
}, observerOptions);
counters.forEach(function(counter) {
counterObserver.observe(counter);
});
// Copy button functionality
const copyBtns = document.querySelectorAll('.copy-btn');
const copyToast = document.querySelector('.copy-toast');
copyBtns.forEach(function(btn) {
btn.addEventListener('click', function() {
// Show toast
if (copyToast) {
copyToast.classList.add('show');
setTimeout(function() {
copyToast.classList.remove('show');
}, 2000);
}
});
});
// Scroll reveal animation
const revealElements = document.querySelectorAll('section');
const revealObserver = new IntersectionObserver(function(entries) {
entries.forEach(function(entry) {
if (entry.isIntersecting) {
entry.target.classList.add('animate-fade-in-up');
entry.target.style.opacity = '1';
}
});
}, {
threshold: 0.1
});
revealElements.forEach(function(el) {
el.style.opacity = '0';
revealObserver.observe(el);
});
// Smooth scroll for navigation links
document.querySelectorAll('a[href^="#"]').forEach(function(anchor) {
anchor.addEventListener('click', function(e) {
const href = this.getAttribute('href');
if (href && href !== '#') {
e.preventDefault();
const target = document.querySelector(href);
if (target) {
target.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
}
});
});
});
</script>
</body>
</html>
设计说明
设计理念
- 深色主题:采用深灰/炭黑色背景配合琥珀色强调色,营造高级、现代的视觉感受
- 一致的圆角和阴影:统一使用
rounded-xl/2xl 圆角和微妙的边框
- 层次分明:通过不同深度的背景色区分组件层级
包含的组件
- 按钮 - 主要、轮廓、文字、渐变、图标、加载状态等多种变体
- 卡片 - 基础卡片、数据统计、个人资料、定价卡片
- 表单 - 输入框、下拉选择、复选框、开关、单选组
- 反馈 - 提示框、徽章、进度条、骨架屏
- 导航 - 标签页、面包屑、分页、下拉菜单、手风琴
交互特性
- 标签页切换带滑动指示器动画
- 下拉菜单平滑展开/收起
- 数字计数器滚动动画
- 卡片悬停抬起效果
- 响应式移动端菜单
- 无障碍访问支持(ARIA 标签、键盘导航、焦点状态)