(Docs)
Another way to give components a parent-child relationship
Provide unique names so that multiple slots can get their own stuff
Default stuff to show in case nothing is passed to the slot.
A couple of benefits of using slots:
- Can pass arbitrary content to child components
- Passing components to children is a breeze
- We can have even less logic in our children
- Can make code more reusable
- Looks kinda nice
To see an example of a project with slots vs the same project with props, check out this repo: https://github.com/CassandraGoose/props-vs-slots
1. What are slots?
- Another way to create child/parent relationships between components. 2. When should I use them?
- When it can make your components more reusable and versatile.
By Cassandra Torske