Skip to content

Commit 2ac53a1

Browse files
.
1 parent 879d85b commit 2ac53a1

File tree

2 files changed

+180
-0
lines changed

2 files changed

+180
-0
lines changed

README.md

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
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+
![Next.js](https://img.shields.io/badge/Next.js-000000.svg?style&logo=Next.js&logoColor=white)
12+
![React](https://img.shields.io/badge/React-61DAFB.svg?style&logo=React&logoColor=black)
13+
![TypeScript](https://img.shields.io/badge/TypeScript-3178C6.svg?style&logo=TypeScript&logoColor=white)
14+
15+
![GitHub last commit](https://img.shields.io/github/last-commit/programming-with-ia/shadcn-theme-editor)
16+
![GitHub commit activity](https://img.shields.io/github/commit-activity/m/programming-with-ia/shadcn-theme-editor)
17+
![GitHub top language](https://img.shields.io/github/languages/top/programming-with-ia/shadcn-theme-editor)
18+
19+
![npm bundle size](https://badgen.net/bundlephobia/min/shadcn-theme-editor@latest)
20+
[![NPM Version](https://img.shields.io/npm/v/shadcn-theme-editor?logo=npm)](https://www.npmjs.com/package/shadcn-theme-editor)
21+
[![GitHub](https://img.shields.io/badge/shadcn_theme_editor-161b22?logo=github)](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+
<h3 id="install-scaflo-cli">2️⃣ Install via Scaflo CLI</h3>
71+
72+
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.
73+
74+
```bash
75+
# pnpm (recommended)
76+
pnpm dlx shadcn@latest add sheet button accordion
77+
pnpm dlx [email protected] https://shadcnthemeeditor.vercel.app/r/editor.json -e %COMPONENTS%/shadcn-theme-editor
78+
79+
# or with npx
80+
npx shadcn@latest add sheet button accordion
81+
npx [email protected] https://shadcnthemeeditor.vercel.app/r/editor.json -e %COMPONENTS%/shadcn-theme-editor
82+
83+
# or with bun
84+
bunx shadcn@latest add sheet button accordion
85+
bunx [email protected] https://shadcnthemeeditor.vercel.app/r/editor.json -e %COMPONENTS%/shadcn-theme-editor
86+
```
87+
88+
Follow the CLI prompts to generate and configure the components inside your own codebase.
89+
90+
> ⚠️ Note for **Next.js**: Add `"use client";` to `components/shadcn-theme-editor/index.tsx`.
91+
92+
---
93+
94+
## 📖 Usage
95+
96+
Import the component and add it to your layout:
97+
98+
<!--
99+
> **Tip**
100+
> It is preferable to use this component within the `ThemeProvider`, as follows:
101+
`import { ThemeProvider } from 'next-themes';` -->
102+
103+
```tsx
104+
import ShadcnThemeEditor from "shadcn-theme-editor";
105+
```
106+
107+
### Load in Development Only
108+
Exclude the editor from production builds:
109+
110+
```tsx
111+
let ShadcnThemeEditor: any;
112+
if (process.env.NODE_ENV === 'development') {
113+
import('shadcn-theme-editor').then(module => {
114+
ShadcnThemeEditor = module.default; // or module, depending on the module's export
115+
});
116+
} else {
117+
// eslint-disable-next-line react/display-name
118+
ShadcnThemeEditor = ()=>null
119+
}
120+
```
121+
122+
and use
123+
124+
```tsx
125+
<ShadcnThemeEditor />
126+
```
127+
128+
</br>
129+
130+
## 🖼️ Screenshots
131+
132+
<p align="center">
133+
<img align="center" src="https://raw.githubusercontent.com/programming-with-ia/shadcn-theme-editor/master/screenshots/shadcn-theme-editor.png" alt="screenshot">
134+
</p>
135+
136+
For detailed UI examples, see: [usage.md](./usage.md)
137+
138+
## ⚙️ Props
139+
140+
| Prop | Type | Default | Description |
141+
| ------------------ | ------------------------ | -------------------------------- | ------------------------------------------------------- |
142+
| `side` | `"left"` | `"right"` | `"left"` | Position of the editor sidebar. |
143+
| `className` | `string` | `undefined` | Extra CSS classes for the root element. |
144+
| `triggerClassName` | `string` | `undefined` | Extra CSS classes for the trigger button. |
145+
| `title` | `string` | `"Shadcn Theme Editor"` | Sidebar header text. |
146+
| `customColors` | `Record<string, string>` | `undefined` | Map of CSS vars → labels (e.g. `--primary: "Primary"`). |
147+
| `getContainer` | `() => HTMLElement` | `() => document.documentElement` | Element where dynamic styles will be injected. |
148+
149+
## 🙌 Special Thanks
150+
151+
- [Julian](https://github.com/jln13x) creator of [ui.jln.dev](https://ui.jln.dev/), featuring 10,000+ Shadcn themes.
152+
153+
## 📄 License
154+
155+
Licensed under the MIT License.

usage.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<h1 align="center">Shadcn Theme Editor</h1>
2+
3+
## Usage
4+
<p align="center">
5+
<img align="center" src="https://raw.githubusercontent.com/programming-with-ia/shadcn-theme-editor/master/screenshots/usage-pic.png" alt="Shadcn Usage ScreenShot">
6+
</p>
7+
8+
### 1. Reset Button
9+
10+
- Click to **Reset the Theme**.
11+
- Press `⌘ + Click` to delete all themes stored in Local Storage.
12+
13+
### 2. Copy Button
14+
15+
- Click to **Copy the Current Theme** to your clipboard.
16+
17+
### 3. Color Picker Trigger
18+
19+
- Opens the color picker for the selected theme color.
20+
21+
### 4. Color Button & 5. Tooltip
22+
23+
- **Color Name/Title**: Displays the name of the color.
24+
- **Double-Click**: Copy the current color value to the clipboard.
25+
- **Hover**: Display the current value of the color in a tooltip.

0 commit comments

Comments
 (0)