Design reusable Vue component APIs with slots and v-model

8 steps · about 2 h 15 min · Intermediate

  1. Define and use your first Vue component (tutorial, Vue.js, 20 min)

    Covers defining, importing and nesting components in one pass.

  2. Create a to-do item component step by step (tutorial, MDN, 25 min)

    Builds a real component inside a small app so the parts make sense together.

  3. Organise components as single-file components (reference, Vue.js, 10 min)

    Explains why template, logic and styles live together in one file.

  4. Type props and emits with defineProps and defineEmits (reference, Vue.js, 20 min)

    The exact compiler macros for a typed, documented component contract.

  5. Support v-model on a custom input component (reference, Vue.js, 15 min)

    Lets your form components work with two-way binding like native inputs.

  6. Pass markup into a component with slots (reference, Vue.js, 20 min)

    Named and scoped slots are what make layout components reusable.

  7. Control fallthrough attributes (reference, Vue.js, 10 min)

    Stops class, id and listeners landing on the wrong element.

  8. Share data deep in the tree with provide and inject (reference, Vue.js, 15 min)

    Avoids passing the same prop through many layers.