UGC Widgets
    Preparing search index...

    Interface TilesSDK

    The Tiles SDK provides methods for interacting with the widget's tiles, including searching, fetching, and managing tile states. Tiles are an essential part of the UGC platform, you will likely spend most of your time manipulating tiles and retrieving tile data with the Tiles API.

    interface TilesSDK {
        closeExpandedTiles: () => void;
        enableAutoAddNewTiles: () => void;
        fetchTiles: (page: number, limit: number) => Promise<Tile[]>;
        getContentTagsFromTile: (tile: Tile) => Content[];
        getFirstProductInTile: (tile: Tile) => undefined | Product;
        getPage: () => number;
        getProductTagById: (id: string) => undefined | Product;
        getProductTagsFromTile: (tile?: Tile) => Product[];
        getSelectedProduct: () => undefined | Product;
        getShopspotsFromTile: (tileId: string) => any;
        getTile: () => undefined | Tile;
        getTileById: (id: string) => undefined | Tile;
        getTiles: () => Tile[];
        hasMoreTiles: () => boolean;
        hideTileById: (tileId: string) => Promise<void>;
        loadTilesUntilVisibleTilesCount: () => Promise<void>;
        openExpandedTiles: (tileId: string) => void;
        searchTiles: (query: string, replaceExisting?: boolean) => void;
        setHideBrokenTiles: (hideBrokenTiles: boolean) => void;
        setMediaType: (mediaType: "image" | "video") => void;
        setPreloadImages: (preloadImages: boolean) => void;
        setTile: (tile: Tile) => void;
        setVisibleTilesCount: (visibleTileCount: number) => void;
        waitForTile: (tileId: string) => Promise<undefined | Tile>;
    }
    Index

    Properties

    closeExpandedTiles: () => void

    Close the expanded tile This is helpful when you want to close the expanded tile programmatically

    // Close any open expanded tile
    sdk.closeExpandedTiles();
    enableAutoAddNewTiles: () => void

    Enable or disable the auto addition of new tiles

    // Enable auto-adding of new tiles
    sdk.enableAutoAddNewTiles();
    fetchTiles: (page: number, limit: number) => Promise<Tile[]>

    Type declaration

      • (page: number, limit: number): Promise<Tile[]>
      • Parameters

        • page: number
        • limit: number

        Returns Promise<Tile[]>

        Promise<Tile[]>

    Fetch tiles

    // Fetch 10 tiles from page 2
    const tiles = await sdk.fetchTiles(2, 10);
    getContentTagsFromTile: (tile: Tile) => Content[]

    Get content tags from a tile

    // Get all content tags for a tile
    const tags = sdk.getContentTagsFromTile(tile);
    getFirstProductInTile: (tile: Tile) => undefined | Product

    Get the first product in a tile

    // Get the first product for a tile
    const product = sdk.getFirstProductInTile(tile);
    getPage: () => number

    Type declaration

      • (): number
      • Returns number

        number

    Get page

    // Get the current page number. When load more is clicked, the page number changes.
    const page = sdk.getPage();
    getProductTagById: (id: string) => undefined | Product

    Get product tag by id

    // Get a product tag by id
    const tag = sdk.getProductTagById('product-123');
    getProductTagsFromTile: (tile?: Tile) => Product[]

    Get product tags from a tile

    // Get product tags for a tile
    const tags = sdk.getProductTagsFromTile(tile);
    getSelectedProduct: () => undefined | Product

    Get selected product

    // Get the currently selected product
    const product = sdk.getSelectedProduct();
    getShopspotsFromTile: (tileId: string) => any

    Get shopspots from a tile by id

    // Get shopspots for a tile
    const shopspots = sdk.getShopspotsFromTile('tile-123');
    getTile: () => undefined | Tile

    Get the current selected tile (expanded)

    // Get the currently expanded tile
    const expanded = sdk.getTile();
    getTileById: (id: string) => undefined | Tile

    Get a tile by its id

    // Get a tile by id
    const tile = sdk.getTileById('tile-123');
    getTiles: () => Tile[]

    Type declaration

      • (): Tile[]
      • Returns Tile[]

        Tile[]

    Get all tiles

    // Get all tiles and log their ids
    sdk.getTiles().forEach(tile => console.log(tile.id));
    hasMoreTiles: () => boolean

    Check if more tiles are available

    // Check if there are more tiles to load
    if (sdk.hasMoreTiles()) {
    // load more
    }
    hideTileById: (tileId: string) => Promise<void>

    Hide a tile by id

    // Hide a tile with a specific id
    await sdk.hideTileById('tile-123');
    loadTilesUntilVisibleTilesCount: () => Promise<void>

    Load tiles until visible tile count

    // Ensure enough tiles are loaded to meet the visible count
    await sdk.loadTilesUntilVisibleTilesCount();
    openExpandedTiles: (tileId: string) => void

    Open the expanded tile This is helpful when you want to open the expanded tile programmatically

    // Open the expanded tile for a specific tile id
    sdk.openExpandedTiles('tile-123');
    searchTiles: (query: string, replaceExisting?: boolean) => void

    Type declaration

      • (query: string, replaceExisting?: boolean): void
      • Parameters

        • query: string

          search query, i.e. dogs

        • OptionalreplaceExisting: boolean

          replace existing tiles with new search results (default: true)

        Returns void

    Search tiles

    // Search for tiles with the query 'dogs'
    sdk.searchTiles('dogs');

    // Search for tiles and append to existing
    sdk.searchTiles('cats', false);
    setHideBrokenTiles: (hideBrokenTiles: boolean) => void

    Disable or enable the removal of broken tiles This is helpful when you want to handle the removal of broken tiles yourself.

    // Enable hiding of broken tiles
    sdk.setHideBrokenTiles(true);
    setMediaType: (mediaType: "image" | "video") => void

    Set the media type for the tile search

    // Only show video tiles
    sdk.setMediaType('video');
    setPreloadImages: (preloadImages: boolean) => void

    Disable or enable preloading of images This is helpful when you want to handle the preloading yourself.

    // Disable image preloading
    sdk.setPreloadImages(false);
    setTile: (tile: Tile) => void

    Set the selected tile (expanded)

    // Set a tile as the currently expanded tile
    sdk.setTile(tile);
    setVisibleTilesCount: (visibleTileCount: number) => void

    Set visible tile count

    // Show only 5 tiles at a time
    sdk.setVisibleTilesCount(5);
    waitForTile: (tileId: string) => Promise<undefined | Tile>

    Type declaration

      • (tileId: string): Promise<undefined | Tile>
      • Parameters

        • tileId: string

          id of the tile to wait for

        Returns Promise<undefined | Tile>

        Promise<Tile | undefined>

    Wait for a tile to be loaded

    // Wait for a tile to be available in the DOM
    const tile = await sdk.waitForTile('tile-123');