import { ImageGallery } from "@replicas/ui";

const scene = (sky: string, far: string, near: string, sun: string) =>
  `data:image/svg+xml,${encodeURIComponent(
    `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 160 120"><rect width="160" height="120" fill="${sky}"/><circle cx="118" cy="34" r="12" fill="${sun}"/><path d="M0 84l40-30 30 20 26-18 64 40v24H0z" fill="${far}"/><path d="M0 98l48-20 36 14 30-10 46 18v20H0z" fill="${near}"/></svg>`,
  )}`;

const images = [
  { src: scene("#f6c9a8", "#8aa58c", "#5f7f63", "#fff3e6"), alt: "Hills at sunset", source: "unsplash.com" },
  { src: scene("#bcd7ee", "#7d97b5", "#4f6b8a", "#ffffff"), alt: "Lake in the morning", source: "flickr.com" },
  { src: scene("#d9cdea", "#9c8bb8", "#6e5e8c", "#fdf2ff"), alt: "Valley at dusk", source: "pexels.com" },
  { src: scene("#f2e2b8", "#c4a86b", "#8f7440", "#fffaf0"), alt: "Desert dunes", source: "unsplash.com", more: 8 },
];

export default function ImageGalleryDemo() {
  return (
    <div style={{ width: "100%", maxWidth: 520 }}>
      <ImageGallery.Root>
        {images.map((image) => (
          <ImageGallery.Item key={image.alt} {...image} aria-label={image.more ? `Show ${image.more} more images` : image.alt} />
        ))}
      </ImageGallery.Root>
      <ImageGallery.Caption>Landscapes for the onboarding hero</ImageGallery.Caption>
    </div>
  );
}

Prompt

Copy Prompt hands your agent everything it needs to build the Image Gallery in the Palermo style: the measured tokens, the CSS and the structure.

Show Prompt
# Palermo Image Gallery

Images the agent found, in a grid, with a count of the rest.

Build a Image Gallery in this project that looks and behaves like Palermo's. Measured from the running Palermo app (palermo.tryprofound.com). Keep every value exact. Map the tokens onto the project's own theme variables instead of hard-coding them. Use the project's own component library for behaviour, or Base UI primitives if it has none.

Fidelity: Concept, not a real feature. Designed from Palermo docs /docs/question-tool, /docs/list, /docs/statistic and /docs/multi-step-form. Tiles are radius-8 on bg-tertiary. The source label shows on hover in tooltip colours, and the +N tile uses the drawer overlay.

## Tokens

| Token | Light | Dark |
| --- | --- | --- |
| `--color-bg-tertiary` | `#f5f5f5` | `#272625` |
| `--color-bg-tooltip` | `#18181ae6` | `#2e2d2be6` |
| `--color-text-white` | `#fff` | `#fff` |
| `--color-text-tooltip` | `#fff` | `#ecebe9` |
| `--text-secondary` | `#787878` | `#aaa8a5` |
| `--overlay-drawer` | `rgb(0 0 0 / 0.5)` | `rgb(0 0 0 / 0.5)` |
| `--focus-ring` | `#006bff` | `#006bff` |
| `--font-regular` | `"Profound Inter", "Inter Variable", "Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif` | `"Profound Inter", "Inter Variable", "Inter", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif` |
| `--font-size-micro` | `0.625rem` | `0.625rem` |
| `--font-size-mini` | `0.75rem` | `0.75rem` |
| `--font-size-small` | `0.8125rem` | `0.8125rem` |
| `--line-height-micro` | `14px` | `14px` |
| `--line-height-mini` | `16px` | `16px` |
| `--line-height-small` | `18px` | `18px` |
| `--font-weight-medium` | `500` | `500` |
| `--radius-6` | `6px` | `6px` |
| `--radius-8` | `8px` | `8px` |
| `--ease-out` | `cubic-bezier(0, 0, 0.2, 1)` | `cubic-bezier(0, 0, 0.2, 1)` |
| `--ease-in-out` | `cubic-bezier(0.4, 0, 0.2, 1)` | `cubic-bezier(0.4, 0, 0.2, 1)` |
| `--duration-reveal` | `120ms` | `120ms` |
| `--duration-smooth` | `250ms` | `250ms` |

## CSS

Scoped under `[data-style="palermo"]`; dark rules sit under `[data-theme="dark"]`. The `ui-*` classes and data attributes match the structure below.

