Skip to content

Commit e516936

Browse files
dallasbpetersclaude
andcommitted
Add critical color pairing and component usage docs
Document the two most common AI mistakes: - Not pairing background/text colors - Writing custom CSS instead of using existing components Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 254e0ea commit e516936

File tree

1 file changed

+126
-0
lines changed

1 file changed

+126
-0
lines changed

src/resources/00-system-overview.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,132 @@ When you call `get_component_info` for "Button", you'll see tokens like:
269269
}
270270
```
271271

272+
## ⚠️ CRITICAL: Color Pairing Rule
273+
274+
**This is the #1 rule AI gets wrong. Read carefully.**
275+
276+
In Optics, background colors and text colors are ALWAYS paired. You cannot use one without the other.
277+
278+
### The Rule
279+
280+
| When you set... | You MUST also set... |
281+
|-----------------|----------------------|
282+
| `background-color: var(--op-color-primary-base)` | `color: var(--op-color-primary-on-base)` |
283+
| `background-color: var(--op-color-danger-minus-1)` | `color: var(--op-color-danger-on-minus-1)` |
284+
| `color: var(--op-color-neutral-on-plus-eight)` | `background-color: var(--op-color-neutral-plus-eight)` |
285+
286+
### Why?
287+
288+
The `-on-` tokens are calculated for proper contrast against their matching background. Using them separately:
289+
- Breaks accessibility
290+
- Creates unreadable text
291+
- Defeats the purpose of the system
292+
293+
### ❌ WRONG - Unpaired Colors
294+
295+
```css
296+
/* Missing the text color! */
297+
.card {
298+
background-color: var(--op-color-primary-base);
299+
}
300+
301+
/* Missing the background! */
302+
.label {
303+
color: var(--op-color-danger-on-base);
304+
}
305+
306+
/* Using mismatched tokens! */
307+
.badge {
308+
background-color: var(--op-color-primary-base);
309+
color: var(--op-color-danger-on-base); /* WRONG - mismatched family */
310+
}
311+
```
312+
313+
### ✅ CORRECT - Paired Colors
314+
315+
```css
316+
.card {
317+
background-color: var(--op-color-primary-base);
318+
color: var(--op-color-primary-on-base);
319+
}
320+
321+
.label {
322+
background-color: var(--op-color-danger-base);
323+
color: var(--op-color-danger-on-base);
324+
}
325+
326+
.badge-light {
327+
background-color: var(--op-color-primary-plus-five);
328+
color: var(--op-color-primary-on-plus-five);
329+
}
330+
```
331+
332+
### The Pattern
333+
334+
For ANY color usage:
335+
1. Pick your background: `--op-color-{family}-{scale}`
336+
2. Add matching text: `--op-color-{family}-on-{scale}`
337+
3. For secondary text, use: `--op-color-{family}-on-{scale}-alt`
338+
339+
**Never use background colors alone. Never use text colors alone. They are a pair.**
340+
341+
---
342+
343+
## ⚠️ CRITICAL: Use Existing Components
344+
345+
**Don't write CSS for things that already exist.**
346+
347+
Optics has pre-built components with established class names. AI should use these, not create new ones.
348+
349+
### ❌ WRONG - Writing New CSS
350+
351+
```css
352+
/* DON'T DO THIS - buttons already exist */
353+
.my-button {
354+
padding: var(--op-space-small) var(--op-space-medium);
355+
background-color: var(--op-color-primary-base);
356+
color: var(--op-color-primary-on-base);
357+
border-radius: var(--op-radius-medium);
358+
}
359+
360+
/* DON'T DO THIS - cards already exist */
361+
.custom-card {
362+
padding: var(--op-space-large);
363+
background: var(--op-color-neutral-plus-eight);
364+
border-radius: var(--op-radius-large);
365+
box-shadow: var(--op-shadow-medium);
366+
}
367+
```
368+
369+
### ✅ CORRECT - Use Existing Classes
370+
371+
```html
372+
<!-- Use Optics button classes -->
373+
<button class="btn btn--primary">Click me</button>
374+
375+
<!-- Use Optics card classes -->
376+
<div class="card">
377+
<div class="card__content">...</div>
378+
</div>
379+
```
380+
381+
### When to Write Custom CSS
382+
383+
Only write custom CSS when:
384+
1. **Extending** an existing component with a modifier (following BEM conventions)
385+
2. Creating something that **truly doesn't exist** in Optics
386+
3. Overriding specific tokens for **theming purposes**
387+
388+
### Before Writing CSS, Ask:
389+
390+
1. Does this component exist in Optics? → Check https://docs.optics.rolemodel.design
391+
2. Can I use existing utility classes? → `.stack`, `.cluster`, `.split`, etc.
392+
3. Am I just recreating something that exists? → Use the existing class
393+
394+
**The whole point of a design system is to NOT write custom CSS for common patterns.**
395+
396+
---
397+
272398
## 🚨 Common Mistakes
273399

274400
### Mistake 1: Looking for Simple Color Names

0 commit comments

Comments
 (0)