© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2021
J. KrauseDeveloping Web Components with TypeScripthttps://doi.org/10.1007/978-1-4842-6840-7_6

6. Slots

Jörg Krause1  
(1)
Berlin, Berlin, Germany
 

A slot is a placeholder that users can fill with their own markup. The slot may exist outside a Web Component or inside, in conjunction with a template or a Shadow DOM (or both).

Slots Explained

Many types of components, such as tabs, menus, image galleries, and so on, need dynamic content to render properly. Just like a browser’s built-in element <select> expects <option> items, a <custom-tabs> may expect the actual tab content to be passed. And a <custom-menu> may expect menu items.

The code that makes use of <custom-menu> ...

Get Developing Web Components with TypeScript: Native Web Development Using Thin Libraries now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.