```css
[data-style="palermo"] {
  .ui-image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
    gap: 4px;
  }

  .ui-image-gallery-item {
    box-sizing: border-box;
    position: relative;
    display: block;
    aspect-ratio: 4 / 3;
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: none;
    border-radius: var(--radius-8);
    background-color: var(--color-bg-tertiary);
    cursor: pointer;
    outline: none;

    & img {
      display: block;
      width: 100%;
      height: 100%;
      object-fit: cover;
      transition: scale var(--duration-smooth) var(--ease-out);
    }

    @media (hover: hover) {
      &:hover img {
        scale: 1.03;
      }
    }

    &:focus-visible {
      outline: 1px solid var(--focus-ring);
      outline-offset: 1px;
    }

    @media (prefers-reduced-motion: reduce) {
      & img {
        transition: none;
      }

      &:hover img {
        scale: 1;
      }
    }
  }

  .ui-image-gallery-source {
    box-sizing: border-box;
    position: absolute;
    bottom: 6px;
    left: 6px;
    max-width: calc(100% - 12px);
    padding: 1px 6px;
    overflow: hidden;
    border-radius: var(--radius-6);
    background-color: var(--color-bg-tooltip);
    color: var(--color-text-tooltip);
    font-family: var(--font-regular);
    font-size: var(--font-size-micro);
    line-height: var(--line-height-micro);
    text-overflow: ellipsis;
    white-space: nowrap;
    opacity: 0;
    transition: opacity var(--duration-reveal) var(--ease-in-out);

    @media (prefers-reduced-motion: reduce) {
      transition: none;
    }
  }

  .ui-image-gallery-item:is(:hover, :focus-visible) .ui-image-gallery-source {
    opacity: 1;
  }

  @media (hover: none) {
    .ui-image-gallery-source {
      opacity: 1;
    }
  }

  .ui-image-gallery-item[data-more] .ui-image-gallery-source {
    display: none;
  }

  .ui-image-gallery-more {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--overlay-drawer);
    color: var(--color-text-white);
    font-family: var(--font-regular);
    font-size: var(--font-size-small);
    font-weight: var(--font-weight-medium);
    line-height: var(--line-height-small);
    font-variant-numeric: tabular-nums;
  }

  .ui-image-gallery-caption {
    margin: 8px 0 0;
    color: var(--text-secondary);
    font-family: var(--font-regular);
    font-size: var(--font-size-mini);
    line-height: var(--line-height-mini);
    -webkit-font-smoothing: antialiased;
  }
}
```

## Structure

How Replicas assembles it on Base UI.

```tsx
import { Button as BaseButton } from "@base-ui/react/button";
import type { ComponentProps, ReactNode } from "react";
import { join } from "./utils";

function Root({ className, ...props }: ComponentProps<"div">) {
  return <div className={join("ui-image-gallery", className)} {...props} />;
}

type ItemProps = Omit<BaseButton.Props, "className" | "children"> & {
  className?: string;
  src: string;
  alt: string;
  source?: ReactNode;
  more?: number;
};

function Item({ className, src, alt, source, more, ...props }: ItemProps) {
  return (
    <BaseButton className={join("ui-image-gallery-item", className)} data-more={more ? true : undefined} {...props}>
      <img src={src} alt={alt} />
      {source ? <span className="ui-image-gallery-source">{source}</span> : null}
      {more ? <span className="ui-image-gallery-more">+{more}</span> : null}
    </BaseButton>
  );
}

function Caption({ className, ...props }: ComponentProps<"p">) {
  return <p className={join("ui-image-gallery-caption", className)} {...props} />;
}

export const ImageGallery = {
  Root,
  Item,
  Caption,
};
```

## Example

```tsx
import { ImageGallery } from "@replicas/ui";

const scene = (sky: string, far: string, near: string, sun: string) =>
  `data:image/svg+xml,${encodeURIComponent(
    `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 160 120"><rect width="160" height="120" fill="${sky}"/><circle cx="118" cy="34" r="12" fill="${sun}"/><path d="M0 84l40-30 30 20 26-18 64 40v24H0z" fill="${far}"/><path d="M0 98l48-20 36 14 30-10 46 18v20H0z" fill="${near}"/></svg>`,
  )}`;

const images = [
  { src: scene("#f6c9a8", "#8aa58c", "#5f7f63", "#fff3e6"), alt: "Hills at sunset", source: "unsplash.com" },
  { src: scene("#bcd7ee", "#7d97b5", "#4f6b8a", "#ffffff"), alt: "Lake in the morning", source: "flickr.com" },
  { src: scene("#d9cdea", "#9c8bb8", "#6e5e8c", "#fdf2ff"), alt: "Valley at dusk", source: "pexels.com" },
  { src: scene("#f2e2b8", "#c4a86b", "#8f7440", "#fffaf0"), alt: "Desert dunes", source: "unsplash.com", more: 8 },
];

export default function ImageGalleryDemo() {
  return (
    <div style={{ width: "100%", maxWidth: 520 }}>
      <ImageGallery.Root>
        {images.map((image) => (
          <ImageGallery.Item key={image.alt} {...image} aria-label={image.more ? `Show ${image.more} more images` : image.alt} />
        ))}
      </ImageGallery.Root>
      <ImageGallery.Caption>Landscapes for the onboarding hero</ImageGallery.Caption>
    </div>
  );
}
```

## Foundations

The rest of the Palermo style, as a skill: https://replicas.raphaelsalaja.com/skills/palermo/SKILL.md