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

> ## Agent Instructions
> Install the Courier skill before writing code: `npx skills add trycourier/courier-skills`. It carries the verified SDK shapes and the rules you cannot get wrong.
> Authenticate every request with `Authorization: Bearer <API_KEY>`. A workspace has several environments and each has its own keys, which are plain `pk_` strings with no environment prefix. Start with Test.
> Send with `client.send.message` from the Node SDK (`@trycourier/courier` v7 and later, where the client is the default import). Reference a template by its `nt_` id or its alias.
> A send accepts a bare Elemental element list, but storing content on a template requires the top-level elements wrapped in a channel element.
> To translate a template, write one locale at a time with `PUT /notifications/{id}/locales/{localeId}`, which merges into the existing translations. `PUT /notifications/{id}/content` and `PUT /notifications/{id}/elements/{elementId}` overwrite translations along with the content, so send each element's `id` and `locales` back, and first remove every `checksum` and any `locales` key that starts with an underscore.
> Templates and journeys can be built in the Courier app or created through the API. Either way they live in the workspace and are referenced by ID when you send.
> The hosted MCP server is https://mcp.courier.com. For a briefing on what Courier is and when to use it, read https://www.courier.com/llms.txt.
> Prefer the Guides tab for how-do-I questions and the Docs tab for how-does-it-behave questions. The API reference lives under /api-reference.

# Customize toasts

> Theme toasts for light and dark mode, replace the toast item or only its content, or skip the component and show your own popup. Web SDKs only.

