DEV Community

Cover image for shadcn-glass-ui: Drop-in Glassmorphism for Your shadcn/ui Projects 🎨
Artem Safronov
Artem Safronov

Posted on • Originally published at dev.to

shadcn-glass-ui: Drop-in Glassmorphism for Your shadcn/ui Projects 🎨

πŸ‘‹ The Problem

You've built a beautiful app with shadcn/ui. Now you want to add glassmorphism effects β€” that gorgeous frosted glass look from iOS and macOS. Your options?

  • πŸ“š CSS libraries β€” No React components, manual integration
  • πŸ”„ Full UI frameworks β€” Requires complete project migration
  • ✍️ Custom components β€” Build and maintain everything yourself

What if there was a better way?

✨ Introducing shadcn-glass-ui

shadcn-glass-ui is a glassmorphism component library that installs on top of existing shadcn/ui projects with zero migration required. Think of it as shadcn/ui's glass-themed sibling.

# Add to your existing shadcn/ui project
npx shadcn@latest add @shadcn-glass-ui/button-glass

# Use alongside your existing components
import { Button } from '@/components/ui/button';
import { ButtonGlass } from '@/components/glass/ui/button-glass';
Enter fullscreen mode Exit fullscreen mode

🎯 Key Features

  • πŸ”— 100% shadcn/ui Compatible β€” Same APIs, same CLI, same patterns. Drop-in installation.
  • πŸš€ Progressive Enhancement β€” MVP on base components β†’ glassmorphism β†’ custom branding
  • 🎨 57 Production-Ready Components β€” Core UI, Atomic, Composite, Sections, Specialized
  • πŸ”§ Listed on registry.directory β€” Official shadcn CLI support
  • 🎭 3-Layer Token System β€” Zero hardcoded colors, create themes in ~15 lines
  • 🌈 3 Built-in Themes β€” Glass (dark), Light, Aurora (gradient)
  • πŸ€– AI-First Design β€” Context7 MCP, Claude Code, GitHub Copilot, GPT
  • β™Ώ WCAG 2.1 AA β€” Full accessibility, 44px touch targets
  • ⚑ Modern Stack β€” React 19.2, TypeScript 5.9, Tailwind v4.1, Vite 7
  • πŸ“¦ Tree-Shakeable β€” Import only what you need
  • πŸ§ͺ 1,500+ Tests β€” 99.5% pass rate (visual regression, compliance, unit)

πŸš€ Drop-in Compatibility: The Game Changer

No migration required. shadcn-glass-ui enables a progressive enhancement workflow:

πŸ—οΈ Phase 1: Build MVP with base components
   ↓ shadcn/ui β€” fast start, validate ideas

🎨 Phase 2: Add glassmorphism effects
   ↓ shadcn-glass-ui β€” visual upgrade without rewrites

πŸ”§ Phase 3: Custom branding
   ↓ 3-layer token system β€” brand theme in ~15 lines
Enter fullscreen mode Exit fullscreen mode

Perfect for:

  • Startups β€” Quick MVP β†’ polish design later
  • Agencies β€” Template project β†’ customize per client
  • Enterprise β€” Prototype with shadcn/ui β†’ production-ready with branding
  • Freelancers β€” One codebase β†’ different visual styles per client

Works Alongside Your Existing Code

shadcn-glass-ui components live side-by-side with shadcn/ui:

// βœ… Your existing shadcn/ui components keep working
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';

// βœ… Glass variants install separately
import { ButtonGlass } from '@/components/glass/ui/button-glass';
import { InputGlass } from '@/components/glass/ui/input-glass';

function LoginForm() {
  return (
    <form className="space-y-4">
      {/* Standard shadcn/ui */}
      <Input placeholder="Email" />
      <Button variant="outline">Standard button</Button>

      {/* Glass variants with effects */}
      <InputGlass placeholder="Password" type="password" />
      <ButtonGlass variant="primary">Login with glass ✨</ButtonGlass>
    </form>
  );
}
Enter fullscreen mode Exit fullscreen mode

API Compatibility

v2.0.0 achieves 100% API parity with shadcn/ui:

Component shadcn/ui shadcn-glass-ui v2.0 Compatible
Button variant="default" variant="default" βœ… 100%
Toggle pressed, onPressedChange pressed, onPressedChange βœ… 100%
Slider value: number[], onValueChange value: number[], onValueChange βœ… 100%
ComboBox value, onValueChange value, onValueChange βœ… 100%

Same everything:

  • βœ… Props: variant, size, className
  • βœ… Callbacks: onValueChange, onPressedChange
  • βœ… asChild pattern for polymorphic rendering
  • βœ… CLI installation via npx shadcn add

