===============
LIBRARY RULES
===============
- Use 'variant' prop instead of 'type' for AlertGlass and NotificationGlass (v1.0 breaking change)
- Use 'variant="destructive"' instead of 'variant="danger"' for ButtonGlass
- Always wrap components with ThemeProvider from 'shadcn-glass-ui'
- Import CSS: '@import "shadcn-glass-ui/dist/styles.css"' in main CSS file
- Use TypeScript strict mode - no 'any' types allowed
- ModalGlass and TabsGlass use compound component API (e.g., ModalGlass.Root, ModalGlass.Content)
- Three themes available: 'glass' (dark), 'light', 'aurora' (gradient)
- WCAG 2.1 AA accessibility compliance required
- Use asChild prop on ButtonGlass for polymorphic rendering: Home
- Combine FormFieldWrapper with InputGlass for consistent form validation feedback
- Use ComboBoxGlass instead of SelectGlass for searchable dropdowns (SelectGlass removed in v1.0)
- For forms with validation, use InputGlass error/success props: or
- Use SegmentedControlGlass for exclusive selection (like radio buttons but glass-styled)
- Test all components with 3 themes before shipping: glass (dark), light, aurora
- Use CSS variables from glass-theme.css for custom styling: --glass-bg, --blur-md, --focus-glow
- Prefer GlassCard intensity variants (subtle, medium, strong) for different visual depths
- Use TooltipGlass with aria-label on icon buttons for screen reader support
- ExpandableHeaderGlass has built-in ARIA attributes for accessible expandable sections
- Memoize ComboBoxGlass options array with useMemo to prevent unnecessary re-renders
- RainbowProgressGlass uses GPU-optimized animations with will-change for smooth performance
# shadcn-glass-ui Component Library
shadcn-glass-ui is a production-ready glassmorphism UI component library for React applications. Built with React 19.2, TypeScript 5.9, and Tailwind CSS 4.1, it provides 58 components with strict accessibility compliance (WCAG 2.1 AA), three built-in themes, and comprehensive visual regression testing. The library is optimized for AI coding assistants with rich JSDoc documentation and supports both npm package installation and shadcn CLI registry installation.
The library features a multi-tier component architecture: 18 core UI primitives (buttons, inputs, cards), 7 atomic components (specialized single-purpose elements), 9 specialized components (progress bars, status indicators), 13 composite components (pre-built complex widgets), and 7 full-page sections. It implements advanced patterns including compound components (Modal, Tabs, Stepper), polymorphic rendering via the asChild pattern, and touch-optimized interactions with 44×44px minimum touch targets. The design system is powered by a 3-layer CSS token architecture with 207 OKLCH primitive tokens, enabling 15-minute theme creation (90% faster than v1.x).
## Installation and Setup
### Install via npm package
```bash
npm install shadcn-glass-ui
# Peer dependencies (React 18+ or 19+, Tailwind CSS 4+)
npm install react react-dom tailwindcss
```
### Install via shadcn CLI (recommended)
```json
// components.json
{
"registries": {
"@shadcn-glass-ui": {
"url": "https://raw.githubusercontent.com/Yhooi2/shadcn-glass-ui-library/main/public/r"
}
}
}
```
```bash
# Install single component with dependencies
npx shadcn@latest add @shadcn-glass-ui/button-glass --deps
# Install multiple components
npx shadcn@latest add @shadcn-glass-ui/button-glass @shadcn-glass-ui/input-glass @shadcn-glass-ui/modal-glass
# Install new StepperGlass component (v2.0.0+)
npx shadcn@latest add @shadcn-glass-ui/stepper-glass
```
### Basic setup with theme provider
```tsx
import { ThemeProvider, ButtonGlass, InputGlass } from 'shadcn-glass-ui';
import 'shadcn-glass-ui/dist/styles.css';
function App() {
return (
Click me
);
}
export default App;
```
## Theme Management
### ThemeProvider component
```tsx
import { ThemeProvider, useTheme } from 'shadcn-glass-ui';
// Wrap your app with ThemeProvider
function Root() {
return (
);
}
// Access theme context in child components
function ThemeSwitcher() {
const { theme, setTheme, cycleTheme } = useTheme();
return (
Current theme: {theme}
{/* Direct theme selection */}
{/* Cycle through themes */}
);
}
```
### Theme types and configuration
```tsx
import { THEMES, THEME_CONFIG, getNextTheme } from 'shadcn-glass-ui';
// Available themes: "light" | "aurora" | "glass"
const allThemes = THEMES; // ["light", "aurora", "glass"]
// Get theme configuration with icon
const glassConfig = THEME_CONFIG.glass;
// { label: "Glass", icon: Palette }
// Programmatically get next theme
const currentTheme = "glass";
const nextTheme = getNextTheme(currentTheme); // "light"
```
## Core UI Components
### ButtonGlass with variants and loading state
```tsx
import { ButtonGlass } from 'shadcn-glass-ui';
import { Check, X, Mail } from 'lucide-react';
import { Link } from 'react-router-dom';
function ButtonExamples() {
const [loading, setLoading] = useState(false);
const handleSubmit = async () => {
setLoading(true);
try {
await submitForm();
} finally {
setLoading(false);
}
};
return (
{/* Variants */}
Primary Action
SecondaryGhost ButtonDeleteConfirm
{/* With icons */}
Save Changes
Send Email
{/* Icon-only button (requires aria-label) */}
{/* Loading state */}
{loading ? 'Processing...' : 'Submit'}
{/* Polymorphic rendering with asChild */}
Go to Dashboard
{/* As anchor tag */}
External Link
{/* Form submit button */}
);
}
```
### InputGlass with validation and icons
```tsx
import { InputGlass } from 'shadcn-glass-ui';
import { Search, Mail, Lock, Eye, EyeOff } from 'lucide-react';
function FormExample() {
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const [showPassword, setShowPassword] = useState(false);
const [errors, setErrors] = useState>({});
const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();
const newErrors: Record = {};
if (!email) newErrors.email = 'Email is required';
if (!password) newErrors.password = 'Password is required';
if (password.length < 8) newErrors.password = 'Password must be 8+ characters';
setErrors(newErrors);
};
return (
);
}
```
### GlassCard with intensity levels
```tsx
import { GlassCard } from 'shadcn-glass-ui';
function CardExamples() {
return (
{/* Subtle glass effect (8px blur) */}
Subtle Card
Light glass effect for subtle emphasis
{/* Standard glassmorphism (16px blur - default) */}
Standard Card
Default glassmorphism effect
{/* Strong glass effect (24px blur) */}
Featured Card
Prominent glass effect for featured content
{/* Polymorphic rendering */}
Article Title
Article content with semantic HTML
{/* Interactive card with hover effects */}
Clickable Card
Hover for interaction
);
}
```
## Compound Components
### StepperGlass - Multi-step workflows (NEW in v2.0.0)
```tsx
import { StepperGlass, ButtonGlass } from 'shadcn-glass-ui';
import { User, Mail, Check } from 'lucide-react';
import { useState } from 'react';
function RegistrationWizard() {
const [currentStep, setCurrentStep] = useState('account');
return (
);
}
```
### useWallpaperTint for adaptive theming (NEW in v2.0.0)
```tsx
import { useWallpaperTint } from 'shadcn-glass-ui';
function AdaptiveBackground() {
const { tint, isDark, isLight } = useWallpaperTint();
return (
Background adapts to wallpaper
Detected tint: {tint}
);
}
// Conditional rendering based on wallpaper
function ThemedContent() {
const { isDark } = useWallpaperTint();
return isDark ? : ;
}
```
## Utility Functions and Primitives
### cn() utility for className merging
```tsx
import { cn } from 'shadcn-glass-ui';
// Merge conditional classes with Tailwind conflict resolution
function Component({ isActive, className }) {
return (
Content
);
}
// Complex example with multiple conditions
function Button({ variant, size, disabled, className }) {
return (
);
}
```
### FormFieldWrapper primitive
```tsx
import { FormFieldWrapper } from 'shadcn-glass-ui';
function CustomFormField() {
return (
);
}
```
### InteractiveCard primitive
```tsx
import { InteractiveCard } from 'shadcn-glass-ui';
function ProductCard({ product }) {
return (
console.log('Card clicked')}
className="p-6"
>
{product.name}
{product.description}
${product.price}
);
}
```
### TouchTarget primitive
```tsx
import { TouchTarget } from 'shadcn-glass-ui';
function IconButton({ icon: Icon, onClick, label }) {
return (
);
}
```
## Data Visualization Components
### SparklineGlass for compact time series (NEW in v2.0.0)
```tsx
import { SparklineGlass, InsightCardGlass } from 'shadcn-glass-ui';
function AnalyticsDashboard() {
const weeklyData = [120, 132, 101, 134, 90, 230, 210];
const monthlyRevenue = [45000, 52000, 48000, 61000, 55000, 67000];
return (
{/* Basic sparkline */}
{/* With filled area */}
{/* Inside metric card */}
);
}
```
### CircularProgressGlass for percentage displays
```tsx
import { CircularProgressGlass } from 'shadcn-glass-ui';
function ProgressIndicators() {
return (
{/* Basic circular progress */}
{/* With custom colors */}
{/* With label */}
);
}
```
## 3-Layer Token System (v2.0.0+)
### Using semantic tokens in components
```css
/* ✅ DO: Use semantic tokens for theming */
.my-component {
background: var(--semantic-surface);
color: var(--semantic-text);
border: 1px solid var(--semantic-border);
}
.my-component:hover {
background: var(--semantic-surface-elevated);
border-color: var(--semantic-primary);
}
/* ✅ DO: Use component tokens for specific components */
.my-button {
background: var(--btn-primary-bg);
color: var(--btn-primary-text);
border: 1px solid var(--btn-primary-border);
}
.my-button:hover {
background: var(--btn-primary-bg-hover);
box-shadow: var(--btn-primary-glow);
}
/* ✅ DO: Use primitive tokens for specific effects */
.my-glow-effect {
box-shadow: 0 0 20px var(--oklch-purple-500-40);
}
/* ❌ DON'T: Hardcode OKLCH values */
.my-component {
background: oklch(66.6% 0.159 303); /* NEVER do this */
}
```
### Creating custom themes in 15 minutes
```css
/* Example: Creating "neon" theme */
[data-theme='neon'] {
/* Layer 2: Define ~15 semantic tokens */
--semantic-primary: var(--oklch-cyan-400);
--semantic-surface: var(--oklch-black-90);
--semantic-surface-elevated: var(--oklch-slate-900-80);
--semantic-text: var(--oklch-white-95);
--semantic-text-muted: var(--oklch-slate-400);
--semantic-border: var(--oklch-cyan-500-20);
--semantic-success: var(--oklch-green-400);
--semantic-warning: var(--oklch-amber-400);
--semantic-destructive: var(--oklch-red-400);
/* Layer 3: Component tokens inherit automatically! */
/* All 296+ component variables work without modification */
}
```
### Breaking changes from v1.x to v2.0.0
```css
/* ❌ REMOVED in v2.0.0 */
background: var(--metric-emerald-bg);
color: var(--metric-amber-text);
border: 1px solid var(--metric-blue-border);
box-shadow: var(--metric-red-glow);
/* ✅ Use in v2.0.0+ */
background: var(--metric-success-bg);
color: var(--metric-warning-text);
border: 1px solid var(--metric-default-border);
box-shadow: var(--metric-destructive-glow);
```
## Additional Components
### AlertGlass and NotificationGlass
```tsx
import { AlertGlass, NotificationGlass } from 'shadcn-glass-ui';
import { AlertTriangle, CheckCircle } from 'lucide-react';
function AlertExamples() {
const [notifications, setNotifications] = useState([]);
const showNotification = (variant, title, message) => {
const id = Date.now();
setNotifications([...notifications, { id, variant, title, message }]);
};
return (
{/* Alert variants */}
This is an informational message.
Something went wrong. Please try again.
Your changes have been saved successfully.
This action requires your attention.
{/* Notification toasts */}
{/* Badge variants */}
DefaultSecondaryErrorSuccessWarningInfo
{/* Badge with tooltip */}
Hover me
{/* Status badge with count */}
Errors: 5
);
}
```
## Summary
shadcn-glass-ui v2.0.0 provides a complete glassmorphism design system with 58 production-ready components, supporting React 18/19 and Tailwind CSS 4. The library excels in accessibility (WCAG 2.1 AA compliance with 1,570+ tests), developer experience (TypeScript strict mode, rich JSDoc), and modern patterns (compound components, polymorphic rendering, 3-layer token architecture). Installation is flexible via npm package or shadcn CLI registry, with automatic dependency resolution and tree-shakeable ESM exports for optimal bundle sizes. The new 3-layer token system enables 90% faster theme creation (2-3 hours → 15 minutes) with zero hardcoded OKLCH values across all themes.
Common use cases include building modern dashboard applications with glass-themed UI, creating accessible forms with validation states and keyboard navigation, implementing multi-step wizards with StepperGlass compound components, and developing theme-aware applications with automatic dark/light/aurora mode switching. The library integrates seamlessly with existing shadcn/ui projects, React frameworks (Next.js, Remix, Vite), and AI coding assistants (Claude Code, GitHub Copilot) through comprehensive documentation and type definitions. All components support touch-optimized interactions (44×44px minimum), reduced motion preferences, and screen reader announcements for inclusive user experiences. New in v2.0.0: StepperGlass compound component (3 variants, 2 orientations), 4 exported custom hooks (useFocus, useHover, useResponsive, useWallpaperTint), SparklineGlass for data visualization, and complete token architecture migration.