[Add toasts](https://www.courier.com/docs/in-app/add-toasts.md) covers rendering them. Toasts are a web component, so theming and custom rendering are web-only.

## Theme

Theme toasts with `lightTheme` / `darkTheme` (a `CourierToastTheme`). Set `mode` to `"light"`, `"dark"`, or `"system"`. The default is `"system"`, which follows the user's OS setting.

![A Courier toast with a custom purple theme applied to its action buttons](https://mintcdn.com/courier-4f1f25dc/rYENcCCTyPPrDtw0/assets/toast-theme.webp?fit=max\&auto=format\&n=rYENcCCTyPPrDtw0\&q=85\&s=22b5e2ae9ff8bbc7e82dd97a87f474b0)

A Courier toast with a custom theme.

```jsx React highlight={3-4,6} theme={null}
import { CourierToast } from "@trycourier/courier-react";  // or "@trycourier/courier-react-17"

const lightTheme = { /* CourierToastTheme */ };
const darkTheme = { /* CourierToastTheme */ };

<CourierToast lightTheme={lightTheme} darkTheme={darkTheme} mode="system" />;
```

```html Web Components highlight={7-8} theme={null}
<courier-toast id="toast"></courier-toast>

<script type="module">
  import { Courier } from "@trycourier/courier-ui-toast";

  const toast = document.getElementById("toast");
  toast.setLightTheme({ /* CourierToastTheme */ });
  toast.setDarkTheme({ /* CourierToastTheme */ });
</script>
```

```vue Vue highlight={4-5,9} theme={null}
<script setup lang="ts">
import { CourierToast } from "@trycourier/courier-vue";

const lightTheme = { /* CourierToastTheme */ };
const darkTheme = { /* CourierToastTheme */ };
</script>

<template>
  <CourierToast :lightTheme="lightTheme" :darkTheme="darkTheme" mode="system" />
</template>
```

```ts Angular highlight={8,11-12} theme={null}
import { Component } from "@angular/core";
import { CourierToastComponent, CourierToastTheme } from "@trycourier/courier-angular";

@Component({
  selector: "app-toast",
  standalone: true,
  imports: [CourierToastComponent],
  template: `<courier-toast [lightTheme]="lightTheme" [darkTheme]="darkTheme" mode="system"></courier-toast>`,
})
export class ToastComponent {
  lightTheme: CourierToastTheme = { /* ... */ };
  darkTheme: CourierToastTheme = { /* ... */ };
}
```

The object is the same on React, Vue, Angular, and the Web Components, so it is documented once below.

> [!NOTE]
>
> A toast item has a default border: `1px solid #E5E5E5` in light mode, `1px solid #3A3A3A` in dark. Override it with `item.border`.

### CourierToastTheme reference

Every property is optional, and it is a shallower object than the inbox theme: one `item` key, not a tree of `popup` and `inbox`.

**The theme has no `toast` wrapper.** Pass `{ item: { ... } }` directly. A theme nested under a `toast` key has no effect, and the toast keeps its default look.

```ts theme={null}
type CourierToastTheme = {
  item?: {
    backgroundColor?: string;
    hoverBackgroundColor?: string;
    activeBackgroundColor?: string;
    autoDismissBarColor?: string;      // the countdown bar
    title?: FontTheme;
    body?: FontTheme;
    icon?: IconTheme & { visible?: boolean };
    dismissIcon?: IconTheme & { visible?: boolean };
    shadow?: string;
    border?: string;
    borderRadius?: string;
    actions?: ActionVariantTheme & {
      button?: ActionVariantTheme;     // style: 'button', the filled default
      secondary?: ActionVariantTheme;  // style: 'secondary', outlined
      tertiary?: ActionVariantTheme;   // style: 'tertiary', borderless
      link?: ActionVariantTheme;       // style: 'link', inline text
    };
  };
};

type FontTheme = { family?: string; weight?: string; size?: string; color?: string };
type IconTheme = { color?: string; svg?: string };

type ActionVariantTheme = {
  backgroundColor?: string;
  hoverBackgroundColor?: string;
  activeBackgroundColor?: string;
  border?: string;
  borderRadius?: string;
  shadow?: string;
  textDecoration?: string;
  padding?: string;
  font?: FontTheme;
};
```

**`actions` carries a default at its top level and one override per style.** Fields set
directly on `actions` apply to every action button. The `button`, `secondary`, `tertiary`,
and `link` keys layer over that, each for actions asking for that look. So set shared
padding once on `actions`, and only the colours per variant.

Setting `icon.visible` to `false` drops the icon and the space it reserved, for toasts that
read better as text alone.

> [!NOTE]
>
> The built-in toast is **web-only**. On iOS, Android, Flutter, and React Native, listen for new messages and style your own UI. See [Add toasts](https://www.courier.com/docs/in-app/add-toasts.md).

## Custom UI

On the web SDKs, toasts support the same custom rendering as the inbox.

### Replace the toast item

Swap the toast item for your own element while the SDK keeps managing the feed:

```jsx React theme={null}
<CourierToast renderToastItem={(props) => <MyToast message={props?.message} />} />
```

```js Web Components theme={null}
const toast = document.querySelector("courier-toast");
toast.setToastItem((props) => renderToast(props));
```

```vue Vue theme={null}
<CourierToast :renderToastItem="(props) => renderToast(props)" />
```

```html Angular theme={null}
<courier-toast>
  <ng-template #toastItem let-props>
    <!-- your custom toast; props.message is available -->
  </ng-template>
</courier-toast>
```

A replaced item still dismisses itself on the `autoDismiss` timer. The renderer receives `autoDismiss` and `autoDismissTimeoutMs` alongside the `message`, so your element can draw its own countdown.

### Replace only the content

Replace the content instead of the item to change only what sits inside a toast. The SDK keeps drawing the frame, the countdown bar, and the dismiss button, and still fires `onToastItemClick`.

![A Courier toast whose content area shows a custom icon, a bold title, a body line, and a custom close button, inside the default toast frame](https://mintcdn.com/courier-4f1f25dc/fN1MbwzHtG3Vhos5/assets/courier-toast-custom-item-content.webp?fit=max\&auto=format\&n=fN1MbwzHtG3Vhos5\&q=85\&s=c92c48ff62db652c8fd2d15e9e470b7a)

A toast with custom content inside the default frame.

```jsx React theme={null}
<CourierToast renderToastItemContent={(props) => <MyToastContent message={props.message} />} />
```

```js Web Components theme={null}
const toast = document.querySelector("courier-toast");
toast.setToastItemContent((props) => renderContent(props));
```

```vue Vue theme={null}
<CourierToast :renderToastItemContent="(props) => renderContent(props)" />
```

```html Angular theme={null}
<courier-toast>
  <ng-template #toastItemContent let-props>
    <!-- your custom content; props.message is available -->
  </ng-template>
</courier-toast>
```

### Show your own popup

Skip the component: subscribe to the datastore and react to new messages with `onMessageAdd`. The datastore comes from `@trycourier/courier-ui-inbox` on every framework. Only the lifecycle wiring differs.

```jsx React highlight={6} theme={null}
import { useEffect } from "react";
import { CourierInboxDatastore, CourierInboxDataStoreListener } from "@trycourier/courier-ui-inbox";

useEffect(() => {
  const listener = new CourierInboxDataStoreListener({
    onMessageAdd: (message, index, datasetId) => showMyPopup(message),
  });
  CourierInboxDatastore.shared.addDataStoreListener(listener);

  return () => CourierInboxDatastore.shared.removeDataStoreListener(listener);
}, []);
```

```js Web Components highlight={4} theme={null}
import { CourierInboxDatastore, CourierInboxDataStoreListener } from "@trycourier/courier-ui-inbox";

const listener = new CourierInboxDataStoreListener({
  onMessageAdd: (message, index, datasetId) => showMyPopup(message),
});
CourierInboxDatastore.shared.addDataStoreListener(listener);
```

```vue Vue highlight={6} theme={null}
<script setup lang="ts">
import { onMounted, onUnmounted } from "vue";
import { CourierInboxDatastore, CourierInboxDataStoreListener } from "@trycourier/courier-ui-inbox";

const listener = new CourierInboxDataStoreListener({
  onMessageAdd: (message, index, datasetId) => showMyPopup(message),
});

onMounted(() => CourierInboxDatastore.shared.addDataStoreListener(listener));
onUnmounted(() => CourierInboxDatastore.shared.removeDataStoreListener(listener));
</script>
```

```ts Angular highlight={7} theme={null}
import { Component, OnDestroy, OnInit } from "@angular/core";
import { CourierInboxDatastore, CourierInboxDataStoreListener } from "@trycourier/courier-ui-inbox";

@Component({ /* ... */ })
export class ToastPopupComponent implements OnInit, OnDestroy {
  private listener = new CourierInboxDataStoreListener({
    onMessageAdd: (message, index, datasetId) => this.showMyPopup(message),
  });

  ngOnInit() {
    CourierInboxDatastore.shared.addDataStoreListener(this.listener);
  }

  ngOnDestroy() {
    CourierInboxDatastore.shared.removeDataStoreListener(this.listener);
  }
}
```

See [Customize the inbox](https://www.courier.com/docs/in-app/build-a-custom-inbox.md) for the full inbox datastore surface.
