# Examples

### Creating a tabbed content group

Creating a tabbed content group in Bloqs is pretty easy when using nested bloqs. You can put as many bloqs or components inside of a tab. In this example there is a single component in each tab.

![](https://3476660910-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Ly1eNBG1JvS5rivVtg3%2Fuploads%2FWJKpbCEFXeXpUxYzlduI%2Fbloqs-tab-group-example.png?alt=media\&token=0629940f-cfc4-41da-bc2c-e2b384bbe5cd)

The template markup is where the magic happens. Since Bloqs lets you repeat the same tag pair more than once in the page, you'll create two different loops. The first loop is to render all of your tabs, either in a list, or in this example a series of buttons. And the second loop will render the actual tab panel itself, which will render the contents, or children of each tab, through the `{bloqs:children}` variable.

```
{block_tab}
    {if bloqs:is:first_child}
        <div role="tablist">
    {/if}

        <button
            role="tab"
            aria-controls="{tab_id}"
            tabindex="0"
            aria-selected="{if bloqs:is:first_child}true{if:else}false{/if}"
            data-text="{tab_label:attr_safe}"
        >
            {tab_label}
        </button>

    {if bloqs:is:last_child}
        </div>
    {/if}
{/block_tab}

{block_tab}
    {if bloqs:is:first_child}
        <div class="tab-group__panel-container">
    {/if}

        <div
            id="{tab_id}"
            role="tabpanel"
            aria-expanded="{if bloqs:is:first_child}true{if:else}false{/if}"
        >
            {bloqs:children}
        </div>

    {if bloqs:is:last_child}
        </div>
    {/if}
{/block_tab}
```

### Displaying Assets fields in Bloqs

```
{bloqs_field}
    {asset_field}
        {!-- Looping over multiple files in an Assets field --}
        {asset_field:file}
            <img src="{url}" />
        {/asset_field:file}
        
        {!-- Displaying a single file in an Assets field --}
        {asset_field}
            <img src="{file:url}" />
        {/asset_field}
    {/asset_field}
{/bloqs_field}
```
