# Content >> Tabs >> Features ||20 ```js script import { LitElement, html } from '@mdjs/mdjs-preview'; import '@lion/tabs/define'; ``` ## Selected Index You can set the `selectedIndex` to select a certain tab. ```js preview-story export const selectedIndex = () => html`

Info page with lots of information about us.

Work page that showcases our work.

`; ``` ## Slots Order The tab and panel slots are ordered by DOM order. This means you can switch the grouping in your `lion-tabs` from tab + panel to all tabs first or all panels first. ```js preview-story export const slotsOrder = () => html`

Info page with lots of information about us.

Work page that showcases our work.

`; ``` ## Nesting tabs You can include tabs within tabs ```js preview-story export const nestedTabs = () => html`

Find some more info about our favorite movies:

Cars is a 2006 American computer-animated comedy film produced by Pixar Animation Studios and released by Walt Disney Pictures.

The feature film directorial debut of John Lasseter, it was the first entirely computer-animated feature film, as well as the first feature film from Pixar.

Work page that showcases our work.

`; ``` ## Distribute New Elements Below, we demonstrate on how you could dynamically add new tab + panels. ```js preview-story export const distributeNewElement = () => { const tagName = 'demo-tabs-add-dynamically'; if (!customElements.get(tagName)) { customElements.define( tagName, class extends LitElement { static get properties() { return { __collection: { type: Array }, }; } render() { return html`

Append

panel 1

panel 2


Push

panel 1

panel 2

${this.__collection.map( item => html`

${item.panel}

`, )}
`; } constructor() { super(); this.__collection = []; } __handleAppendClick() { const tabsElement = this.shadowRoot.querySelector('#appendTabs'); const c = 2; const n = Math.floor(tabsElement.children.length / 2); for (let i = n + 1; i < n + c; i += 1) { const tab = document.createElement('button'); tab.setAttribute('slot', 'tab'); tab.innerText = `tab ${i}`; const panel = document.createElement('p'); panel.setAttribute('slot', 'panel'); panel.innerText = `panel ${i}`; tabsElement.append(tab); tabsElement.append(panel); } } __handlePushClick() { const tabsElement = this.shadowRoot.querySelector('#pushTabs'); const i = Math.floor(tabsElement.children.length / 2) + 1; this.__collection = [ ...this.__collection, { button: `tab ${i}`, panel: `panel ${i}`, }, ]; } }, ); } return html` `; }; ``` One way is by creating the DOM elements and appending them as needed. Inside your `lion-tabs` extension, an example for appending nodes on a certain button click: ```js __handleAppendClick() { const tabsAmount = this.children.length / 2; const tab = document.createElement('button'); tab.setAttribute('slot', 'tab'); tab.innerText = `tab ${tabsAmount + 1}`; const panel = document.createElement('p'); panel.setAttribute('slot', 'panel'); panel.innerText = `panel ${tabsAmount + 1}`; this.append(tab); this.append(panel); } ``` The other way is by adding data to a Lit property where you loop over this property in your template. You then need to ensure this causes a re-render. ```js __handlePushClick() { const tabsAmount = this.children.length; myCollection = [ ...myCollection, { button: `tab ${tabsAmount + 1}`, panel: `panel ${tabsAmount + 1}`, }, ]; renderMyCollection(); } ``` Make sure your template re-renders when myCollection is updated. ```html ${myCollection.map(item => html`

${item.panel}

`)}
```