Skip to content

Commit ecc23d5

Browse files
committed
chore: update readme for style customization
1 parent 024d6fd commit ecc23d5

File tree

4 files changed

+100
-17
lines changed

4 files changed

+100
-17
lines changed

README.md

Lines changed: 85 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,6 @@ function App() {
7070
</script>
7171
```
7272

73-
**With CSS custom properties for theming:**
74-
75-
```html
76-
<docs-chatbot
77-
search-url="your-edge-function-url"
78-
api-key="your-api-key"
79-
title="Your Docs"
80-
style="--primary: #f5426c; --primary-foreground: #ffffff"
81-
>
82-
</docs-chatbot>
83-
```
84-
8573
## Props / Configuration
8674

8775
### React Component
@@ -104,3 +92,88 @@ function App() {
10492
| `title` | Yes | Title displayed in the chatbot header |
10593
| `empty-state-title` | No | Main heading shown before the first message |
10694
| `empty-state-description` | No | Subtext shown below the empty state title |
95+
96+
## Customizing Theme
97+
98+
You can customize the chatbot's appearance by overriding CSS variables.
99+
100+
### Available CSS Variables
101+
102+
```css
103+
:root {
104+
/* Border radius */
105+
--docs-chatbot-radius
106+
107+
/* Colors */
108+
--docs-chatbot-background
109+
--docs-chatbot-foreground
110+
--docs-chatbot-card
111+
--docs-chatbot-card-foreground
112+
--docs-chatbot-popover
113+
--docs-chatbot-popover-foreground
114+
--docs-chatbot-primary
115+
--docs-chatbot-primary-foreground
116+
--docs-chatbot-secondary
117+
--docs-chatbot-secondary-foreground
118+
--docs-chatbot-muted
119+
--docs-chatbot-muted-foreground
120+
--docs-chatbot-accent
121+
--docs-chatbot-accent-foreground
122+
--docs-chatbot-destructive
123+
--docs-chatbot-border
124+
--docs-chatbot-input
125+
--docs-chatbot-ring
126+
}
127+
```
128+
129+
### Usage Examples
130+
131+
**In your global CSS (recommended):**
132+
133+
```css
134+
/* In your main CSS file, import the chatbot styles first */
135+
@import "@sqliteai/docs-chatbot/style.css";
136+
137+
/* Then override the variables */
138+
:root {
139+
--docs-chatbot-primary: oklch(0.6 0.2 0);
140+
--docs-chatbot-primary-foreground: oklch(1 0 0);
141+
--docs-chatbot-border: oklch(0.85 0 0);
142+
}
143+
```
144+
145+
**In React:**
146+
147+
```tsx
148+
import { DocsChatbot } from "@sqliteai/docs-chatbot";
149+
import "./styles.css"; // Your CSS file with overrides
150+
151+
function App() {
152+
return (
153+
<DocsChatbot
154+
searchUrl="your-edge-function-url"
155+
apiKey="your-api-key"
156+
title="Your Docs"
157+
/>
158+
);
159+
}
160+
```
161+
162+
**In Vanilla JavaScript / HTML:**
163+
164+
```html
165+
<style>
166+
docs-chatbot {
167+
--docs-chatbot-primary: oklch(0.6 0.2 0);
168+
--docs-chatbot-primary-foreground: oklch(1 0 0);
169+
--docs-chatbot-border: oklch(0.85 0 0);
170+
}
171+
</style>
172+
173+
<docs-chatbot
174+
search-url="your-edge-function-url"
175+
api-key="your-api-key"
176+
title="Your Docs"
177+
>
178+
</docs-chatbot>
179+
```

examples/react-app/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { DocsChatbot } from "../../../dist/esm/index.esm.js";
2-
import "../../../dist/esm/docs-chatbot.css";
2+
import "./styles.css";
33

44
function App() {
55
return (

examples/react-app/src/styles.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@import "../../../dist/esm/docs-chatbot.css";
2+
3+
:root {
4+
--docs-chatbot-primary: oklch(70.427% 0.13219 65.637);
5+
--docs-chatbot-primary-foreground: oklch(1 0 0);
6+
--docs-chatbot-border: oklch(0.85 0 0);
7+
}

examples/vanilla-js/index.html

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
<script src="../../dist/umd/docs-chatbot.min.js"></script>
1717
<script src="./config.js"></script>
1818

19+
<style>
20+
docs-chatbot {
21+
--docs-chatbot-primary: oklch(65.698% 0.12717 240.619);
22+
--docs-chatbot-primary-foreground: oklch(1 0 0);
23+
}
24+
</style>
25+
1926
<docs-chatbot
2027
title="SQLite Cloud Docs"
2128
empty-state-title="Ask questions about SQLite Cloud"
@@ -27,10 +34,6 @@
2734
const chatbot = document.querySelector("docs-chatbot");
2835
chatbot.setAttribute("search-url", window.ChatbotConfig.searchUrl);
2936
chatbot.setAttribute("api-key", window.ChatbotConfig.apiKey);
30-
chatbot.setAttribute(
31-
"style",
32-
"--docs-chatbot-primary: #f5426c; --docs-chatbot-primary-foreground: #ffffff"
33-
);
3437
</script>
3538
</body>
3639
</html>

0 commit comments

Comments
 (0)