Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Video Gallery

ProNew

A channel's supplied videos with playlists, subscribe controls and grid, masonry, list, slider or inline-player layouts. Video files or consumer-owned embed URLs load only when played.

Installation

pnpm dlx shadcn@latest add @viewport/video-gallery

First time? Add the @viewport registry to components.json. Setup takes one minute.

Usage

The code behind the preview above comes with Truffle Pro.

Props

PropTypeDefault
playlists*GalleryPlaylist[]

One list of videos, or several: more than one playlist adds tabs.

—
channelGalleryChannel

The channel shown in the header and under the pop-up player.

—
header"banner" | "minimal" | "none"

`banner` is a cover image with the avatar over its edge, `minimal` is a compact strip, `none` hides it.

"banner"
layout"grid" | "masonry" | "list" | "slider" | "playlist"

`grid`, `masonry` and `list` page through cards, `slider` is a swipeable row, and `playlist` puts a player beside a scrolling list. Only the playlist plays inline; other layouts open a pop-up player.

"grid"
columns2 | 3 | 4

Most columns the grid and slider grow to on wide containers.

3
pageSizenumber

Cards per page in the grid. 0 shows everything.

6
descriptionsboolean

Show the description under each card.

false
accentstring

Any CSS colour, used for the subscribe button, play badge and active tab.

—
subscribeLabelstring | false

Text of the subscribe button. `false` hides it.

"Subscribe"
subscribedLabelstring

Text of the button once subscribed.

"Subscribed"
subscribersstring

Count shown beside the subscribe button.

—
defaultSubscribedboolean

Whether the visitor starts out subscribed.

false
onSubscribeChange(subscribed: boolean) => void

Called when the subscribe button is pressed. Do the real work here.

—
onVideoOpen(video: GalleryVideo) => void

Called when a video starts in the pop-up or the inline player.

—
localestring

Locale used to write dates and counts.

"en-US"
loadingboolean

Draws placeholders while the videos are being fetched.

false
errorstring

Shown instead of the videos when fetching them failed.

—
onRetry() => void

Adds a Retry button to the error.

—
labelstring

Accessible name of the gallery.

—
classNamestring—

Accessibility

  • Playlists are a tablist: Left and Right move between them, Home and End jump to the ends, and the panel is labelled by the selected tab.
  • Each card is one button named Play video plus the title, views and date, with the length spoken as minutes and seconds; the subscribe button is a toggle that reports its state.
  • The pop-up is a modal dialog titled with the video: native playback closes with Escape, Close always restores focus to the card, and Previous and Next stay in the dialog. When focus enters an embedded iframe, use Close; its keys belong to that player.
  • The slider scrolls natively, so touch, trackpad and Tab all work, with arrow buttons that disable at each end; grid, masonry and list have named page buttons.
  • No player is loaded until play is pressed; supplied embeds and page links accept only HTTP(S) or root-relative URLs. Under reduced motion thumbnails do not zoom, the slider jumps instead of gliding and the dialog appears without a fade; otherwise the panel and backdrop enter together.