> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/gradio-app/gradio/llms.txt
> Use this file to discover all available pages before exploring further.

# Gallery

> Display images and videos in a grid layout

The Gallery component displays a grid of images or videos with optional captions.

## Basic usage

```python theme={null}
import gradio as gr

def get_images():
    return ["image1.jpg", "image2.jpg", "image3.jpg"]

gr.Interface(
    fn=get_images,
    inputs=gr.Button("Load"),
    outputs=gr.Gallery()
).launch()
```

## Constructor

<ParamField path="value" type="Sequence[np.ndarray | PIL.Image | str | Path | tuple] | Callable | None" default="None">
  List of images/videos or (media, caption) tuples
</ParamField>

<ParamField path="format" type="str" default="'webp'">
  Image format for saving (e.g., "png", "jpg", "webp")
</ParamField>

<ParamField path="columns" type="int | None" default="2">
  Number of columns in grid
</ParamField>

<ParamField path="rows" type="int | None" default="None">
  Number of rows to display
</ParamField>

<ParamField path="height" type="int | float | str | None" default="None">
  Component height with scrolling if needed
</ParamField>

<ParamField path="allow_preview" type="bool" default="True">
  Whether images can be enlarged on click
</ParamField>

<ParamField path="preview" type="bool | None" default="None">
  If True, starts in preview mode
</ParamField>

<ParamField path="object_fit" type="Literal['contain', 'cover', 'fill', 'none', 'scale-down'] | None" default="None">
  CSS object-fit property for thumbnails
</ParamField>

<ParamField path="type" type="Literal['numpy', 'pil', 'filepath']" default="'filepath'">
  Format for images passed to function
</ParamField>

## 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

```python theme={null}
import gradio as gr

images_with_captions = [
    ("cat.jpg", "A cute cat"),
    ("dog.jpg", "A friendly dog"),
    ("bird.jpg", "A colorful bird")
]

gr.Gallery(value=images_with_captions, columns=3)
```

### Custom grid layout

```python theme={null}
import gradio as gr

gr.Gallery(
    columns=4,
    rows=2,
    height="500px",
    object_fit="cover"
)
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.