--- name: svelte-frontend description: Svelte coding guidelines for the Windmill frontend. MUST use when writing or modifying code in the frontend directory. --- # Windmill Svelte Patterns Apply these Windmill-specific patterns when writing Svelte code in `frontend/`. For general Svelte 5 syntax (runes, snippets, event handling), use the Svelte MCP server. ## Before writing any UI (MUST) Do both of these before the first line of markup — not after, and not only when something looks unfamiliar. **1. Find the component that already exists.** `frontend/src/lib/components/common/index.ts` is the design-system barrel — 28 lines, read it in full. It exports far more than the three documented below: `Alert`, `Badge`, `Breadcrumb`, `Drawer`/`DrawerContent`, `Menu`/`MenuItem`, `Tabs`/`Tab`/`TabContent`, `Skeleton`, `FileInput`, `RadioCard`, `Section`, `Kbd`, `ActionRow`, `ClearableInput`, `CopyButton`, `SecondsInput`, `UndoRedo`, `Url`. The barrel is not the full picture either: `common/` has 34 subdirectories and only 23 exports, so `modal/`, `popup/`, `stepper/`, `tooltip/`, `checkbox/`, `table/`, `contextmenu/`, `confirmationModal/`, `calendarPicker/`, `fileUpload/`, `toggleButton-v2/` and more exist but must be imported by path. Selects, text inputs and melt-based primitives sit next to `common/` in `components/select/`, `components/text_input/`, `components/meltComponents/`. The tree holds 1,600+ components — grep `frontend/src/lib/components` for the thing you're about to build; it almost certainly exists. Building a new one is the last resort, not the first move. **2. Read the guideline for what you're building.** `frontend/brand-guidelines.md` is the authority on how it should look and read. Don't load all 34k chars — jump to the section: | Building | Section to read | |---|---| | Any new screen or component | `# Components` (Core Rules, Quick Reference) | | Buttons, CTAs | `## Buttons` — hierarchy matters, only one Accent per view | | Colors, surfaces, borders | `# Color system` (Quick Reference, Do's and Don'ts) | | Text, labels, headings | `# Typography` — note `## Text Casing`, sentence case throughout | | Spacing, grids, page structure | `# Spacing & Layout`; `# Layout` → `## Form` for forms | | Shadows, overlays, depth | `# Elevation` | | Icons | `# Iconography` | | Wording of any UI copy | `# Voice & Communication`, `# Tone of Voice` | Get the line range with `grep -n '^#' frontend/brand-guidelines.md`, then read just that span. ## Windmill UI Components (MUST use) Always use Windmill's design-system components. Never use raw HTML elements. The three below are the ones you'll reach for most often — they are examples, not the catalog. For anything else, go back to the barrel and grep. ### Buttons — `