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

function SaveChanges() {
  const toastManager = Toast.useToastManager();

  const save = () => {
    toastManager.add({
      title: "Changes saved",
      description: "Your profile has been updated.",
      actionProps: { children: "Undo" },
    });
  };

  return (
    <Button variant="primary" onClick={save}>
      Save changes
    </Button>
  );
}

export default function ToastDemo() {
  return (
    <Toast.Provider>
      <SaveChanges />
    </Toast.Provider>
  );
}

Prompt

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

Show Prompt
# Palermo Toast

Generates toast notifications.

Build a Toast 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](https://base-ui.com/react/components/toast) if it has none.

Fidelity: Partly measured from Palermo's Toast. No reference has been captured yet.

## Tokens

| Token | Light | Dark |
| --- | --- | --- |
| `--color-bg-primary` | `#fff` | `#171615` |
| `--bg-secondary` | `#fafafa` | `#1e1d1c` |
| `--text-primary` | `#18181a` | `#ecebe9` |
| `--text-secondary` | `#787878` | `#aaa8a5` |
| `--text-tertiary` | `#969696` | `#898784` |
| `--chip-bg` | `#fff` | `#1e1d1c` |
| `--chip-bg-hover` | `#f5f5f5` | `#252423` |
| `--chip-text` | `#18181a` | `#ecebe9` |
| `--shadow-low` | `var(--surface-shadow-low), var(--shadow-border)` | `var(--surface-shadow-low), var(--shadow-border)` |
| `--shadow-high` | `var(--surface-shadow-high), var(--shadow-border)` | `var(--surface-shadow-high), var(--shadow-border)` |
| `--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-mini` | `0.75rem` | `0.75rem` |
| `--font-size-small` | `0.8125rem` | `0.8125rem` |
| `--font-size-regular` | `0.875rem` | `0.875rem` |
| `--line-height-mini` | `16px` | `16px` |
| `--line-height-small` | `18px` | `18px` |
| `--line-height-regular` | `20px` | `20px` |
| `--font-weight-normal` | `400` | `400` |
| `--font-weight-medium` | `500` | `500` |
| `--radius-control` | `8px` | `8px` |
| `--radius-4` | `4px` | `4px` |
| `--radius-12` | `12px` | `12px` |
| `--ease-out` | `cubic-bezier(0, 0, 0.2, 1)` | `cubic-bezier(0, 0, 0.2, 1)` |
| `--ease-toast` | `cubic-bezier(0.27, 0, 0.07, 1.01)` | `cubic-bezier(0.27, 0, 0.07, 1.01)` |
| `--duration-fade` | `200ms` | `200ms` |
| `--duration-toast` | `350ms` | `350ms` |

## 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-toast-viewport {
    position: fixed;
    z-index: 1;
    right: 32px;
    bottom: 32px;
    width: 384px;
    max-width: calc(100vw - 32px);
  }

  .ui-toast {
    --gap: 16px;
    --peek: 14px;
    --scale: calc(max(0, 1 - (var(--toast-index) * 0.05)));
    --shrink: calc(1 - var(--scale));
    --height: var(--toast-frontmost-height, var(--toast-height));
    --offset-y: calc(
      var(--toast-offset-y) * -1 + (var(--toast-index) * var(--gap) * -1) + var(--toast-swipe-movement-y)
    );
    box-sizing: border-box;
    position: absolute;
    right: 0;
    bottom: 0;
    z-index: calc(1000 - var(--toast-index));
    width: 100%;
    height: var(--height);
    border-radius: var(--radius-12);
    background-color: var(--color-bg-primary);
    box-shadow: var(--shadow-high);
    color: var(--text-primary);
    font-family: var(--font-regular);
    font-size: var(--font-size-small);
    line-height: var(--line-height-small);
    -webkit-font-smoothing: antialiased;
    cursor: default;
    user-select: none;
    transform-origin: bottom center;
    transform: translateX(var(--toast-swipe-movement-x))
      translateY(
        calc(var(--toast-swipe-movement-y) - (var(--toast-index) * var(--peek)) - (var(--shrink) * var(--height)))
      )
      scale(var(--scale));
    transition:
      transform var(--duration-toast) var(--ease-toast),
      scale var(--duration-toast) var(--ease-toast),
      opacity var(--duration-toast) var(--ease-toast),
      filter var(--duration-toast) var(--ease-toast),
      height var(--duration-toast) var(--ease-toast);

    &::after {
      content: "";
      position: absolute;
      top: 100%;
      left: 0;
      width: 100%;
      height: calc(var(--gap) + 1px);
    }

    &[data-expanded] {
      height: var(--toast-height);
      transform: translateX(var(--toast-swipe-movement-x)) translateY(var(--offset-y));
    }

    &[data-starting-style] {
      opacity: 0;
      filter: blur(6px);
      transform: translateY(100%);
    }

    &[data-limited] {
      opacity: 0;
    }

    &[data-ending-style] {
      opacity: 0;
      filter: blur(6px);
      scale: 0.9;

      &[data-swipe-direction="down"] {
        transform: translateY(calc(var(--toast-swipe-movement-y) + 100% + 32px));
      }

      &[data-swipe-direction="right"] {
        transform: translateX(calc(var(--toast-swipe-movement-x) + 100% + 32px)) translateY(var(--offset-y));
      }
    }

    &[data-swiping] {
      transition-duration: 0s;
    }

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

  .ui-toast-content {
    box-sizing: border-box;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    overflow: hidden;
    transition: opacity var(--duration-toast) var(--ease-toast);

    &[data-behind] {
      opacity: 0;
    }

    &[data-expanded] {
      opacity: 1;
    }
  }

  .ui-toast-text {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
  }

  .ui-toast-title {
    margin: 0;
    color: var(--text-primary);
    font-size: var(--font-size-regular);
    font-weight: var(--font-weight-medium);
    line-height: var(--line-height-regular);
  }

  .ui-toast-description {
    margin: 0;
    color: var(--text-secondary);
    font-size: var(--font-size-small);
    font-weight: var(--font-weight-normal);
    line-height: var(--line-height-small);
  }

  .ui-toast-action {
    box-sizing: border-box;
    flex-shrink: 0;
    align-self: center;
    height: 24px;
    padding: 0 8px;
    border: none;
    border-radius: var(--radius-control);
    background-color: var(--chip-bg);
    box-shadow: var(--shadow-low);
    color: var(--chip-text);
    font-family: inherit;
    font-size: var(--font-size-mini);
    font-weight: var(--font-weight-medium);
    line-height: var(--line-height-mini);
    white-space: nowrap;
    cursor: pointer;
    outline: none;

    @media (hover: hover) {
      &:hover {
        background-color: var(--chip-bg-hover);
      }
    }

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

  .ui-toast-close {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    border: none;
    border-radius: var(--radius-4);
    background-color: transparent;
    color: var(--text-tertiary);
    opacity: 0.7;
    cursor: pointer;
    outline: none;
    transition:
      background-color var(--duration-fade) var(--ease-out),
      opacity var(--duration-fade) var(--ease-out);

    & svg {
      width: 16px;
      height: 16px;
    }

    @media (hover: hover) {
      &:hover {
        background-color: var(--bg-secondary);
        opacity: 1;
      }
    }

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

## Structure

How Replicas assembles it on Base UI.

```tsx
import { Toast as BaseToast } from "@base-ui/react/toast";
import { usePortalContainer } from "./portal";

function List() {
  const { toasts } = BaseToast.useToastManager();

  return toasts.map((toast) => (
    <BaseToast.Root key={toast.id} toast={toast} className="ui-toast">
      <BaseToast.Content className="ui-toast-content">
        <div className="ui-toast-text">
          <BaseToast.Title className="ui-toast-title" />
          <BaseToast.Description className="ui-toast-description" />
        </div>
        <BaseToast.Action className="ui-toast-action" />
        <BaseToast.Close className="ui-toast-close" aria-label="Dismiss">
          <svg viewBox="0 0 16 16" fill="none" aria-hidden="true">
            <path d="M4.5 4.5l7 7m0-7l-7 7" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
          </svg>
        </BaseToast.Close>
      </BaseToast.Content>
    </BaseToast.Root>
  ));
}

function Provider({ children, ...props }: BaseToast.Provider.Props) {
  return (
    <BaseToast.Provider {...props}>
      {children}
      <BaseToast.Portal container={usePortalContainer()}>
        <BaseToast.Viewport className="ui-toast-viewport">
          <List />
        </BaseToast.Viewport>
      </BaseToast.Portal>
    </BaseToast.Provider>
  );
}

export const Toast = {
  Provider,
  useToastManager: BaseToast.useToastManager,
  createToastManager: BaseToast.createToastManager,
};
```

## Example

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

function SaveChanges() {
  const toastManager = Toast.useToastManager();

  const save = () => {
    toastManager.add({
      title: "Changes saved",
      description: "Your profile has been updated.",
      actionProps: { children: "Undo" },
    });
  };

  return (
    <Button variant="primary" onClick={save}>
      Save changes
    </Button>
  );
}

export default function ToastDemo() {
  return (
    <Toast.Provider>
      <SaveChanges />
    </Toast.Provider>
  );
}
```

## Foundations

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