# Customer portal template

Compose profile, billing, usage, active sessions, and support into a complete customer account portal.

Access: pro. Category: Templates. Kind: template.

## When to use

- Use it to start a complete customer portal template whose major regions should share one responsive composition.
- Choose it inside an authenticated product surface when the host application owns routing, persistence, and service calls.

## Alternatives

- Choose dashboard-layout instead when a responsive semantic dashboard shell with composable header, navigation, main content, and an in-flow mobile disclosure is the actual interface need, rather than customer portal template.

## Setup for agents

Use React 19 and TypeScript. Initialize shadcn for your framework, then merge this exact entry into components.json:

```json
{
  "registries": {
    "@tidal-pro": {
      "url": "https://tidalui.com/r/pro/{name}.json",
      "headers": {
        "Authorization": "Bearer ${TIDALUI_TOKEN}"
      }
    }
  }
}
```

The namespace must be named **@tidal-pro** because transitive Pro dependencies use that namespace. Obtain an agent key from your active Pro account at https://tidalui.com/account. Keep TIDALUI_TOKEN in your local environment, never in components.json, client code, Git or logs.

```sh
export TIDALUI_TOKEN='your-private-agent-key'
npx shadcn@latest add @tidal-pro/waitlist-form
npx shadcn@latest add https://tidalui.com/r/tidal-button.json
```

Free command: `npx shadcn@latest add https://tidalui.com/r/<name>.json`.
Pro command: `npx shadcn@latest add @tidal-pro/<name>`.

Import the base stylesheet and every stylesheet listed on the installed item's metadata. For example:

```tsx
import "./components/ui/tidal.css";
import "./components/ui/hero-section.css";
// Place installed components inside this wrapper:
<div className="tidal-scope" data-theme="dark">...</div>
```

Omit data-theme for the default light theme. Put the attribute on the same tidal-scope element for dark mode. Every component installs the shared free tidal-base dependency. After upgrading, run `npx shadcn@latest add https://tidalui.com/r/tidal-base.json --overwrite` to receive current tokens. Review local modifications before overwriting.

