# One screenshot

> Show one screenshot from your VisualCI gallery in a page or a README, in the reader's light or dark mode, with the same gallery libraries and components.

Source: https://visualci.com/docs/gallery/screenshot/
All of VisualCI's documentation: https://visualci.com/llms.txt

A [screenshots page](https://visualci.com/docs/gallery.md) shows every screen. Sometimes a page needs just one: the overview at the top of the docs, the dashboard in a README. Each gallery library can render one screenshot from the same manifest: an `<img>`, or a `<picture>` that shows the dark shot to readers whose setting is dark. It has its width and height set, so the page doesn't jump while it loads, and it's lazy-loaded unless you ask otherwise.

It needs no stylesheet or script. Install the library for your stack as its guide says; every snippet below is a file from that library's example site, which VisualCI's tests build and check.

## In a framework

Each framework's package has a `Screenshot` component next to its `Gallery`. It reads the manifest when the site builds, and the build fails when the manifest can't be read or the screen isn't in it.

[React and Next.js](https://visualci.com/docs/gallery/react.md), a server component:

<!-- example: clients/gallery/react/examples/next/app/overview/page.tsx -->
```tsx
import { Screenshot } from "visualci-gallery-react";

export const metadata = { title: "Overview" };

export default function Overview() {
  return (
    <>
      <h1>Overview</h1>
      {/* One screenshot, in the reader's light or dark mode, linked to the full-size original. */}
      <Screenshot manifest="https://app.visualci.com/g/acme/web.json" screen="overview" link />
    </>
  );
}
```

[Astro](https://visualci.com/docs/gallery/astro.md):

<!-- example: clients/gallery/astro/examples/site/src/pages/overview.astro -->
```astro
---
import { Screenshot } from "visualci-astro-gallery";
---

<html lang="en">
  <head>
    <meta charset="utf-8" />
    <title>Overview</title>
  </head>
  <body>
    <h1>Overview</h1>
    <!-- One screenshot, in the reader's light or dark mode, linked to the full-size original. -->
    <Screenshot manifest="https://app.visualci.com/g/acme/web.json" screen="overview" link />
  </body>
</html>
```

[Docusaurus](https://visualci.com/docs/gallery/docusaurus.md), with the plugin in `docusaurus.config.js` as for a gallery:

<!-- example: clients/gallery/docusaurus/examples/site/docs/overview.mdx -->
```mdx
---
title: Overview
---

import Screenshot from "visualci-gallery-docusaurus/Screenshot";

One screenshot, in the reader's light or dark mode, linked to the full-size original.

<Screenshot manifest="https://app.visualci.com/g/acme/web.json" screen="overview" link />
```

[VitePress](https://visualci.com/docs/gallery/vitepress.md), with the plugin and the theme as for a gallery (the theme registers `<Screenshot>` too):

<!-- example: clients/gallery/vitepress/examples/site/overview.md -->
```md
# Overview

One screenshot, in the reader's light or dark mode, linked to the full-size original.

<Screenshot manifest="https://app.visualci.com/g/acme/web.json" screen="overview" link />
```

[MkDocs](https://visualci.com/docs/gallery/mkdocs.md), a `visualci-screenshot` fenced block in any page:

<!-- example: clients/gallery/python/examples/mkdocs/docs/overview.md -->
````md
# Overview

One screenshot, in the reader's light or dark mode, linked to the full-size original.

```visualci-screenshot
manifest: https://app.visualci.com/g/acme/web.json
screen: overview
link: true
```
````

[Hugo](https://visualci.com/docs/gallery/hugo.md), a `visualci-screenshot` shortcode in any page (or the `visualci-screenshot.html` partial in a template, which takes `markdown: true` for Markdown):

<!-- example: clients/gallery/hugo/examples/site/content/overview.md -->
```md
---
title: Overview
---

One screenshot, in the reader's light or dark mode, linked to the full-size original.

{{< visualci-screenshot manifest="https://app.visualci.com/g/acme/web.json" screen="overview" link=true >}}
```

## In your own code

The libraries have two functions that take a parsed manifest and the options below, and return a string:

- `screenshot` returns the HTML.
- `screenshotMarkdown` (`screenshot_markdown` in Ruby, Python and Rust) returns Markdown for a README: `![alt](url)`, or `[![alt](url)](url)` with `link`. When the screen has a dark shot it returns the HTML `<picture>`, which GitHub and most Markdown renderers show as it is.

Both raise an error when an option is invalid or the screen has no shot for what's asked. A script that writes your README when the build passes can call `screenshotMarkdown` with the manifest it fetched. For a screen with no dark shot, it returns:

<!-- example: clients/gallery/contract/screenshots/cases/light-only.md -->
```md
![Billing](https://app.visualci.com/g/acme/web/billing-light.png)
```

and for one with a dark shot:

<!-- example: clients/gallery/contract/screenshots/cases/default.md -->
```html
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://app.visualci.com/g/acme/web/overview-dark-1440.png" width="1440" height="900">
<img src="https://app.visualci.com/g/acme/web/overview-light-1440.png" srcset="https://app.visualci.com/g/acme/web/overview-light-1440.png, https://app.visualci.com/g/acme/web/overview-light-1440-2x.png 2x" width="1440" height="900" alt="Overview" loading="lazy" decoding="async">
</picture>
```

A Markdown image shows at the file's own size, so a README that wants a smaller picture uses `thumb`, or a screen taken at a smaller width.

## Options

- `screen` (required): the screen's key, as the gallery's `screens` and `order` name it: `overview`, `ios/sessions`.
- `group`: the group it's in. Default: the first group that has the screen.
- `theme`: the theme to show, such as `light`. Default: the screen's first, with its dark shot for readers whose setting is dark. When you set it, only that theme's shot is shown.
- `size`: the size to show, such as `phone`. Default: the screen's first that has the theme.
- `alt`: the image's alt text. Default: the screen's title, made from its key.
- `link`: link the image to its full-size original. Default false.
- `thumb`: show the manifest's small copy, where every image shown has one. Default false.
- `loading`: `lazy` (the default) or `eager`, for a screenshot near the top of the page.
- `dimensions` and `groups`: as the gallery's [options](https://visualci.com/docs/gallery/options.md) of the same names, so the screen's shots pair the same way they do in your gallery.

Shots that only come as 2x files are shown at half their size, with the 2x file for sharp screens.
