salla-attachments

Renders a horizontal strip of image/video attachment thumbnails with an optional "+N" overflow indicator on the last visible item.

Renders a horizontal strip of image/video attachment thumbnails with an optional "+N" overflow indicator on the last visible item. When clickable is true, opens salla-attachment-view when a thumbnail is clicked.

Media can be supplied as:

  • attachments — full { id, url, mimeType?/type? } objects
  • images / videos — URL string arrays
  • rating — object with images / videos arrays
  • productRatings + productId — match a product rating, else fall back to rating

It is used by salla-comment-item to show review photos and videos, and a theme can use it for any media strip. Nothing is rendered when there is no valid image or video. Thumbnails are plain div elements with a click handler (images have an empty alt), so they are not keyboard accessible.

Use it

In HTML or JSX, use the tag <salla-attachments> with the Attribute names below. In React, the wrapper takes the Property names (camelCase).

import { SallaAttachments } from '@salla.sa/twilight-components-react/attachments';

Example

import { SallaAttachments } from '@salla.sa/twilight-components-react/attachments';

export function Example() {
  return (
    <SallaAttachments
      images='["https://example.com/a.jpg", "https://example.com/b.jpg"]'
      videos='["https://example.com/c.mp4"]'
      maxVisible={3}
      clickable />
  );
}

Properties

PropertyAttributeDescriptionTypeDefault
attachmentsattachmentsAttachments to display. Accepts an array of { id, url, mimeType? } or a JSON string of the same shape.Attachment[] | string[]
clickableclickableWhen true, clicking a thumbnail opens the attachment lightbox.booleanfalse
imagesimagesImage URLs to display. Accepts a string array or a JSON string.string | string[][]
maxVisiblemax-visibleMaximum number of thumbnails to show before displaying a "+N" overlay on the last visible item. Defaults to 4.number4
productIdproduct-idProduct id used to match an entry in productRatings.number | stringnull
productRatingsproduct-ratingsProduct ratings list. When set with productId, the matching rating's media is preferred over rating.MediaSource[] | string[]
ratingratingRating-like object with images / videos URL arrays. Used when images/videos are empty, and as a fallback when resolving productRatings.string | { images?: string[]; videos?: string[]; product?: { id?: string | number; }; }null
videosvideosVideo URLs to display. Accepts a string array or a JSON string.string | string[][]

Renders: <salla-attachment-view>.

Used inside: <salla-comment-item>, <salla-review-order-item>.

On this page