---
name: vue-component-builder
description: "Scaffolds a complete Vue single-file component from a spec: typed props with defaults, reactive state, methods, declared emits, and styles in the API style that matches your Vue version, ready to drop into the project. Use when you need a new Vue component scaffolded from a list of props, state, methods, and emits in the right API style for your Vue version. Do not use for assembling markup and logic you already wrote into a file, or splitting a large component into smaller ones. Related topics: coding, vue."
---

# Vue Component Builder

Scaffolds a complete Vue single-file component from a spec: typed props with defaults, reactive state, methods, declared emits, and styles in the API style that matches your Vue version, ready to drop into the project.

## When to use

Use this skill when you need a new Vue component scaffolded from a list of props, state, methods, and emits in the right API style for your Vue version. Do not use it for assembling markup and logic you already wrote into a file, or splitting a large component into smaller ones.

## Workflow

1. Ask the user for each input listed below in a single message, skipping any they have already given. Where options are listed, offer them, but accept other answers too.
2. Declare every prop with type, default or required flag, and a validator for enumerated values, in the requested API style.
3. Declare each emitted event (typed when TypeScript is on) and wire v-model conventions for the chosen Vue version where update is listed.
4. Implement state and methods in the chosen style so no Options API syntax leaks into script setup or the reverse.
5. Write the template so every prop and state field is rendered or bound, with a comment where the spec left rendering open.
6. Add scoped styles in the chosen language (empty block for Tailwind) and note any assumption made for a spec gap.

## Inputs

- **Component name** (free text, e.g. "UserCard")
- **Vue version and API style** (choose one: Vue 3 script setup, Vue 3 Composition API, Vue 3 Options API, Vue 2 Options API)
- **Props** (longer free text)
- **Reactive state** (longer free text)
- **Methods** (longer free text)
- **Emits** (choose any: submit, cancel, update, close, change, custom)
- **Style language** (choose one: CSS, SCSS, Tailwind)
- **TypeScript** (choose one: Yes, No)

## Output

One vue code block with the complete single-file component (template, script, style in that order), then a two-line note on assumptions.

## Prompt template

Fill the inputs into this template and follow it as the full instruction.

### Vue Component Builder

Generate a new single-file component from the spec below.

- Component name: {{Component name}}
- Vue version and API style: {{Vue version and API style}}
- Props: {{Props}}
- Reactive state: {{Reactive state}}
- Methods: {{Methods}}
- Emits: {{Emits}}
- Style language: {{Style language}}
- TypeScript: {{TypeScript}}

Write the component in the requested API style only; a Vue 2 component gets data(), methods, and this, while script setup gets defineProps, defineEmits, ref, and computed. Declare every prop with a type and a default or required flag, and validate enumerated props with a validator. Declare every emitted event in emits (or defineEmits with a typed signature when TypeScript is on) so the parent sees the contract. Use v-model conventions where an update event is listed: modelValue prop and update:modelValue emit on Vue 3, value and input on Vue 2.

Build the template from the props and state so every declared field is used; leave a short comment where the spec did not say what a method should render. Scope the styles, and when Tailwind is chosen write utility classes in the template and leave the style block empty. Keep the component free of global state unless the spec names a store.

### Output
Return the full .vue file in one code block tagged vue, with template, script, and style sections in that order, followed by a two-line note on any spec gap you filled with an assumption.

## Pitfalls

- Mixing Options API data() with script setup refs, which produces a file that neither Vue version accepts.
- Emitting events that are not declared in emits, so Vue 3 treats them as native listeners on the root element.
- Using Vue 3 v-model names (modelValue) on a Vue 2 component where the convention is value and input.
