#How to pass a prop from Layout into Slot?

2 messages · Page 1 of 1 (latest)

kind vortex
#

I have a base layout that contains a <slot /> component. I would like to pass props to the slot like <slot foo="bar" /> but the Astro.props received in the page does not include these attributes.

I currently have a workaround using svelte stores. but is there a way to do this?

lament cairn
#

A slot is just a place where you render something that you define in the place of use. So usually you want to define your props there. If you want to modify the props in the place where the slot is, you might want to check out the Astro.slots.render API and use those results with a Fragment set:html