Vue Component Patterns (Esposter)
How an individual component is written, typed and named. Assembling a page or list _from_ components — decomposition, v-for items, action items, singleton dialogs — is the vue-page-composition skill's.
Deep dives
references/props-and-generics.md— when a prop or model type depends on a value-set or discriminant key, when one component is absorbing several data variants, or when a boolean prop has a default.references/component-naming.md— when creating, renaming or moving a component file, when a directory of components gets crowded, or when a tag renders empty with no error.references/shared-shell.md— when a page needs chrome, or a new product or editor is added.references/async-components.md— when a map dispatches a heavy component, or a component awaits in setup behind av-if.references/slots.md— when a component declares a slot, forwards an optional slot into a library component, or a named slot's content has grown non-trivial.references/structured-containers.md— when a component frames other content (a dialog, popover, drawer, card, panel or editor region), or a call site of one writes its own padding, scroll wrapper or footer in the slot.references/abstraction-levels.md— when a script setup mixes a composable with a hand-built block for one concept.references/normal-form.md— when a.vueis past the file-length target, a script has grown long, or a feature's wiring is about to be added to a component that already wires several.references/splitting-a-component.md— when a.vueseveral times past the file-length target is about to be cut, by a session or a delegated agent.references/selection-and-keys.md— when a child reads the selection, initialises state from a prop, or a:keywould be bumped.references/wrapper-and-child.md— when a component initialises editable state from data that may not have arrived.
Shared Shell / Design-System Primitives — `references/shared-shell.md`
Cross-product chrome is a small set of shared components in apps/web/app/components/Ui/ (the UI library) and apps/web/app/components/App/ (app-chrome) — reuse them, never re-roll a bare toolbar per editor. Their design and rationale live in openspec/specs/resource/shell-cohesion/design.md.
The resource layout's page header, UiEmptyState, UiSkeleton and AppBreadcrumbs are the set; what each is for, and what a new product or editor wires up (its page's header, a launcher entry), is that page. A search of its own is a scope of the one command palette (the ui-library skill, references/keys-and-commands.md).
Same Level of Abstraction
Every statement in <script setup> sits at one conceptual level — a lower-level block moves to the store or composable that owns its concept (references/abstraction-levels.md).
Selection State: Read the Store, Don't Thread Props
A child reads the selection from the store rather than a threaded prop; local state initialised from a prop resets through :key, which names the thing rendered and is never a counter (references/selection-and-keys.md).
Async Data: Wrapper + Pure Child Pattern
Data that may arrive after mount splits into an Index.vue wrapper owning the lookup and v-if, and a pure child taking it as a required prop (references/wrapper-and-child.md).
A Registry of Heavy Components Loads on Demand — `references/async-components.md`
A map dispatching a component by type puts every entry in its importer's chunk, so a registry whose entries carry heavy vendors holds defineAsyncComponent(() => import(...)) loaders, and every render site of it puts the <component :is> inside a <Suspense> whose fallback is a UiSkeleton sized to the region. A registry of small components stays static, and a component that awaits in setup behind a v-if owes the same boundary.
Boolean Props — `is` Prefix + Default-Aware Literal Typing
isprefix. Boolean props read as a question:isDense,isInteractive,isOpen— never baredense/interactive/open, and nevercan*/should*(preferis, fall back tohas— thenamingskill, "Booleans"). The same applies todefineModel/ emit payloads.- Type as the non-default literal, not
boolean, so passing the default is impossible: defaults-false →?: true | undefined(caller opts in with the bare attribute), defaults-true →?: false | undefinedwith a destructure default= true. Every optional prop carries| undefined, since a template leaves a prop out by bindingundefined(theabsent-valuesskill). Derived values, and the genuinely two-way boolean, are inreferences/props-and-generics.md.
A Prop, Slot Or Emit Earns Its Place By A Caller
A prop, slot or emit no call site passes or listens to is deleted with the test that pinned it, the day it is found unused: a flag added "so a future caller can opt out" is a switch nothing needs, and a spec that asks for one waits until a caller does (the over-engineering skill's catalogue row on flags, file-organization references/extraction-and-duplication.md). Before adding one, name the call site that passes it; before keeping one in review, grep its callers.
Emits — Present-Tense Event Names
Emit names are present-tense verbs: delete, update, create, save, submit — never past tense (deleted, updated, copied). The event names the action the parent should handle, not a completed fact; past-tense names also drift from Vue/DOM convention (click, submit, change).
For state-sync emits, use the update:x form where x is the state name ("update:copied": [boolean]) — the verb stays present tense; the state name may be any shape.
Template Handlers Stay Inline
A multi-statement handler is written inline in the template binding (@submit="async (_event, onComplete) => { … }"), and it stays there unless one of the exceptions the vue skill's inline-handler page holds applies (references/inline-handlers.md).
Component Folder Naming — `references/component-naming.md`
A component that gains a folder moves into it as Index.vue, never beside the folder; the folder path is the prefix and is never repeated in the filename, since Nuxt builds the auto-import name from both.
File Length
The line-count target and its exception are the file-organization skill's, "File Length". What a .vue over it is split into, and the shape a component in normal form has, is references/normal-form.md. How an extracted slot is named and where it lives is references/slots.md.
Containers — `references/structured-containers.md`
A component that frames other content owns its regions (header, body, footer), their scroll, padding and pinning, and a call site supplies content to the default and named slots and never writes a body wrapper, a footer in the default slot or a fixed body height.
Slots
Every component that renders a <slot> declares defineSlots — typed slot contracts, same as props (defineSlots<{ default: () => VNode }>(); ?: when the consumer may omit it). Forwarding an _optional_ slot into a library component that falls back to a prop needs #default + v-if on the same template, and extracting a non-trivial slot's content into its own component follows a naming convention — both in references/slots.md.