import { Button, Popover } from "@replicas/ui";

export default function PopoverDemo() {
  return (
    <Popover.Root>
      <Popover.Trigger render={<Button>Project status</Button>} />
      <Popover.Popup>
        <Popover.Title>Mobile app launch</Popover.Title>
        <Popover.Description>
          On track. 12 of 18 tasks done, next milestone is the public beta on Dec 3.
        </Popover.Description>
        <div style={{ display: "flex", justifyContent: "flex-end", marginTop: 8 }}>
          <Popover.Close render={<Button size="small">Done</Button>} />
        </div>
      </Popover.Popup>
    </Popover.Root>
  );
}

Prompt

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

Show Prompt
# Lens Popover

An accessible popup anchored to a button.

Build a Popover in this project that looks and behaves like Lens's. Measured from the running Lens app (developer.lens.xyz). 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](https://base-ui.com/react/components/popover) if it has none.

Fidelity: Partly measured from The dashboard's dropdown popup CSS. Not captured on its own. The dark theme is derived.

## Tokens

| Token | Light | Dark |
| --- | --- | --- |
| `--lens-white` | `#fff` | `#1c1d1f` |
| `--lens-text-primary` | `#2c2d30` | `#ececed` |
| `--lens-text-secondary` | `#2c2d3099` | `#ececed9e` |
| `--lens-ring-popup` | `0 0 0 1px var(--lens-hairline), 0 1px 2px #00000005` | `0 0 0 1px var(--lens-hairline), 0 4px 16px #00000052` |
| `--lens-tracking-13` | `-0.00315856em` | `-0.00315856em` |
| `--lens-tracking-14` | `-0.00622354em` | `-0.00622354em` |
| `--duration-popup` | `0.18s` | `0.18s` |
| `--font-regular` | `"Lens Inter", "Lens Inter Fallback", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif` | `"Lens Inter", "Lens Inter Fallback", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif` |

## CSS

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

```css
[data-style="lens"] {
  .ui-popover-positioner {
    z-index: 2147483647;
    outline: 0;
  }

  .ui-popover-popup {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 200px;
    max-width: min(320px, var(--available-width));
    padding: 12px 16px;
    border: 0;
    border-radius: 8px;
    outline: none;
    background: var(--lens-white);
    box-shadow: var(--lens-ring-popup);
    color: var(--lens-text-secondary);
    font-family: var(--font-regular);
    font-size: 13px;
    line-height: 20px;
    letter-spacing: var(--lens-tracking-13);
    -webkit-font-smoothing: antialiased;
    transform-origin: var(--transform-origin);
    transition: all var(--duration-popup);

    &[data-starting-style],
    &[data-ending-style] {
      opacity: 0;
      transform: scale(0.98);
    }
  }

  .ui-popover-title {
    margin: 0;
    color: var(--lens-text-primary);
    font-size: 14px;
    font-weight: 500;
    line-height: 21px;
    letter-spacing: var(--lens-tracking-14);
  }

  .ui-popover-description {
    margin: 0;
    color: var(--lens-text-secondary);
    font-size: 13px;
    font-weight: 400;
    line-height: 20px;
    letter-spacing: var(--lens-tracking-13);
  }
}
```

## Structure

How Replicas assembles it on Base UI.

```tsx
import { Popover as BasePopover } from "@base-ui/react/popover";
import { usePortalContainer } from "./portal";

const join = (base: string, extra?: string) => (extra ? `${base} ${extra}` : base);

type PopupProps = Omit<BasePopover.Popup.Props, "className"> & {
  className?: string;
  side?: BasePopover.Positioner.Props["side"];
  align?: BasePopover.Positioner.Props["align"];
  sideOffset?: number;
};

function Popup({ className, side = "bottom", align = "start", sideOffset = 4, ...props }: PopupProps) {
  return (
    <BasePopover.Portal container={usePortalContainer()}>
      <BasePopover.Positioner className="ui-popover-positioner" side={side} align={align} sideOffset={sideOffset}>
        <BasePopover.Popup className={join("ui-popover-popup", className)} {...props} />
      </BasePopover.Positioner>
    </BasePopover.Portal>
  );
}

function Title({ className, ...props }: Omit<BasePopover.Title.Props, "className"> & { className?: string }) {
  return <BasePopover.Title className={join("ui-popover-title", className)} {...props} />;
}

function Description({
  className,
  ...props
}: Omit<BasePopover.Description.Props, "className"> & { className?: string }) {
  return <BasePopover.Description className={join("ui-popover-description", className)} {...props} />;
}

export const Popover = {
  Root: BasePopover.Root,
  Trigger: BasePopover.Trigger,
  Close: BasePopover.Close,
  Popup,
  Title,
  Description,
};
```

## Example

```tsx
import { Button, Popover } from "@replicas/ui";

export default function PopoverDemo() {
  return (
    <Popover.Root>
      <Popover.Trigger render={<Button>Project status</Button>} />
      <Popover.Popup>
        <Popover.Title>Mobile app launch</Popover.Title>
        <Popover.Description>
          On track. 12 of 18 tasks done, next milestone is the public beta on Dec 3.
        </Popover.Description>
        <div style={{ display: "flex", justifyContent: "flex-end", marginTop: 8 }}>
          <Popover.Close render={<Button size="small">Done</Button>} />
        </div>
      </Popover.Popup>
    </Popover.Root>
  );
}
```

## Foundations

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