> For the complete documentation index, see [llms.txt](https://atomico.gitbook.io/doc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://atomico.gitbook.io/doc/guides/atomico-design-patterns/slot.md).

# Slot

The use of slots improves the composition allowing to reflect the content exposed in the `lightDOM` of the component in the `shadowDOM` of this, example:

![](/files/-MbXmejbSIl8PkxrQd24)

{% hint style="info" %}
The use of slot is thanks to the use of the **ShadowDOM** api, to make use of the shadowDom you must declare it as a property of the host tag, example:

`<host shadowDom>`I exist inside the shadowDOM`</host>`
{% endhint %}

### ::slotted(\<selector>)

The `slotted` selector allows the manipulation of the content exposed as a `lightDOM` slot from the `shadowDOM`, example:

![](/files/-MbXpfOBQonGJQg5QVl5)

### Auto slot

With Atomico you can define a default slot for your components, this is useful if you want to maintain some compositional consistency without the need to declare the use of slot, example:

```markup
<my-component>
    <my-component-header></my-component-header>
    <my-component-footer></my-component-footer>
</my-component>
```

To define a default slot, you only have to declare `slot` in the props, example:

```javascript
myComponentHeader.props = {
    slot: { type: String, value: "header" }
}

myComponentFooter.props = {
    slot: { type: String, value: "footer" }
}
```

Consider this practical only if the composition is leveraged to the container, this does not prevent you from modifying the slot property from the component instance.

### Conditional slot

Atomico has the hook [**@atomico/hooks/use-slot**](/doc/packages/atomico-hooks/use-slot.md) that appends the slotchange event to a reference, this will allow you to hide slots if they do not declare content, example:

```jsx
import { useRef } from "atomico";
import { useSlot } from "@atomico/hooks/use-slot";

function component() {
    const ref = useRef();
    const childNodes = useSlot(ref);
    return <host shadowDom>
        <header style={{
            display: childNodes.length? "block": "none"
        }}>
            <slot name="header" ref={ref} />
        </header>
    </host>
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://atomico.gitbook.io/doc/guides/atomico-design-patterns/slot.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