Bonus features:

  • 🎨 Built-in glassmorphism effects
  • βš™οΈ Additional props: loading, icon, intensity
  • 🧩 Compound Components API for complex widgets

πŸ“¦ Installation: Two Ways

Option 1: shadcn CLI (Recommended)

Now listed on registry.directory!

Step 1: Add registry to components.json:

{
  "registries": {
    "@shadcn-glass-ui": {
      "url": "https://raw.githubusercontent.com/Yhooi2/shadcn-glass-ui-library/main/public/r"
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Step 2: Install components:

# One command per component
npx shadcn@latest add @shadcn-glass-ui/button-glass
npx shadcn@latest add @shadcn-glass-ui/input-glass
npx shadcn@latest add @shadcn-glass-ui/modal-glass

# Or multiple at once
npx shadcn@latest add @shadcn-glass-ui/button-glass @shadcn-glass-ui/input-glass
Enter fullscreen mode Exit fullscreen mode

Why CLI?

  • βœ… Minimal bundle β€” only what you use
  • βœ… Code lives in your project β€” full control
  • βœ… Easy to customize
  • βœ… No npm dependency

Option 2: Full Package (npm)

npm install shadcn-glass-ui
Enter fullscreen mode Exit fullscreen mode

Quick start:

import { ButtonGlass, InputGlass, ThemeProvider } from 'shadcn-glass-ui';
import 'shadcn-glass-ui/dist/styles.css';

function App() {
  return (
    <ThemeProvider defaultTheme="glass">
      <div className="p-8 space-y-4">
        <ButtonGlass variant="primary" size="lg">
          Click me! ✨
        </ButtonGlass>
        <InputGlass placeholder="Enter text..." />
      </div>
    </ThemeProvider>
  );
}
Enter fullscreen mode Exit fullscreen mode

Why npm?

  • βœ… One-command installation
  • βœ… Automatic updates
  • βœ… Tree-shaking included

🎭 Revolutionary: 3-Layer Token System

What makes v2.0 special? Zero hardcoded color values. Every color is a CSS variable.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Component Tokens (280+)                                     β”‚
β”‚  --btn-primary-bg, --modal-surface, --input-border          β”‚
β”‚         ↓ automatically inherit from                        β”‚
β”‚  Semantic Tokens (~15 per theme)                            β”‚
β”‚  --semantic-primary, --semantic-surface, --semantic-border  β”‚
β”‚         ↓ reference                                         β”‚
β”‚  Primitive Tokens (225 OKLCH colors)                        β”‚
β”‚  --oklch-purple-500, --oklch-slate-900                      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Enter fullscreen mode Exit fullscreen mode

How It Works

Layer 1 β€” 225 OKLCH colors, defined once for all themes:

:root {
  --oklch-purple-500: oklch(0.55 0.25 270);
  --oklch-slate-900: oklch(0.15 0.02 250);
  --oklch-emerald-500: oklch(0.55 0.20 160);
  --oklch-cyan-400: oklch(0.70 0.15 195);
  /* ... 221 more colors */
}
Enter fullscreen mode Exit fullscreen mode

Layer 2 β€” Each theme defines ~15 semantic tokens:

[data-theme='glass'] {
  --semantic-primary: var(--oklch-purple-500);
  --semantic-surface: var(--oklch-slate-900);
  --semantic-text: var(--oklch-white-95);
  --semantic-border: var(--oklch-slate-700);
  --semantic-glow: var(--oklch-purple-500);
  /* ... 10 more tokens */
}
Enter fullscreen mode Exit fullscreen mode

Layer 3 β€” Components automatically inherit:

:root {
  --btn-primary-bg: var(--semantic-primary);
  --btn-primary-glow: var(--semantic-glow);
  --modal-surface: var(--semantic-surface);
  --input-border: var(--semantic-border);
  /* ... 280+ component tokens */
}
Enter fullscreen mode Exit fullscreen mode

Create a Custom Theme in ~15 Lines

Want a neon theme? Override only the semantic layer:

[data-theme='neon'] {
  --semantic-primary: var(--oklch-cyan-400);
  --semantic-secondary: var(--oklch-purple-400);
  --semantic-surface: var(--oklch-black-10);
  --semantic-surface-elevated: var(--oklch-slate-950);
  --semantic-text: var(--oklch-white-98);
  --semantic-text-muted: var(--oklch-slate-400);
  --semantic-border: var(--oklch-cyan-500);
  --semantic-border-subtle: var(--oklch-slate-800);
  --semantic-glow: var(--oklch-cyan-400);
  --semantic-success: var(--oklch-emerald-500);
  --semantic-warning: var(--oklch-amber-500);
  --semantic-destructive: var(--oklch-red-500);
  --semantic-info: var(--oklch-blue-500);
}
Enter fullscreen mode Exit fullscreen mode

Result:

  • βœ… All 57 components update automatically
  • βœ… Theme switching is instant β€” CSS only, no React re-renders
  • βœ… 280+ component tokens inherit without changes

Real-World Example: MVP to Production

Scenario: SaaS startup building an analytics dashboard.

Week 1-2: MVP with shadcn/ui

// Quick prototype with base components
import { Button, Input, Card } from '@/components/ui';

function Dashboard() {
  return (
    <div>
      <Card>
        <h2>Metrics</h2>
        <Input placeholder="Search..." />
        <Button>Export</Button>
      </Card>
    </div>
  );
}
Enter fullscreen mode Exit fullscreen mode

Week 3: Add glassmorphism

# One command β€” visual upgrade
npx shadcn@latest add @shadcn-glass-ui/card-glass
npx shadcn@latest add @shadcn-glass-ui/button-glass
npx shadcn@latest add @shadcn-glass-ui/input-glass
Enter fullscreen mode Exit fullscreen mode
// Change only imports β€” APIs identical
import { ButtonGlass, InputGlass, CardGlass } from '@/components/glass/ui';

function Dashboard() {
  return (
    <div>
      <CardGlass> {/* Now with blur and glow effects */}
        <h2>Metrics</h2>
        <InputGlass placeholder="Search..." />
        <ButtonGlass>Export</ButtonGlass>
      </CardGlass>
    </div>
  );
}
Enter fullscreen mode Exit fullscreen mode

Week 4: Brand with corporate colors

/* 15 lines β€” entire company branded */
[data-theme='company'] {
  --semantic-primary: var(--oklch-blue-600);      /* Corp blue */
  --semantic-secondary: var(--oklch-orange-500);  /* Corp orange */
  --semantic-surface: var(--oklch-slate-900);     /* Dark background */
  --semantic-glow: var(--oklch-blue-400);         /* Blue glow */
  /* ... 10 more tokens */
}
Enter fullscreen mode Exit fullscreen mode

Result:

  • ⚑ 0 rewritten code β€” only import changes
  • 🎨 Full rebrand in 15 CSS lines
  • πŸš€ Idea to production in one month

Before and After

Metric v1.x (old) v2.0 (token system)
Hardcoded OKLCH values ~280 per theme 0
CSS variables per theme ~85 296+ (auto-inherited)
Lines to create theme ~280 ~15
Theme switching React re-render Instant CSS swap

πŸ€– AI-First: Built for AI Assistants

Modern developers use AI coding assistants (Claude, Copilot, ChatGPT). The problem? Most libraries are poorly indexed: implicit APIs, outdated docs in training data.

shadcn-glass-ui is optimized for AI:

AI Tool Integration What it provides
Context7 MCP Auto-indexed 41 rules, auto-fetched current docs, version-aware
Claude Code CLAUDE.md 365-line project context, patterns, examples
GitHub Copilot TypeScript strict + JSDoc Accurate completions with inline examples
ChatGPT/GPT-4 EXPORTS_MAP.json Machine-readable component registry

Example: Context7 MCP in Action

Context7 is a Model Context Protocol for indexing documentation. AI assistants query current documentation in real-time instead of relying on stale training data.

Typical workflow:

Developer: "Add a stepper to my checkout flow with 3 steps"

β†’ Claude Code queries Context7 MCP for documentation
β†’ Context7 returns current StepperGlass docs
β†’ Claude sees: "compound API, linear mode for wizards, 3 variants"
β†’ Claude generates correct code:
Enter fullscreen mode Exit fullscreen mode
<StepperGlass.Root mode="linear" currentStep={step}>
  <StepperGlass.Step value={0}>
    <StepperGlass.Trigger>
      <StepperGlass.Icon />
      Shipping
    </StepperGlass.Trigger>
    <StepperGlass.Content>
      <AddressForm />
    </StepperGlass.Content>
  </StepperGlass.Step>

  <StepperGlass.Step value={1}>
    <StepperGlass.Trigger>
      <StepperGlass.Icon />
      Payment
    </StepperGlass.Trigger>
    <StepperGlass.Content>
      <PaymentForm />
    </StepperGlass.Content>
  </StepperGlass.Step>

  <StepperGlass.Step value={2}>
    <StepperGlass.Trigger>
      <StepperGlass.Icon />
      Confirmation
    </StepperGlass.Trigger>
    <StepperGlass.Content>
      <OrderSummary />
    </StepperGlass.Content>
  </StepperGlass.Step>
</StepperGlass.Root>
Enter fullscreen mode Exit fullscreen mode

Without Context7, AI would:

  1. Rely on outdated docs from training data
  2. Guess API names (maybe step instead of value?)
  3. Miss the linear mode for wizards
  4. Forget StepperGlass.Icon and other subcomponents

Decision Trees for AI

The repository includes decision trees β€” which component to use for specific tasks:

Need to display a metric?
β”œβ”€ Single value β†’ MetricCardGlass
β”œβ”€ Compare multiple β†’ MetricsGridGlass
β”œβ”€ With trend (sparkline) β†’ SparklineGlass
└─ Circular chart β†’ CircularMetricGlass

Need a modal?
β”œβ”€ Simple confirmation β†’ AlertGlass
β”œβ”€ Form with fields β†’ ModalGlass.Root (compound)
└─ Toast notification β†’ NotificationGlass
Enter fullscreen mode Exit fullscreen mode

Rich JSDoc for All Components

Every component includes detailed JSDoc with examples:

/**
 * Glass-styled button with glassmorphism effect
 * 
 * @example
 * // Primary button with loading state
 * <ButtonGlass variant="primary" size="lg" loading>
 *   Loading...
 * </ButtonGlass>
 * 
 * @example
 * // As link with React Router (polymorphic)
 * <ButtonGlass asChild>
 *   <Link to="/profile">Profile</Link>
 * </ButtonGlass>
 * 
 * @example
 * // With icon
 * <ButtonGlass icon={<CheckIcon />} variant="ghost">
 *   Saved
 * </ButtonGlass>
 * 
 * @accessibility 
 * - Keyboard navigation (Enter, Space)
 * - Focus visible ring (2px inner + 4px outer)
 * - Touch target minimum 44x44px (Apple HIG)
 * - Loading state disables interaction
 */
export const ButtonGlass: React.FC<ButtonGlassProps> = ({ 
  variant = "default",
  size = "md",
  loading = false,
  icon,
  asChild = false,
  ...props 
}) => { /* ... */ };
Enter fullscreen mode Exit fullscreen mode

AI sees examples directly in types and generates correct code on the first try.

🎨 Components: 57 Production-Ready

shadcn-glass-ui provides 57 components across 6 categories:

Category Count Description Examples
Core UI 18 Essential building blocks ButtonGlass, InputGlass, ModalGlass, TabsGlass, CheckboxGlass, SliderGlass
Atomic 7 Single-purpose components SearchBoxGlass, ThemeToggleGlass, IconButtonGlass, StatItemGlass
Composite 13 Pre-built complex widgets MetricCardGlass, AICardGlass, RepositoryCardGlass, UserInfoGlass
Sections 7 Full page sections HeaderNavGlass, ProfileHeaderGlass, CareerStatsGlass, ProjectsListGlass
Specialized 10 Advanced components SparklineGlass, StepperGlass (3 variants), RainbowProgressGlass
Primitives 3 Low-level primitives TouchTarget, FormFieldWrapper, InteractiveCard

Three Built-in Themes

  • Glass (dark) β€” Classic glassmorphism with purple accents and glow effects
  • Light β€” Clean minimal design with subtle glass effects
  • Aurora β€” Vibrant gradients with aurora borealis-inspired colors
import { ThemeProvider, useTheme } from 'shadcn-glass-ui';

function ThemeSwitcher() {
  const { theme, cycleTheme } = useTheme();

  return (
    <button onClick={cycleTheme}>
      Current theme: {theme}
    </button>
  );
}
Enter fullscreen mode Exit fullscreen mode

Compound Components API

Complex components use the Compound Components pattern for maximum flexibility:

<ModalGlass.Root open={isOpen} onOpenChange={setIsOpen}>
  <ModalGlass.Overlay />
  <ModalGlass.Content>
    <ModalGlass.Header>
      <ModalGlass.Title>Confirm Action</ModalGlass.Title>
      <ModalGlass.Description>
        This action cannot be undone
      </ModalGlass.Description>
      <ModalGlass.Close />
    </ModalGlass.Header>

    <ModalGlass.Body>
      <p>Are you sure you want to delete this item?</p>
    </ModalGlass.Body>

    <ModalGlass.Footer>
      <ButtonGlass variant="ghost" onClick={() => setIsOpen(false)}>
        Cancel
      </ButtonGlass>
      <ButtonGlass variant="destructive" onClick={handleDelete}>
        Delete
      </ButtonGlass>
    </ModalGlass.Footer>
  </ModalGlass.Content>
</ModalGlass.Root>
Enter fullscreen mode Exit fullscreen mode

Benefits:

  • 🧩 Flexible composition β€” Skip Footer or add Description as needed
  • πŸ“¦ Tree-shaking β€” Unused parts don't ship to production
  • πŸ“– Clear structure β€” DOM hierarchy visible without docs

Polymorphic Components (asChild)

All interactive components support the asChild pattern from Radix UI:

import { ButtonGlass } from 'shadcn-glass-ui';
import { Link } from 'react-router-dom';

// Render button as React Router Link
<ButtonGlass asChild variant="primary">
  <Link to="/dashboard">Go to Dashboard</Link>
</ButtonGlass>

// Render button as anchor
<ButtonGlass asChild variant="ghost">
  <a href="https://github.com" target="_blank" rel="noopener">
    GitHub
  </a>
</ButtonGlass>

// Render button as custom component
<ButtonGlass asChild>
  <motion.button
    whileHover={{ scale: 1.05 }}
    whileTap={{ scale: 0.95 }}
  >
    Animated Button
  </motion.button>
</ButtonGlass>
Enter fullscreen mode Exit fullscreen mode

β™Ώ Accessibility First

All components comply with WCAG 2.1 Level AA:

  • βœ… Contrast β€” Minimum 4.5:1 for text
  • βœ… Keyboard β€” Full navigation via Tab, Enter, Arrow keys
  • βœ… Touch targets β€” Minimum 44Γ—44px (Apple HIG)
  • βœ… Screen readers β€” Proper ARIA attributes and semantic HTML
  • βœ… Focus indicators β€” 2px inner + 4px outer ring
  • βœ… Reduced motion β€” Auto-disables animations with prefers-reduced-motion

Test Coverage: 1,500+ Automated Tests

Category Count Tools Pass Rate
Design System Compliance 650+ Vitest + custom matchers 99.5%
Visual Regression 580 Playwright + screenshots 99.5%
Unit Tests 270+ Vitest 99.5%

Design System Compliance verifies:

  • All components use tokens (no hardcoded values)
  • Touch targets minimum 44Γ—44px
  • Color contrast 4.5:1+
  • Correct compound component structure

Visual Regression catches:

  • Unintended visual changes
  • Theme switching bugs
  • Responsive design issues

πŸ› οΈ CLI Utilities

shadcn-glass-ui includes a CLI for quick reference:

# Component info (fuzzy search)
npx shadcn-glass-ui info button
npx shadcn-glass-ui info modal

# List all components
npx shadcn-glass-ui list

# Filter by category
npx shadcn-glass-ui list --category=core
npx shadcn-glass-ui list --category=composite
Enter fullscreen mode Exit fullscreen mode

πŸ—ΊοΈ Roadmap

Coming in future releases:

  • 🎨 10+ new components (DatePicker, Calendar, Command Palette)
  • 🌈 Additional themes (Cyberpunk, Nord, Dracula)
  • πŸ“± Mobile optimization enhancements
  • πŸ”Œ Figma plugins (export themes)
  • πŸ€– Extended Context7 integration (code actions)

πŸ“š Resources

🀝 Contributing

shadcn-glass-ui is open source (MIT) and we welcome contributions!

⭐ Support the Project

If you find shadcn-glass-ui useful:

🎯 What Makes This Different?

shadcn-glass-ui solves four key problems:

  1. "How do I add glassmorphism without rewriting my project?"

    β†’ Drop-in compatibility with shadcn/ui, CLI installation

  2. "How do I quickly go from MVP to production-ready design?"

    β†’ Progressive enhancement: base components β†’ glassmorphism β†’ branding

  3. "How do I create themes without copy-pasting hundreds of values?"

    β†’ 3-layer token system, new theme in ~15 lines

  4. "How do I make my library AI-assistant friendly?"

    β†’ Context7 MCP, rich JSDoc, decision trees

Typical workflow:

Week 1-2: Prototype with shadcn/ui
    ↓
Week 3: Add glassmorphism (npm install)
    ↓
Week 4: Custom brand theme (15 CSS lines)
    ↓
Production-ready in one month πŸš€
Enter fullscreen mode Exit fullscreen mode

πŸ’¬ Let's Connect!

I'd love to hear your feedback! Drop a comment below or reach out:

  • GitHub: @Yhooi2
  • Twitter: Share your builds with #shadcnglassui

Thanks for reading! Happy coding! πŸš€βœ¨


Found this helpful? Follow for more articles on React, TypeScript, and UI development.

⭐ Star on GitHub | πŸ“¦ npm | 🌐 Live Demo

Top comments (0)