Spaces:
Running
Running
File size: 6,886 Bytes
cd40c70 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | # OpenHands Design System
A portable design system extracted from the OpenHands UI. Drop it into any React + Tailwind project to get a consistent dark-first interface with semantic color tokens, pre-built components, and a comprehensive style guide.
## What's Included
```
OpenHands-Design/
DESIGN.md # Full design system specification
README.md # This file
tailwind.config.js # Tailwind theme (colors, radii, fonts, animations)
src/
globals.css # CSS custom properties (design tokens) + base resets
lib/
utils.ts # cn() helper (clsx + tailwind-merge)
components/ui/
button.tsx # Button with 8 variants (default, destructive, outline, light, secondary, muted, ghost, link)
input.tsx # Text input with unified focus style
search-input.tsx # Search input with icon, clear button, and 3 sizes
native-select.tsx # Native <select> with consistent styling
```
## Quick Start
### Install with npx
From your project root:
```bash
npx openhands-design
```
This adds `./OpenHands-Design/` (including `DESIGN.md`, tokens, and UI components). Then ask your AI assistant to use **`DESIGN.md`** for UI work. If the folder already exists, run `npx openhands-design --force` to replace it.
### 1. Install dependencies
```bash
npm install clsx tailwind-merge class-variance-authority @radix-ui/react-slot lucide-react tailwindcss-animate
```
### 2. Copy files into your project
```bash
# Copy the design tokens and global CSS
cp OpenHands-Design/src/globals.css your-project/src/globals.css
# Copy the Tailwind config (or merge into your existing one)
cp OpenHands-Design/tailwind.config.js your-project/tailwind.config.js
# Copy the utility helper
cp OpenHands-Design/src/lib/utils.ts your-project/src/lib/utils.ts
# Copy the UI components
cp -r OpenHands-Design/src/components/ui/ your-project/src/components/ui/
```
### 3. Import globals.css
In your app entry point (e.g., `main.tsx` or `App.tsx`):
```tsx
import './globals.css';
```
### 4. Add the dark class
The system is dark-first. Add the `dark` class to your `<html>` tag:
```html
<html lang="en" class="dark">
```
### 5. Start using components
```tsx
import { Button } from './components/ui/button';
import { Input } from './components/ui/input';
import { SearchInput } from './components/ui/search-input';
import { NativeSelect } from './components/ui/native-select';
function Example() {
return (
<div className="flex flex-col gap-4 bg-background p-6 text-foreground">
<h1 className="text-2xl font-semibold">Settings</h1>
<p className="text-sm text-muted-foreground">Manage your account.</p>
<Input placeholder="Your name" />
<NativeSelect>
<option>Option A</option>
<option>Option B</option>
</NativeSelect>
<div className="flex gap-2">
<Button>Save</Button>
<Button variant="outline">Cancel</Button>
<Button variant="destructive">Delete</Button>
</div>
</div>
);
}
```
## Using with AI Agents (Cursor, Copilot, etc.)
The `DESIGN.md` file is structured as an AI-readable specification. Two ways to use it:
### Option A: Cursor Rule (recommended)
Create `.cursor/rules/design-system.md` in your project:
```markdown
When building UI components, follow the design system in /DESIGN.md.
Key rules:
- Use semantic color tokens (bg-card, text-foreground, border-border) β never raw palette classes
- Use the Button, Input, SearchInput, and NativeSelect components β never raw HTML with inline styles
- Hover on dark surfaces: hover:bg-muted/60
- Hover on white/primary buttons: hover:bg-primary/85
- Focus rings: focus-visible:ring-1 (keyboard-only, 1px)
- Default text: text-sm font-normal text-foreground
- Secondary text: text-sm text-muted-foreground
- Standard gap: gap-2 (8px)
- Standard card: bg-card border border-border rounded-lg p-4
```
Every Cursor conversation will now follow your design system automatically.
### Option B: Direct prompt
Paste this at the start of a conversation:
> Build this feature following the design system in DESIGN.md. Use semantic tokens for all colors, the Button component for actions, and the Input component for form fields.
## Token Architecture
All colors are HSL triplets stored as CSS custom properties. Tailwind maps them via `hsl(var(--token))`.
```
Background scale (darkest β lightest):
--background 5% #0d0d0d Page background
--card 7% #121212 Cards, elevated surfaces
--secondary 8% #141414 Secondary surfaces
--muted 12% #1f1f1f Hover fills, badges, tooltips
--border 14% #242424 Borders, dividers
--muted-hover 18% #2e2e2e Hover on muted surfaces
Text scale:
--foreground 98% #fafafa Primary text
--muted-foreground 55% #8c8c8c Secondary text, placeholders
--primary 100% #ffffff Maximum emphasis, button bg
--primary-foreground 0% #000000 Text on white buttons
Semantic colors:
--success hsl(142 71% 45%) Green β success states
--warning hsl(38 92% 50%) Amber β warnings, in-progress
--info hsl(217 91% 60%) Blue β links, informational
--destructive hsl(0 72% 51%) Red β errors, danger
```
## Button Variants
| Variant | Look | Use |
|---------|------|-----|
| `default` | White bg, black text | Primary CTA |
| `destructive` | Red bg, white text | Delete, danger |
| `outline` | Transparent, border | Secondary actions |
| `light` | White bg, border | High-contrast primary |
| `secondary` | Dark bg | Tertiary actions |
| `muted` | Muted bg, grey text | Subdued actions |
| `ghost` | Transparent, no border | Minimal chrome |
| `link` | Underline on hover | Inline links |
## Customization
### Changing the color scheme
Edit the HSL values in `globals.css`. Every UI element updates automatically:
```css
:root {
--background: 220 20% 5%; /* Add a blue tint */
--card: 220 15% 8%;
--border: 220 10% 16%;
}
```
### Adding a light theme
Create a new class block in `globals.css` with inverted values:
```css
.light {
--background: 0 0% 100%;
--foreground: 0 0% 5%;
--card: 0 0% 97%;
--border: 0 0% 88%;
/* ... */
}
```
Then toggle `class="light"` on the `<html>` element.
## Reference
See [DESIGN.md](./DESIGN.md) for the complete specification including:
1. Visual theme and atmosphere
2. Full color palette with hex values
3. Typography rules and type scale
4. Component styling recipes
5. Layout principles and spacing system
6. Depth and elevation system
7. Do's and Don'ts
8. Responsive behavior
9. Interaction and motion patterns
10. AI agent prompt guide
11. Normalization backlog
## License
MIT
|