<!--
{
  "documentType" : "article",
  "framework" : "TVML",
  "identifier" : "/documentation/TVML/stacktemplate",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "stackTemplate"
}
-->

# stackTemplate

Displays groups of products.

## Overview

Use the `stackTemplate` element to display, for example, displaying different genres
of movies. Each group of products is displayed directly underneath the previous group.
Products can be displayed in different ways using `carousel`, `grid`, and `shelf`
elements. The following figure shows the basic layout for a `stackTemplate` page.
The theme for the stack template defaults to the system preference.

![Layout diagram showing a banner area at the top of the screen, and a collection list area containing two shelf areas directly below.](images/com.apple.TVML/stacktemplate-1.png)

### Main Elements

The following listing shows the main elements of the `stackTemplate` element in TVML
format.

```xml
<stackTemplate>
    <banner>
        …
    </banner>
    <collectionList>
        <shelf>
            <section>
                <lockup>…</lockup>
            </section>
        </shelf>
    </collectionList>
</stackTemplate>
```

> Note: The `shelf` element can be replaced with a `grid` or `carousel` element to
> change the way products are displayed.

#### Element Descriptions

- [banner](/documentation/TVML/banner): A page description along the top of the screen.
- [carousel](/documentation/TVML/carousel): Element that contains all elements used to display groups
  of products, such as dramas and comedies, in a horizontal format.
- [collectionList](/documentation/TVML/collectionlist): Element that contains all elements used to display groups
  of products, such as dramas and comedies, in a horizontal format.
- [grid](/documentation/TVML/grid): Element that contains all elements used to display groups of products,
  such as dramas and comedies, in a grid format.
- [lockup](/documentation/TVML/lockup): Element containing `img` and `title` elements used to describe
  a product.
- [section](/documentation/TVML/section): Element containing a group of `lockup` elements.
- [shelf](/documentation/TVML/shelf): Element containing a group of `section` elements.

### Example

The following listing shows the TVML for a `stackTemplate` example:

```xml
<document>
    <stackTemplate>
        <banner>
            <title>Available Action Movies</title>
        </banner>
        <collectionList>
            <shelf>
                <section>
                    <lockup>
                        <img src="path to images on your server/Car_Movie_250x375_A.png" width="182" height="274" />
                        <title>Movie 1</title>
                    </lockup>
                    <lockup>
                        <img src="path to images on your server/Car_Movie_250x375_B.png" width="182" height="274" />
                        <title>Movie 2</title>
                    </lockup>
                    <lockup>
                        <img src="path to images on your server/Car_Movie_250x375_C.png" width="182" height="274" />
                        <title>Movie 3</title>
                    </lockup>
                </section>
            </shelf>
            <shelf>
                <section>
                    <lockup>
                        <img src="path to images on your servers/Space_Movie/Space_Movie_250x375_B.png" width="182" height="274"></img>
                        <title>Movie 4</title>
                    </lockup>
                    <lockup>
                        <img src="path to images on your server/Space_Movie/Space_Movie_250x375_A.png" width="182" height="274"></img>
                        <title>Movie 5</title>
                    </lockup>
                    <lockup>
                        <img src="path to images on your server/Space_Movie/Space_Movie_250x375_C.png" width="182" height="274"></img>
                        <title>Movie 6</title>
                    </lockup>
                </section>
            </shelf>
        </collectionList>
    </stackTemplate>
</document>
```

The following figure shows the output for the above example:

![Screenshot showing two shelves of movie posters.](images/com.apple.TVML/stacktemplate-2.png)

You can also customize the stack template’s background content. To do so, embed a
`mediaContent `element in a `background `element, as shown in this example:

```xml
<background>
    <mediaContent playbackMode="always">
        <img src="path to images on your server/Car_Movie.png"/>
    </mediaContent>
</background>
```

When you add a video in the background, playback starts 5 seconds after the page
is loaded. The video does not repeat.

## Topics

### Valid TVML Attributes

[binding](/documentation/TVML/binding)

Associates information in a data item with an element.

[itemID](/documentation/TVML/itemid)

Mark elements for reuse during DOM updates.

[layoutDirection](/documentation/TVML/layoutdirection)

Specifies the direction in which text is displayed.

[needsMoreThreshold](/documentation/TVML/needsmorethreshold)

Sets the amount of remaining screen lengths before firing the needs more event.

[prototype](/documentation/TVML/prototype)

Associates a data item type with an element.

[theme](/documentation/TVML/theme)

Sets the color scheme for an element.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)