# Tabs

Tabs give the option to separate elements further by grouping them, and only showing a handfull each time. Tabs reset the order so they can be thinked of as subpaths but work as components so they are very versatile! In the following images we can see that groups of components  with complex behaviour ([bentobox](https://docs.shimoku.com/dev/elements/features-and-navigation/broken-reference) and [grid](https://docs.shimoku.com/dev/building-web-app/grid) behaviour) are being rendered correctly:

{% tabs %}
{% tab title="Simple Tab" %}

<figure><img src="https://3782181538-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUlHTfmIZY46Z1EDfyGMz%2Fuploads%2FiDWO3Juj3PCvIxXuAMcd%2Fimage.png?alt=media&#x26;token=fecab99f-4e64-4737-87e0-3eadc304751a" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Tab with Grid" %}

<figure><img src="https://3782181538-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUlHTfmIZY46Z1EDfyGMz%2Fuploads%2FFbkvAGgxMxH8umsfOT33%2Fimage.png?alt=media&#x26;token=da7c461a-763a-4f87-b2b1-816f80a02136" alt=""><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

### Usage

To use it you just have to define the location of the chart the same way you define the menu, it needs a tabs group name and the name of the tab where it will be inserted:

```python
s.plt.set_tabs_index((tabs_group_name, tab_name))
...  # Charts
s.plt.pop_out_of_tabs_group()
```

The function is called `s.plt.set_tabs_index` and it has the parameters:

```python
tabs_index: Tuple[str, str]                          # The tab to be used
order: Optional[int] = None                          # The order in the menu path
parent_tabs_index: Optional[Tuple[str, str]] = None  # The parent tabs group
padding: Optional[str] = None                        # Padding in the view
cols_size: Optional[str] = None                      # Horizontal size
rows_size: Optional[int] = None                      # Vertical size
just_labels: Optional[bool] = None                   # Visual variant
sticky: Optional[bool] = None                        # Follow the scroll or not
```

To change the tab being used the function `s.plt.change_current_tab` has to be used, an example on how to use the tabs functionality:&#x20;

```python
s.plt.set_tabs_index(('Charts', 'Indicators Tab'), order=0)

s.plt.indicator(
    order=0, data={
        "description": "",
        "title": "",
        "value": "Indicator",
        "color": "warning"
    }
)
s.plt.change_current_tab('Bars Tab')
s.plt.bar(
    x='date', order=0, data=[
        {'date': dt.date(2021, 1, 1), 'x': 5, 'y': 5},
        {'date': dt.date(2021, 1, 2), 'x': 6, 'y': 5},
        {'date': dt.date(2021, 1, 3), 'x': 4, 'y': 5},
        {'date': dt.date(2021, 1, 4), 'x': 7, 'y': 5},
        {'date': dt.date(2021, 1, 5), 'x': 3, 'y': 5}
    ]
)

s.plt.pop_out_of_tabs_group()
```

{% tabs %}
{% tab title="Indicators Tab" %}

<figure><img src="https://3782181538-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUlHTfmIZY46Z1EDfyGMz%2Fuploads%2FfuDqW0Z1OM6EiMr8CLFD%2FIndicators%20Tab.png?alt=media&#x26;token=4a6285b5-fa2a-4126-9c4c-953ae316f839" alt=""><figcaption><p>Indicators tab</p></figcaption></figure>
{% endtab %}

{% tab title="Bars Tab" %}

<figure><img src="https://3782181538-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUlHTfmIZY46Z1EDfyGMz%2Fuploads%2FowGdcfiw1MvvyhhDAs1R%2FBars%20Tab.png?alt=media&#x26;token=095a4bbe-d98f-4d0d-bef7-b71637376d09" alt=""><figcaption><p>Bars tab</p></figcaption></figure>
{% endtab %}
{% endtabs %}

## Positioning & Style Variants

Tabs can stick to the top of the screen when scrolling by setting the parameter `sticky` to `True`. They also have two variants, one where they are enclosed:

<figure><img src="https://3782181538-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUlHTfmIZY46Z1EDfyGMz%2Fuploads%2FiNq4aXp44arF6lrzNuoV%2Fimage.png?alt=media&#x26;token=4f52c2b9-84a9-48e0-a232-c8114d0f69ed" alt=""><figcaption></figcaption></figure>

and one where they are separated:

<figure><img src="https://3782181538-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUlHTfmIZY46Z1EDfyGMz%2Fuploads%2FWhm4mHNFxUWy05EuxiZ5%2Fimage.png?alt=media&#x26;token=dbaf0629-82af-4ed8-8035-b3c1ce66b593" alt=""><figcaption></figcaption></figure>

## Recursive Inclusion

Tabs groups can be included in other tabs groups, this brings a lot of flexibility on the separation of information and distribution of elements. To use this functionality the parameter `parent_tabs_index` has to be used to inform where to include the tabs group.

The different styles of tabs can be useful to differentiate between shallower and deeper tabs, the following example uses two types of tabs:

```python
s.plt.set_tabs_index(('Gauge Indicators Head', 'Lorem ispum'), order=0)

s.plt.gauge_indicator(
    order=0, value=random.randint(0, 100),
    title='Lorem ispum', description='Lorem ispum',
)
s.plt.set_tabs_index(('Gauge Indicators', 'Lorem ispum'), order=0, just_labels=True,
                     parent_tabs_index=('Gauge Indicators Head', 'Lorem ispum'))

s.plt.gauge_indicator(
    order=0, value=random.randint(0, 100),
    title='Lorem ispum', description='Lorem ispum',
)

s.plt.pop_out_of_tabs_group()
```

<figure><img src="https://3782181538-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUlHTfmIZY46Z1EDfyGMz%2Fuploads%2F1oPDe8Ep3NpbwOQ5beTP%2FTab%20within%20tab.png?alt=media&#x26;token=67c7e7a0-4122-4d66-8d1c-3a6e3a747dab" alt=""><figcaption><p>Tabs group inside a tabs group</p></figcaption></figure>
