How to change the contents of an expanded tile

This guide will explain how to customize the content displayed within an expanded tile in Nosto UGC NextGen widgets.

For IDE Users:

As an IDE user, you will directly interact with the widget's codebase, primarily within the widgets/blankcanvas folder. Your main focus will be on widget.tsx for logic, layout.hbs or tile.hbs for HTML structure, and widget.scss for styling.

  1. Understanding the Expanded Tile Structure

The expanded tile's content is rendered through the expanded-tiles web component. A sample template is located in samples/expanded-tile.template.tsx. This template dictates what information from the tile is displayed when it expands. When a tile is expanded, the SDK triggers the EVENT_TILE_EXPAND event. The expanded-tiles component then renders the content based on its internal logic and the provided template.

  1. Modifying the Expanded Tile Template

To change the content, you'll need to override the default expanded-tiles template.

// File: widget.tsx

import { ISdk, loadWidget } from "@stackla/widget-utils";
import { config } from "./config";
import { ExpandedTiles } from "./expanded-tile.template"; // Import your custom template

declare const sdk: ISdk;

loadWidget(sdk, {
  config: {
    ...config,
  },
  templates: {
    "expanded-tiles": { // Specify the component you want to override
      template: ExpandedTiles, // Provide your custom template function
    },
  },
});

(Create this file if it doesn't exist, and copy the content from samples/expanded-tile.template.tsx as a starting point.)

Within this file, you have full control over the HTML structure of the expanded tile. You can add, remove, or reorder elements to suit your needs.

Here's an example of how you might modify the ExpandedTile function to add a custom header and reorder some elements:

For Web Editor Users:

As a web editor user, you'll typically interact with the widget through the Nosto Admin Portal's "Custom Code" section. This means you'll be working with compiled HTML, CSS, and JavaScript.

  1. Understanding the Expanded Tile When a user clicks on a tile, it can expand to show more details. This "expanded tile" is a special overlay that appears. To change what's inside it, you'll need to modify the underlying code that controls its appearance.

  2. How to Modify the Expanded Tile Content You'll make your changes in four key boxes within the Custom Code editor:

Box 1: Custom JS

Box 2: Custom CSS

Congratulations! You have successfully modified the contents of an expanded tile in Nosto UGC NextGen widgets. You can further customize the HTML and CSS to fit your brand's needs.

Last updated

Was this helpful?