VTEX Ads Stories Package Layout and Player
Understand how the VTEX Ads Stories carousel arranges videos and how its player handles products, links, accessibility, controls, and playback errors.
The <vtex-ads-story-carousel> element of the @vtex/ads-stories package arranges Story ads in a responsive video carousel and opens them in a mini or expanded player. This guide explains the layouts, playback behavior, destinations, product controls, accessibility behavior, and error states that the element provides.
If you haven't installed the package yet, see the VTEX Ads Stories Package Quickstart.
Story ads are off by default. Request enablement for your store through VTEX Support before displaying Stories. For the setup steps, see Before you begin.
Carousel layouts
The element requests up to the number of Stories set by quantity and displays them in a 500 px-high band that fills the width of its parent.
The layout depends on how many Stories the request returns:
- One Story: The card is centered over a background. On screens 576 px wide or less, only the card is shown, without the background.
- Two Stories: Both cards are shown side by side. The highlighted card is full size, and the other card is smaller and dimmed.
- Three or more Stories: The highlighted card is in the middle, with up to two smaller, dimmed cards on each side. Each card moves one position per step. With four Stories, the card opposite the highlighted card is shown at both ends.
On screens 576 px wide or less, two Stories use the three-or-more layout, with the Story that is not highlighted shown on both sides.
Highlight and video playback
When the carousel has more than one Story, the highlight advances to the next card according to slide-duration, which is 5 seconds by default. The automatic advance pauses when:
- The pointer is over the carousel.
- Keyboard focus is inside the carousel.
- The player is open.
Shoppers can move the highlight with the carousel arrows, a swipe, or a click on a dimmed card. For the allowed slide-duration range and how to turn automatic advance off, see Attributes.
Only the highlighted card plays its video. The other cards show their covers. When inactive-autoplay is enabled, visible cards without the highlight also play, but remain muted.
If a shopper turns on the sound of the highlighted card, the next highlighted card also starts with sound. It starts muted instead if the browser blocks playback with sound.
Reduced motion
When a shopper's system uses prefers-reduced-motion: reduce, the carousel remains still:
- Cards show only their covers, with no videos playing.
- The highlight doesn't advance automatically, regardless of
slide-durationorinactive-autoplay. - The highlight moves only with the carousel arrows, swipes, or clicks.
Opening a Story still plays its video in the player because the shopper chose to watch it.
Product destinations
When a Story's destination is a product, its card shows the product image, name, and price at the bottom. The name can use up to two lines. When the product is on sale, the original price is struck through beside the current price. The price follows the element's currency and language settings.
In the player, the product appears in a pill at the bottom of the video. Clicking it opens a product panel with an Add to cart button and a View product link. The View product link opens the product page in a new tab, pauses the video, and leaves the player open.
The product interaction depends on the card:
- On the highlighted card, clicking the product opens the player with the product panel already open.
- On a dimmed card, clicking the product moves the highlight to that card.
- Clicking the video or moving to another Story closes the product panel.
The Add to cart button dispatches an event for the store to handle. The player and product panel remain open. A product without a SKU doesn't show the Add to cart button.
Cart stepper
After the shopper adds a product, a quantity stepper replaces the Add to cart button. It contains minus, quantity, and plus controls. When the quantity is one, the minus control becomes a trash control. Removing the last item restores the Add to cart button.
The stepper counts additions and removals for each combination of SKU and seller since the player was opened. It doesn't read the store's cart. As a result:
- Items added or removed elsewhere don't change the stepper.
- A failed add-to-cart action doesn't change the stepper.
- Closing and reopening the player resets the stepper to the
Add to cartbutton. - Reopening the player doesn't remove items that were previously added to the store's cart.
Sold-out products
When the store's hydration strategy marks a product as unavailable, the Story keeps playing. The card and player still show the product.
- The price remains visible. If there is no price, Sold out appears instead.
- The
Add to cartbutton becomes a disabledProduct unavailablebutton. View productremains available and opens the product page.
Call-to-action destinations
When a Story's destination is a link instead of a product, the card and player show a call-to-action button at the bottom. The button uses the campaign's call_to_action text, such as Learn more, and includes a caret. If the campaign has no call-to-action text, the element doesn't show the button.
Clicking the button opens the destination in a new tab. On a dimmed card, the first click moves the highlight to that card instead.
After the link opens:
- In the player, the video pauses and the player remains open.
- On the highlighted card, the video is muted and continues playing.
The highlighted card keeps playing because a paused card would show its play button. That button opens the player instead of resuming playback on the card.
Destination URL safety
The element follows the campaign's destination_url for a product or call to action only when the URL matches one of these formats.
- An absolute
httporhttpsURL. - A path on the current store, such as
/product/p.
The element ignores paths that could lead to another host, including //host and /\host. When the URL is ignored, the Story shows no View product link or call-to-action button.
Player behavior
When the shopper selects the highlighted card, the screen width determines how the Story opens.
- On screens wider than 768 px, the Story opens in the mini player at the bottom right. The shopper can expand it.
- On screens 768 px wide or narrower, the Story opens directly in the expanded player. There is no control to collapse it to the mini player.
In either view, the video starts with sound. If the browser blocks playback with sound, it starts muted.
The player closes when the shopper:
- Clicks its close button.
- Presses
Escape. - Clicks the backdrop around the expanded player.
Mini player
When there is more than one Story, previous and next buttons above the mini player's top-left corner change the video. The carousel highlight follows the selected Story, and the carousel's automatic advance remains paused while the player is open.
Expanded player
When there are three or more Stories, the expanded player shows up to two Story covers on each side of the video. Shoppers can click a cover or use the previous and next buttons to change Stories. When a video ends, the next Story starts playing.
With two Stories on screens wider than 576 px, the video moves off center and the other Story's cover appears beside it. The expanded player hides the previous and next buttons. Shoppers can select the cover to switch Stories.
On screens 576 px wide or narrower, the expanded player fills the screen and hides the side covers. When there is more than one Story, the previous and next buttons appear inside the video's edges. The sound and close buttons sit at the top right of the video.
Keyboard controls
When focus is inside the player, the left and right arrow keys move between Stories. If a modifier key is held, the player doesn't handle the arrow key. Outside the player, these keys keep their normal page behavior.
Video errors
If a video can't load, its cover remains visible with an error notice:
- On a carousel card, the notice says Video unavailable.
- In the player, the notice says Couldn't load the video and provides a
Try againbutton.
After the shopper selects Try again, a spinner labeled Loading video appears. If the video loads, it tries to play with sound. It starts muted if the browser blocks playback with sound. If the video fails to load again, the error notice returns.
These are the English UI texts. The element translates them according to its language settings, with Portuguese as the default.
Next steps
- VTEX Ads Stories Package Configuration: Configure language, slide duration, inactive autoplay, and other element attributes.