Skip to main content
The Gallery component displays a grid of images or videos with optional captions.

Basic usage

Constructor

Sequence[np.ndarray | PIL.Image | str | Path | tuple] | Callable | None
default:"None"
List of images/videos or (media, caption) tuples
str
default:"'webp'"
Image format for saving (e.g., “png”, “jpg”, “webp”)
int | None
default:"2"
Number of columns in grid
int | None
default:"None"
Number of rows to display
int | float | str | None
default:"None"
Component height with scrolling if needed
bool
default:"True"
Whether images can be enlarged on click
bool | None
default:"None"
If True, starts in preview mode
Literal['contain', 'cover', 'fill', 'none', 'scale-down'] | None
default:"None"
CSS object-fit property for thumbnails
Literal['numpy', 'pil', 'filepath']
default:"'filepath'"
Format for images passed to function

Events

  • select - Triggered when image/video is selected
  • upload - Triggered when media is uploaded
  • change - Triggered when gallery changes
  • delete - Triggered when item is deleted

Examples

With captions

Custom grid layout