Vite: Use React + TypeScript. Map @/* to ./src/* in paths and Vite resolve.alias. Import tidal.css and each component stylesheet in your application entry.

Next.js 15 App Router: Next.js App Router: import tidal.css and component CSS in app/layout.tsx. Interactive examples belong in a client component with "use client". Map @/* to ./* or ./src/* to match your project.

TypeScript 6: use paths without baseUrl:

```json
{
  "compilerOptions": {
    "paths": {
      "@/*": [
        "./src/*"
      ]
    }
  }
}
```

Pro registry requests are server/CLI-only. Use the same-origin account interface in a browser; cross-origin Authorization preflights are intentionally unsupported.


## Install Customer portal template

```sh
npx shadcn@latest add @tidal-pro/customer-portal-template
```

Stylesheets: `components/ui/tidal.css`, `components/ui/customer-portal-template.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/customer-portal-template.css";
import{TidalCustomerPortalTemplate}from"./components/ui/customer-portal-template";
export default(p:Parameters<typeof TidalCustomerPortalTemplate>[0])=><div className="tidal-scope"><TidalCustomerPortalTemplate {...p}/></div>;
```

## Structured props

- `TidalCustomerPortalTemplate.billing: TidalCustomerPortalBillingConfig`: Required billing value accepted by this exported component.
- `TidalCustomerPortalTemplate.profile: TidalCustomerPortalProfileConfig`: Required profile value accepted by this exported component.
- `TidalCustomerPortalTemplate.sessions: TidalCustomerPortalSessionsConfig`: Required sessions value accepted by this exported component.
- `TidalCustomerPortalTemplate.support: TidalCustomerPortalSupportConfig`: Required support value accepted by this exported component.
- `TidalCustomerPortalTemplate.title: ReactNode`: Required title value accepted by this exported component.
- `TidalCustomerPortalTemplate.usage: TidalCustomerPortalUsageConfig`: Required usage value accepted by this exported component.
- `TidalCustomerPortalTemplate.billingRef?: Ref<HTMLElement> | undefined`: Optional billing ref value accepted by this exported component.
- `TidalCustomerPortalTemplate.description?: ReactNode`: Optional description value accepted by this exported component.
- `TidalCustomerPortalTemplate.eyebrow?: ReactNode`: Optional eyebrow value accepted by this exported component.
- `TidalCustomerPortalTemplate.footer?: ReactNode`: Optional footer value accepted by this exported component.
- `TidalCustomerPortalTemplate.helpHref?: string | undefined`: Optional help href value accepted by this exported component.
- `TidalCustomerPortalTemplate.helpLabel?: ReactNode`: Optional help label value accepted by this exported component.
- `TidalCustomerPortalTemplate.helpLinkProps?: PortalLinkProps | undefined`: Optional help link props value accepted by this exported component.
- `TidalCustomerPortalTemplate.helpLinkRef?: Ref<HTMLAnchorElement> | undefined`: Optional help link ref value accepted by this exported component.
- `TidalCustomerPortalTemplate.labels?: Partial<{ navigation: string; overview: ReactNode; profile: ReactNode; billing: ReactNode; usage: ReactNode; sessions: ReactNode; support: ReactNode; }> | undefined`: Optional labels value accepted by this exported component.
- `TidalCustomerPortalTemplate.profileRef?: Ref<HTMLElement> | undefined`: Optional profile ref value accepted by this exported component.
- `TidalCustomerPortalTemplate.sessionsRef?: Ref<HTMLElement> | undefined`: Optional sessions ref value accepted by this exported component.
- `TidalCustomerPortalTemplate.supportRef?: Ref<HTMLElement> | undefined`: Optional support ref value accepted by this exported component.
- `TidalCustomerPortalTemplate.usageRef?: Ref<HTMLElement> | undefined`: Optional usage ref value accepted by this exported component.

## Complete usage example

[Source](https://tidalui.com/examples/customer-portal-template.tsx) | [Manifest](https://tidalui.com/examples/customer-portal-template.json). Install the listed additional dependencies. Consumer fixture: TypeScript pass; Vite pass. This fixture check is distinct from the actual shadcn install receipt.

```tsx
import "./components/ui/tidal.css";

import { useId, useMemo, useState, type MouseEvent } from "react";

import { TidalCustomerPortalTemplate, type TidalCustomerPortalBillingConfig, type TidalCustomerPortalSupportConfig } from "./components/ui/customer-portal-template";

import type { TidalSessionRecord } from "./components/ui/session-manager";

import type { TidalSupportTicket } from "./components/ui/support-inbox";

import "./components/ui/session-manager.css";

import "./components/ui/support-inbox.css";

import "./components/ui/customer-portal-template.css";

import "./components/ui/customer-profile.css";

import "./components/ui/status-badge.css";

import "./components/ui/billing-overview.css";

import "./components/ui/usage-limits.css";

import "./components/ui/meter.css";

function tidalExampleAvatarDataUri(seed: unknown) {
  const text = String(seed).replace(/[^a-z0-9]/gi, "").slice(-2) || "UI";
  const palette = ["#333333", "#555555", "#777777", "#999999", "#bbbbbb"];
  const color = palette[Array.from(text).reduce((sum, character) => sum + character.charCodeAt(0), 0) % palette.length];
  const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96"><rect width="96" height="96" rx="48" fill="${color}"/><circle cx="48" cy="38" r="17" fill="white" fill-opacity=".92"/><path d="M18 92c3-22 15-34 30-34s27 12 30 34" fill="white" fill-opacity=".92"/></svg>`;
  return `data:image/svg+xml,${encodeURIComponent(svg)}`;
}

function tidalExampleImageDataUri(label: string) {
  const safeLabel = label.replace(/[<>&]/g, "").slice(0, 28) || "Sample image";
  const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 675"><defs><linearGradient id="g" x1="0" x2="1" y1="0" y2="1"><stop stop-color="#171717"/><stop offset="1" stop-color="#555555"/></linearGradient></defs><rect width="1200" height="675" fill="url(#g)"/><circle cx="950" cy="100" r="260" fill="white" fill-opacity=".08"/><text x="80" y="570" fill="white" font-family="system-ui,sans-serif" font-size="64" font-weight="700">${safeLabel}</text></svg>`;
  return `data:image/svg+xml,${encodeURIComponent(svg)}`;
}

const tidalExampleStyles = ".tidal-scope .tidal-customer-portal-demo,\n.tidal-scope .tidal-customer-portal-demo * {\n  box-sizing: border-box;\n}\n\n.tidal-scope .tidal-customer-portal-demo {\n  inline-size: 100%;\n  min-inline-size: 0;\n  display: grid;\n  justify-items: center;\n  gap: 16px;\n}\n\n.tidal-scope .tidal-customer-portal-demo-action {\n  min-block-size: 44px;\n  padding: 8px 13px;\n  border: 1px solid var(--t-border-strong);\n  border-radius: 10px;\n  background: var(--t-surface);\n  color: var(--t-ink);\n  font: inherit;\n  font-size: 11px;\n  font-weight: 700;\n  cursor: pointer;\n}\n\n.tidal-scope .tidal-customer-portal-demo-action:hover {\n  background: var(--t-subtle);\n}\n\n.tidal-scope .tidal-customer-portal-demo-note {\n  inline-size: min(100%, 1180px);\n  min-inline-size: 0;\n  padding: 16px;\n  border: 1px solid var(--t-border);\n  border-radius: var(--t-radius-card);\n  background: var(--t-surface);\n  scroll-margin-block-start: 16px;\n}\n\n.tidal-scope .tidal-customer-portal-demo-note h2,\n.tidal-scope .tidal-customer-portal-demo-note p {\n  margin: 0;\n}\n\n.tidal-scope .tidal-customer-portal-demo-note h2 {\n  font-size: 15px;\n}\n\n.tidal-scope .tidal-customer-portal-demo-note p {\n  margin-block-start: 6px;\n  color: var(--t-muted);\n  font-size: 11px;\n  line-height: 1.55;\n}\n\n@media (prefers-reduced-motion: reduce) {\n  .tidal-scope .tidal-customer-portal-demo-action {\n    transition: none;\n  }\n}";

const initialSessions: readonly TidalSessionRecord[] = [
  {
    id: "current",
    device: "MacBook Pro · Safari",
    detail: "Current browser",
    location: "Austin, Texas",
    lastActive: "Active now",
    current: true,
  },
  {
    id: "phone",
    device: "iPhone · Mobile Safari",
    location: "Austin, Texas",
    lastActive: "18 minutes ago",
    dateTime: "2026-10-15T14:42:00-05:00",
  },
  {
    id: "studio",
    device: "Studio PC · Chrome",
    location: "Dallas, Texas",
    lastActive: "3 days ago",
    dateTime: "2026-10-12T09:20:00-05:00",
  },
];

const initialTickets: readonly TidalSupportTicket[] = [
  {
    id: "exports",
    customerName: "Ava Morgan",
    subject: "Export column order",
    preview: "Can I save a preferred column order?",
    timestamp: "Today",
    status: "open",
    statusLabel: "Open",
    unreadCount: 1,
    avatarSrc: tidalExampleAvatarDataUri("04"),
    messages: [
      {
        id: "exports-1",
        authorName: "Ava Morgan",
        body: "Can I save a preferred column order for future exports?",
        timestamp: "9:24 AM",
        avatarSrc: tidalExampleAvatarDataUri("04"),
        side: "customer",
      },
      {
        id: "exports-2",
        authorName: "Support sample",
        body: "Saved export layouts are available from the export menu.",
        timestamp: "9:31 AM",
        side: "agent",
      },
    ],
  },
  {
    id: "members",
    customerName: "Ava Morgan",
    subject: "Member access",
    preview: "A teammate needs access to the reports folder.",
    timestamp: "Oct 12",
    status: "closed",
    statusLabel: "Closed",
    messages: [
      {
        id: "members-1",
        authorName: "Ava Morgan",
        body: "A teammate needs access to the reports folder.",
        timestamp: "Oct 12",
        avatarSrc: tidalExampleAvatarDataUri("04"),
        side: "customer",
      },
    ],
  },
];

function isPlainPrimary(event: MouseEvent<HTMLAnchorElement>) {
  return (
    event.button === 0 &&
    !event.metaKey &&
    !event.ctrlKey &&
    !event.shiftKey &&
    !event.altKey
  );
}

export function CustomerPortalTemplateDemo({
  theme = "light",
}: {
  theme?: "light" | "dark";
}) {
  const generatedId = useId().replace(/:/g, "");
  const helpId = `customer-portal-help-${generatedId}`;
  const invoiceId = `customer-portal-invoice-${generatedId}`;
  const [billingPeriod, setBillingPeriod] = useState("current");
  const [sessions, setSessions] = useState(initialSessions);
  const [tickets, setTickets] = useState(initialTickets);
  const [selectedTicketId, setSelectedTicketId] = useState("exports");
  const [search, setSearch] = useState("");
  const [statusFilter, setStatusFilter] = useState("all");
  const [draft, setDraft] = useState("");
  const [showProfileNote, setShowProfileNote] = useState(false);
  const [showPlanDetails, setShowPlanDetails] = useState(false);
  const [showUsageDetails, setShowUsageDetails] = useState(false);
  const [notice, setNotice] = useState("Local sample ready.");

  const visibleTickets = useMemo(() => {
    const query = search.trim().toLocaleLowerCase();
    return tickets.filter(
      (ticket) =>
        (statusFilter === "all" || ticket.status === statusFilter) &&
        (!query ||
          ticket.subject.toLocaleLowerCase().includes(query) ||
          ticket.customerName.toLocaleLowerCase().includes(query)),
    );
  }, [search, statusFilter, tickets]);

  const billing: TidalCustomerPortalBillingConfig = {
    title: "Billing overview",
    description: "Current sample plan, allowances, and invoices.",
    plan: {
      name: "Studio",
      accessibleName: "Studio plan",
      status: "Active",
      price: billingPeriod === "current" ? "$32" : "$384",
      priceNote: billingPeriod === "current" ? "per month" : "per year",
      description: showPlanDetails
        ? "Workspace controls and reporting for a small team."
        : undefined,
      details: showPlanDetails
        ? [
            { id: "seats", label: "Seats", value: "8 included" },
            { id: "renewal", label: "Next review", value: "Nov 15, 2026" },
          ]
        : undefined,
      action: {
        id: "review-plan",
        kind: "button",
        label: showPlanDetails ? "Hide plan details" : "Show plan details",
        onAction: () => {
          setShowPlanDetails((visible) => !visible);
          setNotice(
            showPlanDetails
              ? "Plan details hidden."
              : "Plan details shown locally.",
          );
        },
      },
    },
    allowances: [
      {
        id: "members",
        label: "Members",
        valueLabel: "5 of 8 seats",
        used: 5,
        limit: 8,
        description: "Three seats remain in this sample plan.",
      },
      {
        id: "storage",
        label: "Storage",
        valueLabel: "18 GB of 50 GB",
        used: 18,
        limit: 50,
      },
    ],
    invoices: [
      {
        id: "inv-1048",
        label: "INV-1048",
        accessibleLabel: "invoice INV-1048",
        date: "Oct 15, 2026",
        total: "$32.00",
        status: "Paid",
        destination: {
          href: `#${invoiceId}`,
          linkProps: {
            onClick: (event: import("react").MouseEvent<HTMLAnchorElement>) => {
              if (isPlainPrimary(event)) setNotice("Sample invoice selected.");
            },
          },
        },
      },
      {
        id: "inv-1037",
        label: "INV-1037",
        accessibleLabel: "invoice INV-1037",
        date: "Sep 15, 2026",
        total: "$32.00",
        status: "Paid",
        destination: { href: `#${invoiceId}` },
      },
    ],
    invoiceCaption: "Sample invoices",
    periodControl: {
      value: billingPeriod,
      label: "Billing period",
      options: [
        { value: "current", label: "Monthly" },
        { value: "annual", label: "Annual" },
      ],
      onValueChange: setBillingPeriod,
    },
    footer: "No charge or plan change is made in this preview.",
  };

  const support: TidalCustomerPortalSupportConfig = {
    title: "Support",
    eyebrow: "",
    description: "Search the sample record or add a local reply.",
    tickets: visibleTickets,
    selectedTicketId,
    onTicketSelect: (ticket) => {
      setSelectedTicketId(ticket.id);
      setNotice(`${ticket.subject} selected.`);
    },
    searchValue: search,
    onSearchValueChange: setSearch,
    statusFilterValue: statusFilter,
    statusOptions: [
      { value: "all", label: "All statuses" },
      { value: "open", label: "Open" },
      { value: "closed", label: "Closed" },
    ],
    onStatusFilterChange: setStatusFilter,
    draftValue: draft,
    onDraftValueChange: setDraft,
    onReplySubmit: (ticket, event) => {
      event.preventDefault();
      const body = draft.trim();
      if (!body) return;
      setTickets((current) =>
        current.map((item) =>
          item.id === ticket.id
            ? {
                ...item,
                preview: body,
                messages: [
                  ...item.messages,
                  {
                    id: `${item.id}-local-${item.messages.length + 1}`,
                    authorName: "Ava Morgan",
                    body,
                    timestamp: "Now",
                    avatarSrc: tidalExampleAvatarDataUri("04"),
                    side: "customer" as const,
                  },
                ],
              }
            : item,
        ),
      );
      setDraft("");
      setNotice("Reply added to the local sample.");
    },
    composerPlaceholder: "Write a sample reply",
    submitLabel: "Add local reply",
  };

  return (
    <div className="tidal-customer-portal-demo" data-theme={theme}>
      <TidalCustomerPortalTemplate
        title="Your account"
        description="Review profile, billing, usage, active sessions, and support in one place."
        helpHref={`#${helpId}`}
        helpLabel="Account help"
        profile={{
          customer: {
            name: "Ava Morgan",
            company: "Northstar Studio",
            detail: "Member since February 2025",
            imageSrc: tidalExampleAvatarDataUri("04"),
          },
          contacts: [
            { id: "email", label: "Email", value: "ava@example.test" },
            { id: "phone", label: "Phone", value: "+1 (555) 014-2038" },
          ],
          fields: [
            { id: "workspace", label: "Workspace", value: "Northstar" },
            { id: "region", label: "Data region", value: "United States" },
          ],
          health: { label: "Account in good standing", status: "success" },
          plan: { name: "Studio", detail: "5 of 8 seats used" },
          actions: [
            {
              id: "review-profile",
              kind: "button",
              label: showProfileNote
                ? "Hide profile note"
                : "Show profile note",
              onAction: () => {
                setShowProfileNote((visible) => !visible);
                setNotice(
                  showProfileNote
                    ? "Profile note hidden."
                    : "Profile note shown locally.",
                );
              },
            },
          ],
          note: showProfileNote
            ? "Preferred workspace contact for billing and support."
            : undefined,
          activity: [
            {
              id: "profile-update",
              title: "Profile reviewed",
              description: "Workspace contact details were checked.",
              time: "Oct 14",
              dateTime: "2026-10-14",
            },
            {
              id: "invoice-paid",
              title: "Invoice marked paid",
              description: "Sample invoice INV-1048.",
              time: "Oct 15",
              dateTime: "2026-10-15",
              href: `#${invoiceId}`,
              linkLabel: "View invoice note",
            },
          ],
        }}
        billing={billing}
        usage={{
          title: "Usage",
          description: showUsageDetails
            ? "Sample plan allowances for the current period. Values reset on the dates shown."
            : undefined,
          metrics: [
            {
              id: "automation-runs",
              kind: "metered",
              label: "Automation runs",
              value: 642,
              limit: 1000,
              valueText: "642 runs",
              limitText: "1,000 runs",
              description: showUsageDetails
                ? "358 sample runs remain in this period."
                : undefined,
              reset: { label: "Resets Nov 1", dateTime: "2026-11-01" },
            },
            {
              id: "reports",
              kind: "unlimited",
              label: "Saved reports",
              valueText: "No set limit",
              description: showUsageDetails
                ? "Saved reports do not use a metered allowance in this sample."
                : undefined,
            },
          ],
          action: (
            <button
              className="tidal-customer-portal-demo-action"
              type="button"
              onClick={() => {
                setShowUsageDetails((visible) => !visible);
                setNotice(
                  showUsageDetails
                    ? "Usage details hidden."
                    : "Usage details shown locally.",
                );
              }}
            >
              {showUsageDetails ? "Hide usage details" : "Show usage details"}
            </button>
          ),
        }}
        sessions={{
          title: "Active sessions",
          description: "Devices in this fictional account sample.",
          sessions,
          onRevokeRequest: (session) => {
            setSessions((current) =>
              current.filter((item) => item.id !== session.id),
            );
            setNotice(
              `${String(session.device)} removed from the local sample.`,
            );
          },
          onRevokeOthersRequest: () => {
            setSessions((current) =>
              current.filter((session) => session.current),
            );
            setNotice("Other sessions removed from the local sample.");
          },
        }}
        support={support}
        footer={
          <output aria-live="polite">
            {notice} All records are fictional and stay in this page.
          </output>
        }
      />
      <section className="tidal-customer-portal-demo-note">
        <h2>Sample details</h2>
        <p id={invoiceId}>
          INV-1048 is a fictional paid invoice used for this local preview.
        </p>
        <p id={helpId}>
          Account help in this sample does not contact a support service.
        </p>
      </section>
    </div>
  );
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <style>{tidalExampleStyles}</style>
      <CustomerPortalTemplateDemo />
    </div>
  );
}

```

## Gotchas

- The host application owns data, validation, persistence, navigation, and service side effects described by this API.

## Theme and accessibility

{"tokens":["--t-accent","--t-border","--t-border-strong","--t-canvas","--t-danger","--t-display","--t-ease-out","--t-ease-spring","--t-faint","--t-font","--t-ink","--t-line","--t-muted","--t-primary","--t-primary-contrast","--t-radius-card","--t-radius-control","--t-radius-overlay","--t-radius-panel","--t-ring","--t-shadow-lg","--t-shadow-soft","--t-soft","--t-subtle","--t-surface","--t-wash"],"darkMode":true}

{"aria":"The component wires labels and relationships from consumer-provided visible text or ARIA props; preserve those labels in production.","notes":"Verify focus visibility, text alternatives, contrast, and reduced motion in the final composition."}

Consumer-owned profile, billing, usage, session, and support configurations compose five accepted TidalUI blocks beneath one template h1. The template owns the h2/h3 hierarchy, per-instance navigation destinations, descendant mobile layout, and optional native help link. Dedicated root, child-root, and help-link refs support React 19 cleanup. Native child forms, links, actions, modifiers, cancellation, controlled state, and focus recovery remain owned by each composed component. Root and child replacement markup, aggregate unavailable state, and heading overrides are excluded and defensively stripped. The component performs no account, billing, session, support, network, storage, authentication, or messaging effect.
