Concept Flow - Props for parent to child data
Parent Component
Child Component
Use props in template or script
Render child with passed data
The parent sends data to the child using props. The child receives and uses this data to render or compute.
<template> <ChildComponent :message="parentMessage" /> </template> <script setup> const parentMessage = 'Hello from Parent' </script>
| Step | Action | Parent Data | Prop Passed | Child Receives | Child Renders |
|---|---|---|---|---|---|
| 1 | Parent defines 'parentMessage' = 'Hello from Parent' | parentMessage = 'Hello from Parent' | N/A | N/A | N/A |
| 2 | Parent renders <ChildComponent :message='parentMessage' /> | parentMessage = 'Hello from Parent' | message = 'Hello from Parent' | N/A | N/A |
| 3 | Child receives prop 'message' | parentMessage = 'Hello from Parent' | message = 'Hello from Parent' | message = 'Hello from Parent' | N/A |
| 4 | Child renders template using 'message' | parentMessage = 'Hello from Parent' | message = 'Hello from Parent' | message = 'Hello from Parent' | Displays: Hello from Parent |
| Variable | Start | After Step 1 | After Step 2 | After Step 3 | Final |
|---|---|---|---|---|---|
| parentMessage | undefined | 'Hello from Parent' | 'Hello from Parent' | 'Hello from Parent' | 'Hello from Parent' |
| message (prop in child) | undefined | undefined | 'Hello from Parent' | 'Hello from Parent' | 'Hello from Parent' |
Props let a parent send data to a child component. Parent passes data using :propName="value" syntax. Child declares props to receive them. Child uses props in template or script. Props are reactive and update child on change.