|
| 1 | +<div align="center"> |
| 2 | + |
| 3 | +# 🎨 Shadcn Theme Editor |
| 4 | + |
| 5 | +**Effortless Shadcn Theme Customization Made Simple** |
| 6 | + |
| 7 | +Manage Shadcn theme colors with an **intuitive UI**, adjust styles in real-time, and keep your design consistent without diving into raw CSS. |
| 8 | + |
| 9 | +--- |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | +[](https://www.npmjs.com/package/shadcn-theme-editor) |
| 21 | +[](https://github.com/programming-with-ia/shadcn-theme-editor) |
| 22 | + |
| 23 | +</div> |
| 24 | + |
| 25 | +--- |
| 26 | + |
| 27 | +# 📍 Overview |
| 28 | + |
| 29 | +The **Shadcn Theme Editor** is a lightweight component designed to simplify theme customization in Shadcn projects. |
| 30 | + |
| 31 | +- 🎛 **Visual UI** for adjusting theme colors |
| 32 | +- ⚡ **Real-time preview** of changes |
| 33 | +- 🌗 **Supports light & dark mode** via the `html.dark` class |
| 34 | +- 🛠 Works seamlessly with Shadcn components |
| 35 | +- 📦 Install as a **dev dependency** (recommended, due to bundle size) |
| 36 | + |
| 37 | +This makes it a **must-have dev tool** for anyone building with [shadcn/ui](https://ui.shadcn.com/). |
| 38 | + |
| 39 | +--- |
| 40 | + |
| 41 | +## 🚀 Installation |
| 42 | + |
| 43 | +There are two ways to install **shadcn-theme-editor**: |
| 44 | + |
| 45 | +1. **[Via npm/yarn/pnpm/bun](#install-npm)** (as a dev dependency) |
| 46 | +2. **[Via Scaflo CLI](#install-scaflo-cli)** (copies fully editable components) |
| 47 | + |
| 48 | +--- |
| 49 | + |
| 50 | +<h3 id="install-npm">1️⃣ Install via npm (as a dev dependency)</h3> |
| 51 | + |
| 52 | +Install the package as a development dependency: |
| 53 | + |
| 54 | +```bash |
| 55 | +# npm |
| 56 | +npm install --save-dev shadcn-theme-editor |
| 57 | + |
| 58 | +# yarn |
| 59 | +yarn add --dev shadcn-theme-editor |
| 60 | + |
| 61 | +# pnpm |
| 62 | +pnpm add -D shadcn-theme-editor |
| 63 | + |
| 64 | +# bun |
| 65 | +bun add -D shadcn-theme-editor |
| 66 | +``` |
| 67 | + |
| 68 | +--- |
| 69 | + |
| 70 | +**TailwindCSS**: |
| 71 | +- Tailwind v4 |
| 72 | + |
| 73 | + ```diff |
| 74 | + @import "tailwindcss"; |
| 75 | + |
| 76 | + +@source "../node_modules/shadcn-theme-editor"; /** <-- depends on your project structure */ |
| 77 | + ``` |
| 78 | + |
| 79 | +- Tailwind v3 |
| 80 | + |
| 81 | + ```diff |
| 82 | + module.exports = { |
| 83 | + content: [ |
| 84 | + // ... |
| 85 | + + "./node_modules/shadcn-theme-editor/**/*", /** <-- depends on your project structure */ |
| 86 | + ], |
| 87 | + // ... |
| 88 | + }; |
| 89 | + |
| 90 | + ``` |
| 91 | + |
| 92 | +--- |
| 93 | + |
| 94 | +<h3 id="install-scaflo-cli">2️⃣ Install via Scaflo CLI</h3> |
| 95 | + |
| 96 | +The [Scaflo CLI](https://github.com/programming-with-ia/scaflo) installs Shadcn Theme Editor as source components into your project, so you can fully customize them. |
| 97 | + |
| 98 | +```bash |
| 99 | +# pnpm (recommended) |
| 100 | +pnpm dlx shadcn@latest add sheet button accordion |
| 101 | +pnpm dlx [email protected] https://shadcnthemeeditor.vercel.app/r/editor.json -e %COMPONENTS%/shadcn-theme-editor |
| 102 | + |
| 103 | +# or with npx |
| 104 | +npx shadcn@latest add sheet button accordion |
| 105 | +npx [email protected] https://shadcnthemeeditor.vercel.app/r/editor.json -e %COMPONENTS%/shadcn-theme-editor |
| 106 | + |
| 107 | +# or with bun |
| 108 | +bunx shadcn@latest add sheet button accordion |
| 109 | +bunx [email protected] https://shadcnthemeeditor.vercel.app/r/editor.json -e %COMPONENTS%/shadcn-theme-editor |
| 110 | +``` |
| 111 | + |
| 112 | +Follow the CLI prompts to generate and configure the components inside your own codebase. |
| 113 | + |
| 114 | +> ⚠️ Note for **Next.js**: Add `"use client";` to `components/shadcn-theme-editor/index.tsx`. |
| 115 | +
|
| 116 | +--- |
| 117 | + |
| 118 | +## 📖 Usage |
| 119 | + |
| 120 | +Import the component and add it to your layout: |
| 121 | + |
| 122 | +<!-- |
| 123 | +> **Tip** |
| 124 | +> It is preferable to use this component within the `ThemeProvider`, as follows: |
| 125 | +`import { ThemeProvider } from 'next-themes';` --> |
| 126 | + |
| 127 | +```tsx |
| 128 | +import ShadcnThemeEditor from "shadcn-theme-editor"; |
| 129 | +``` |
| 130 | + |
| 131 | +### Load in Development Only |
| 132 | +Exclude the editor from production builds: |
| 133 | + |
| 134 | +```tsx |
| 135 | +let ShadcnThemeEditor: any; |
| 136 | +if (process.env.NODE_ENV === 'development') { |
| 137 | + import('shadcn-theme-editor').then(module => { |
| 138 | + ShadcnThemeEditor = module.default; // or module, depending on the module's export |
| 139 | + }); |
| 140 | +} else { |
| 141 | + // eslint-disable-next-line react/display-name |
| 142 | + ShadcnThemeEditor = ()=>null |
| 143 | +} |
| 144 | +``` |
| 145 | + |
| 146 | +and use |
| 147 | + |
| 148 | +```tsx |
| 149 | +<ShadcnThemeEditor /> |
| 150 | +``` |
| 151 | + |
| 152 | +</br> |
| 153 | + |
| 154 | +## 🖼️ Screenshots |
| 155 | + |
| 156 | +<p align="center"> |
| 157 | + <img align="center" src="https://raw.githubusercontent.com/programming-with-ia/shadcn-theme-editor/master/screenshots/shadcn-theme-editor.png" alt="screenshot"> |
| 158 | +</p> |
| 159 | + |
| 160 | +For detailed UI examples, see: [usage.md](./usage.md) |
| 161 | + |
| 162 | +## ⚙️ Props |
| 163 | + |
| 164 | +| Prop | Type | Default | Description | |
| 165 | +| ------------------ | ------------------------ | -------------------------------- | ------------------------------------------------------- | |
| 166 | +| `side` | `"left"` | `"right"` | `"left"` | Position of the editor sidebar. | |
| 167 | +| `className` | `string` | `undefined` | Extra CSS classes for the root element. | |
| 168 | +| `triggerClassName` | `string` | `undefined` | Extra CSS classes for the trigger button. | |
| 169 | +| `title` | `string` | `"Shadcn Theme Editor"` | Sidebar header text. | |
| 170 | +| `customColors` | `Record<string, string>` | `undefined` | Map of CSS vars → labels (e.g. `--primary: "Primary"`). | |
| 171 | +| `getContainer` | `() => HTMLElement` | `() => document.documentElement` | Element where dynamic styles will be injected. | |
| 172 | + |
| 173 | +## 🙌 Special Thanks |
| 174 | + |
| 175 | +- [Julian](https://github.com/jln13x) creator of [ui.jln.dev](https://ui.jln.dev/), featuring 10,000+ Shadcn themes. |
| 176 | + |
| 177 | +## 📄 License |
| 178 | + |
| 179 | +Licensed under the MIT License. |
0 commit comments