Skip to content

Commit c636a89

Browse files
.
.
1 parent f0a9b74 commit c636a89

File tree

12 files changed

+215
-189
lines changed

12 files changed

+215
-189
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,6 @@ todo_*
4242
tempCodeRunnerFile.*
4343
*.tgz
4444
/testapps
45+
46+
shadcn-theme-editor/README.md
47+
shadcn-theme-editor/usage.md

README.md

Lines changed: 155 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,155 @@
1-
shadcn-theme-editor/README.md
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.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"lint": "turbo run lint",
88
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
99
"check-types": "turbo run check-types",
10-
"pkg-build": "turbo run build --filter=shadcn-theme-editor && tsx scripts/scaflo.ts"
10+
"pkg-build": "turbo run build --filter=shadcn-theme-editor && tsx scripts/scaflo.ts && tsx scripts/copy-files.ts"
1111
},
1212
"devDependencies": {
1313
"@types/fs-extra": "^11.0.4",
78 KB
Loading

screenshots/usage-pic.png

167 KB
Loading

scripts/copy-files.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import fs from "fs-extra";
2+
import path from "path";
3+
import { editorPath, rootDir } from "./paths";
4+
5+
function copyFiles() {
6+
try {
7+
["README.md", "usage.md"].forEach((file) => {
8+
const src = path.join(rootDir, file);
9+
const dest = path.join(editorPath, file);
10+
11+
fs.copyFileSync(src, dest);
12+
console.log(`✅ Copied ${file}${dest}`);
13+
});
14+
} catch (err) {
15+
console.error("❌ Error copying files:", err);
16+
}
17+
}
18+
19+
// Example usage
20+
copyFiles();

scripts/paths.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import path from "path";
2+
import { fileURLToPath } from "url";
3+
4+
export const currentFile = fileURLToPath(import.meta.url);
5+
export const rootDir = path.resolve(path.dirname(currentFile), "..");
6+
7+
export const editorPath = path.join(rootDir, "/shadcn-theme-editor");
8+
export const editorMainPath = path.join(editorPath, "/src/(main)/");
9+
export const outputPath = path.join(rootDir, "/web/public/r/editor.json");

scripts/scaflo.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import fs from "fs-extra";
22
import path from "path";
33
import { fileURLToPath } from "url";
4+
import { editorMainPath, editorPath, outputPath } from "./paths";
45

56
//* Scaflo types
67

@@ -20,12 +21,7 @@ type JsonStructure = {
2021
registryDependencies: string[]; //* modified (shadcn's components)
2122
};
2223

23-
const currentFile = fileURLToPath(import.meta.url);
24-
const rootDir = path.resolve(path.dirname(currentFile), "..");
2524

26-
const editorPath = path.join(rootDir, "/shadcn-theme-editor");
27-
const editorMainPath = path.join(editorPath, "/src/(main)/");
28-
const outputPath = path.join(rootDir, "/web/public/r/editor.json");
2925

3026
fs.ensureDirSync(path.dirname(outputPath));
3127

shadcn-theme-editor/README.md

Lines changed: 0 additions & 155 deletions
This file was deleted.

0 commit comments

Comments
 (0)