# Neon JS SDK - UI Theming Complete guide to customizing the Neon Auth UI components. ## How It Works Neon Auth UI **automatically inherits your app's existing theme**. If you already have CSS variables like `--primary`, `--background`, etc. defined (from Tailwind, shadcn/ui, or custom CSS), the auth components will use them with no configuration needed. **Key features:** - **Automatic inheritance**: Uses your existing `--primary`, `--background`, etc. variables - **Fallback defaults**: If you don't define a variable, sensible defaults are used - **No conflicts**: All auth styles are in `@layer neon-auth`, so your styles always win - **Import order doesn't matter**: CSS layers handle priority automatically ### Integration with shadcn/ui If you use shadcn/ui or similar libraries that define `--primary`, `--background`, etc., Neon Auth will automatically inherit those colors. No additional configuration needed. ### Why Variables Are on `:root` Variables are defined on `:root` to ensure they're accessible to portal-rendered components (modals, dropdowns, toasts) that render outside the normal component tree. ## CSS Import Decision | Your Setup | Import Path | Bundle Size | |------------|-------------|-------------| | No Tailwind | `@neondatabase/neon-js/ui/css` | ~47KB | | Tailwind v4 | `@neondatabase/neon-js/ui/tailwind` | ~2KB (tokens only) | **Never import both** - causes duplicate styles (~94KB). Import order doesn't matter - auth UI styles are wrapped in `@layer neon-auth`, giving your unlayered styles automatic priority. ### Without Tailwind ```typescript // In layout.tsx or _app.tsx import "@neondatabase/neon-js/ui/css"; ``` ### With Tailwind v4 ```css /* globals.css */ @import 'tailwindcss'; @import '@neondatabase/neon-js/ui/tailwind'; /* Your theme variables (if any) - auth will inherit these automatically */ ``` ## Customization Options ### Option 1: Use Your Existing Theme (Recommended) If you already have theme variables defined, auth components inherit them automatically: ```css /* Your existing theme - auth uses these automatically */ :root { --primary: oklch(0.55 0.25 250); /* Auth buttons will be blue */ --primary-foreground: oklch(0.98 0 0); --background: oklch(1 0 0); --foreground: oklch(0.145 0 0); /* ... */ } ``` No additional configuration needed! ### Option 2: Auth-Specific Customization To customize auth components differently from your main app, use the `--neon-*` prefix: ```css :root { /* Your app's primary color */ --primary: oklch(0.55 0.25 250); /* Blue */ /* Override just for auth components */ --neon-primary: oklch(0.55 0.18 145); /* Green - only auth uses this */ } ``` ### Complete `--neon-*` Variable Reference | Variable | Inherits From | Default (Light) | |----------|---------------|-----------------| | `--neon-primary` | `--primary` | `oklch(0.205 0 0)` | | `--neon-primary-foreground` | `--primary-foreground` | `oklch(0.985 0 0)` | | `--neon-secondary` | `--secondary` | `oklch(0.97 0 0)` | | `--neon-secondary-foreground` | `--secondary-foreground` | `oklch(0.205 0 0)` | | `--neon-background` | `--background` | `oklch(1 0 0)` | | `--neon-foreground` | `--foreground` | `oklch(0.145 0 0)` | | `--neon-muted` | `--muted` | `oklch(0.97 0 0)` | | `--neon-muted-foreground` | `--muted-foreground` | `oklch(0.556 0 0)` | | `--neon-accent` | `--accent` | `oklch(0.97 0 0)` | | `--neon-accent-foreground` | `--accent-foreground` | `oklch(0.205 0 0)` | | `--neon-destructive` | `--destructive` | `oklch(0.577 0.245 27.325)` | | `--neon-card` | `--card` | `oklch(1 0 0)` | | `--neon-card-foreground` | `--card-foreground` | `oklch(0.145 0 0)` | | `--neon-border` | `--border` | `oklch(0.922 0 0)` | | `--neon-input` | `--input` | `oklch(0.922 0 0)` | | `--neon-ring` | `--ring` | `oklch(0.708 0 0)` | | `--neon-radius` | `--radius` | `0.625rem` | ## Token Pairing Rules **Always override pairs together** to maintain contrast (min 4.5:1 ratio). | Background Token | Foreground Token | |-----------------|------------------| | `--primary` | `--primary-foreground` | | `--secondary` | `--secondary-foreground` | | `--background` | `--foreground` | | `--muted` | `--muted-foreground` | | `--accent` | `--accent-foreground` | | `--destructive` | `--destructive-foreground` | | `--card` | `--card-foreground` | If you only define `--primary` without `--primary-foreground`, contrast issues may occur. ## Dark Mode ### Dark Mode Fallback Behavior If you define a variable in `:root` but not in `.dark`: - **Light mode**: Uses your value - **Dark mode**: Uses auth's default dark value **Recommendation**: If customizing, define both light and dark modes. ### Option 1: next-themes (Recommended for Next.js) ```bash npm install next-themes ``` ```typescript // app/layout.tsx import { ThemeProvider } from "next-themes"; export default function Layout({ children }: { children: React.ReactNode }) { return (