Back to stories
<Frontend/>
Premium

Vue Slots, Render Functions, and provide/inject: Advanced Composition

Share by

Vue Slots, Render Functions, and provide/inject: Advanced Composition

Vue's slots let parents inject template fragments into child components; render functions let you build VNodes in JavaScript; provide/inject lets ancestors pass values to descendants without prop drilling. Together they support flexible, reusable components and advanced patterns. This post covers when and how to use each.


Slots: default, named, and scoped

A slot is a placeholder in the child's template that the parent fills with content. Default slot: one unnamed outlet; the parent's children (between the component tags) go there. Named slots: multiple outlets; the parent uses v-slot:name or #name to target them. Scoped slots: the child passes data into the slot; the parent receives it as a slot prop and can use it in the slot content.