> Markdown version of [Dynamically Adding Server-side Components to Templates](https://vaadin.com/docs/v23/create-ui/templates/polymer/polymer-template-components-in-slot). Section index: [llms.txt](https://vaadin.com/docs/v23/create-ui/llms.txt)

# Dynamically Adding Server-Side Components to Templates

(deprecated since V18)

**Polymer templates are deprecated. Lit templates are recommended instead.**

## <a id="using-the-slot-element"></a>Using the Slot Element

**Example**: `<slot>` element in a JavaScript Polymer template.

```javascript
import { PolymerElement, html } from '@polymer/polymer/polymer-element.js';

class ComponentContainer extends PolymerElement {
  static get template() {
    return html`
      <div>
        <slot></slot>
      </div>
    `;
  }

  static get is() {
    return 'component-container';
  }
}

customElements.define(ComponentContainer.is, ComponentContainer);
```

**Example**: Mapped Java template class.

```java
@Tag("component-container")
@JsModule("./com/example/component-container.js")
public class ComponentContainer extends PolymerTemplate<TemplateModel> {

    public ComponentContainer() {
        Element label = ElementFactory.createLabel("Main layout header");
        Element button = ElementFactory.createButton("Click me");

        getElement().appendChild(label, button);
    }
}
```

- Without the `<slot>` tag in the JavaScript Polymer template, the `label` and `button` would not be visible to the user, even though they can be located in the DOM.

- You can add multiple components that display in the slot when added to a template element with an open `<slot></slot>`.

- You can remove any element from a `<slot>`. It works as expected and no longer display in the main element.

`62162028-E8BC-4333-BEDD-CEB9DD2BFD73`
