# 7onic Design System — AI Guide (Full) ## What is 7onic? Token-driven React design system with 42 components on Radix UI. Single source of truth — design tokens to code. Use this to build any React service. - Documentation: https://7onic.design - npm: `@7onic-ui/react` (components) + `@7onic-ui/tokens` (design tokens) - For tokens-only guide, see: https://7onic.design/llms.txt --- # ═══ SECTION 1: PROJECT SETUP & AI RULES ═══ ## How to Start ### Step 1: Ask the user (setup checklist) Before writing any code, present this checklist and wait for answers: 1. **Framework** — Next.js / Vite (React SPA) / Remix / other? 2. **Dark mode** — Yes or no? 3. **Font** — Use default, or custom font? If custom, which font? 4. **Locale** — Which language(s)? (for CJK font loading) 5. **What are you building?** — Describe the project **If the user answers in natural language** (e.g., "Make me a dashboard with dark mode, English only"), extract the answers from their message. **If any item is missing, ask a follow-up question for the missing items only.** Do not proceed until all 5 items are answered. ### Step 2: Install / Setup ⚠️ **DO NOT GUESS** — install procedures evolve with each Tailwind / Next / Vite version. Before writing any code, AI **MUST** fetch the live pages below and follow their instructions verbatim: - **Official install page (SSOT)**: https://7onic.design/components/installation - **Tailwind CSS official**: https://tailwindcss.com/docs/installation The install instructions are intentionally **not duplicated in this file**. Setup details (packages, `tailwind.config.js`, `vite.config.ts`, `postcss.config.mjs`, `globals.css` patterns, framework default cleanup, layer wrap tips, etc.) are version-sensitive and change frequently — always defer to the live documentation above. Apply user's answers from Step 1 after the install page steps are complete: - Dark mode = yes → implement dark mode toggle (see below in this file) - Custom font → load via `next/font/google` (Next.js) or Fontsource / CDN (Vite) - Japanese / Korean locale → load Noto Sans JP / KR ⛔ **Do NOT proceed to Step 3 until install page setup is verified.** ### Icon Import Pattern (lucide-react) ⚠️ **`lucide-react` is NOT a 7onic dependency.** 7onic components themselves use inline SVG. Install separately if you want to use lucide icons in your app code: ```bash npm install lucide-react ``` ```tsx // ✅ Official pattern — no suffix import { Search, Settings, ChevronDown, X } from 'lucide-react' // ❌ Legacy alias — avoid import { SearchIcon, SettingsIcon } from 'lucide-react' // ⚠️ Name collision with 7onic component — use alias import { Badge } from '@7onic-ui/react' import { Badge as BadgeIcon } from 'lucide-react' ``` ### Step 3: Add Toaster to root layout (if using Toast) Place `` once in your root layout file. Without this, `toast()` calls will not render. ```tsx import { Toaster } from '@7onic-ui/react' // In your root layout (e.g., app/layout.tsx) {children} ``` ### Step 4: Start building Design freely based on user's project description. Always use 7onic components + tokens. ### Component Dependencies (auto-install during development) | Component | Additional Package | When to install | |---|---|---| | Chart (Bar, Line, Area, Pie) | `recharts` | `npm install recharts` — import from `@7onic-ui/react/chart` (separate entry point) | --- ## ⛔ AI Rules — Whitelist System ### Core Principle **Token values are user-defined.** Every project has different brand colors and design decisions. The token NAMES are the API — never assume or hardcode specific values. ### Whitelist — ONLY These Are Allowed 1. **7onic components + Props** — always prefer components over raw HTML 2. **Token classes** — colors, spacing, typography, radius, shadows, z-index, icon sizes, duration, easing, opacity, scale 3. **Tailwind structural utilities** — layout, positioning, display, overflow, sizing, and more: - Layout: flex, grid, block, inline, hidden, container - Position: relative, absolute, fixed, sticky, top-0, inset-0 - Flex/Grid: items-center, justify-between, gap-4, col-span-2 - Sizing: w-full, h-full, min-h-screen, max-w-7xl - Spacing: space-x-*, space-y-*, divide-x, divide-y - Overflow: overflow-hidden, overflow-auto, truncate, whitespace-nowrap - Interaction: cursor-pointer, pointer-events-none, select-none - Accessibility: sr-only - Group/Peer: group, group-hover:*, peer, peer-checked:* - Aspect: aspect-square, aspect-video - Text: line-clamp-*, text-ellipsis - Animation: animate-spin, animate-pulse, animate-bounce - Any other Tailwind structural/layout utility not listed above is also allowed — as long as it does not hardcode colors, spacing values, font sizes, or other visual values that exist as tokens - ⚠️ Utilities that implicitly use color (divide, border) must be paired with a token color: `divide-y divide-border` ✅ / `divide-y` alone ❌ (may not adapt to dark mode) `border border-border` ✅ / `border` alone ❌ 4. **Tailwind visual utilities using token values** — gradients, transforms, transitions: - Gradient: bg-gradient-to-r, from-primary, to-secondary (token colors only) - Transform: rotate-45, translate-x-1 - Transition: transition-all, transition-colors (with token durations) - Backdrop: backdrop-blur, backdrop-blur-sm 5. **Responsive prefixes** — sm:, md:, lg:, xl:, 2xl: (on allowed classes only) 6. **State prefixes** — hover:, focus:, active:, disabled: (on allowed classes only, token values only) 7. **Layout dimension arbitrary values** — height and width ONLY: h-[300px], max-w-[1200px] (when no token fits) 8. **Opacity modifier** — append `/0-100` to any token color for transparency: - `bg-primary/50`, `text-foreground/70`, `border-border/30` - Do NOT use `opacity-*` utility as a workaround — it affects the entire element including children - `bg-primary/10` ✅ (only background is transparent) / `bg-primary opacity-10` ❌ (children also become transparent) 9. **Token-first rule** — Before adding any Tailwind utility, check if the property is already included in a design token. Typography tokens (`text-sm`, `text-md`, etc.) include both font-size AND line-height as a pair. Do NOT override with Tailwind line-height utilities: - `text-sm` ✅ (token provides font-size + line-height) - `text-sm leading-relaxed` ❌ (overrides token line-height) - `text-sm leading-none` ❌ (overrides token line-height) - `text-sm leading-[18px]` ❌ (hardcodes line-height) **Everything not in this list is FORBIDDEN.** ⚠️ **Gradient/visual utilities must use token colors only:** `from-primary to-secondary` ✅ / `from-blue-500 to-purple-600` ❌ ### Decision Tree — For Every UI Element ``` Step 1: Does a 7onic component exist for this? → YES: Use the component. Style via Props (variant/size/color). className ONLY for layout (margin, width, flex positioning). → NO: Step 2 Step 2: Is this a layout/structural element? (flex container, grid, section wrapper) → YES: Use div/section + token classes only. → NO: Step 3 Step 3: Re-check the 42 components. Most UI can be built with component combinations. → Still no match: Use div + token classes only. ``` ### ❌ Forbidden Patterns ```tsx // ❌ HTML instead of components