Use v-model as syntactic sugar for an update:modelValue event pattern.
Validate emits at runtime by passing a validation function to defineEmits.
Details
Vue's event system follows a "props down, events up" pattern. Parents pass data to children via props; children notify parents via emitted events. This creates a clear, unidirectional data flow that is easy to trace and debug.
Trade-offs:
Events only travel one level up — for deeply nested communication, use provide/inject or a store
Untyped emits (array syntax) provide no compile-time safety — always use the typed syntax
Event names are strings — typos are caught at runtime, not compile time (unless using TypeScript with defineEmits)
When NOT to use:
For deeply nested parent-child communication — use provide/inject or Pinia
For sibling component communication — use a shared store or event bus (though event buses are discouraged in Vue 3)
When the parent does not need to know about the event — side effects belong in the child
Read the instructions and examples in this document.
Apply the patterns to your implementation, adapting to your specific context.
Verify your implementation against the details and edge cases listed above.
Harness Integration
Type: knowledge — this skill is a reference document, not a procedural workflow.
No tools or state — consumed as context by other skills and agents.
Success Criteria
The patterns described in this document are applied correctly in the implementation.
Edge cases and anti-patterns listed in this document are avoided.
1---2name: vue-component-events3description: Vue Component Events4---5# Vue Component Events67> Communicate from child to parent components using emits and defineEmits89## When to Use1011- A child component needs to notify its parent of user actions or state changes12- Implementing form inputs, buttons, or interactive components that report values upward13- Building reusable components with a clear input/output contract (props down, events up)1415## Instructions16171. Declare events with `defineEmits<{ eventName: [payload: Type] }>()` in `<script setup>`.182. Emit events with `emit('eventName', payload)`.193. The parent listens with `@event-name="handler"` (kebab-case in template).204. Always type your emit payloads for compile-time safety.2122```vue23<!-- ChildButton.vue -->24<script setup lang="ts">25const emit = defineEmits<{26 click: [id: number];27 update: [value: string];28}>();29</script>3031<template>32 <button @click="emit('click', 42)">Click</button>33</template>3435<!-- Parent.vue -->36<ChildButton @click="handleClick" @update="handleUpdate" />37```38395. Use `v-model` as syntactic sugar for an `update:modelValue` event pattern.406. Validate emits at runtime by passing a validation function to `defineEmits`.4142## Details4344Vue's event system follows a "props down, events up" pattern. Parents pass data to children via props; children notify parents via emitted events. This creates a clear, unidirectional data flow that is easy to trace and debug.4546**Trade-offs:**4748- Events only travel one level up — for deeply nested communication, use `provide`/`inject` or a store49- Untyped emits (array syntax) provide no compile-time safety — always use the typed syntax50- Event names are strings — typos are caught at runtime, not compile time (unless using TypeScript with `defineEmits`)5152**When NOT to use:**5354- For deeply nested parent-child communication — use `provide`/`inject` or Pinia55- For sibling component communication — use a shared store or event bus (though event buses are discouraged in Vue 3)56- When the parent does not need to know about the event — side effects belong in the child5758## Source5960https://patterns.dev/vue/component-events6162## Process63641. Read the instructions and examples in this document.652. Apply the patterns to your implementation, adapting to your specific context.663. Verify your implementation against the details and edge cases listed above.6768## Harness Integration6970- **Type:** knowledge — this skill is a reference document, not a procedural workflow.71- **No tools or state** — consumed as context by other skills and agents.7273## Success Criteria7475- The patterns described in this document are applied correctly in the implementation.76- Edge cases and anti-patterns listed in this document are avoided.
Run npx skillmds@latest add intense-visions/vue-component-events in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Vue Component Events It is listed under Web & Frontend on SkillMD.
This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
Intense-Visions (@intense-visions) published this skill. Their other Agent Skills are listed on their SkillMD profile.