# Investments

> A portfolio from a broker, read only: value and change, savings plans, dividends, allocation as a donut and every holding with its change and share, for today or one year.

Pattern · Pro kit · [Live page](https://ui.twentyfirst.media/pro/patterns/InvestmentsScreen/)

A portfolio from a broker, read only: value and change, savings plans, dividends, allocation as a
donut and every holding with its change and share, for today or one year.

## Code

```tsx
import * as React from "react";
import {
  AppShell,
  Donut,
  HoldingsList,
  PageHeader,
  Panel,
  Segmented,
  Stagger,
  StatTile,
} from "@twentyfirstmedia/pro";
import { LIFE_NAV } from "./_lifenav";

/** A portfolio: value, change, allocation and holdings with their share. */
export default function Preview() {
  const [period, setPeriod] = React.useState("today");
  return (
    <AppShell
      navigation="sidebar"
      brand="Life"
      sidebarGroups={LIFE_NAV}
      active="investments"
      user={{ name: "Mara Ellis", email: "mara@halo.app" }}
      dock={false}
    >
      <div className="tf-in">
        <PageHeader
          title="Investments"
          subtitle="Scalable Capital · read only"
          actions={[
            <Segmented
              key="p"
              label="Period"
              value={period}
              onChange={setPeriod}
              options={[
                { value: "today", label: "Today" },
                { value: "year", label: "1 year" },
              ]}
            />,
          ]}
        />
      </div>
      <Stagger className="tf-col" style={{ gap: 16 }}>
        <div
          className="tf-grid"
          style={
            {
              "--cols": "repeat(3, minmax(0, 1fr))",
              "--cols-sm": "1fr",
              gap: 16,
            } as React.CSSProperties
          }
        >
          <StatTile
            label="Portfolio value"
            value="€38,420"
            delta={period === "today" ? "+0.2%" : "+11.4%"}
            tint="mint"
          />
          <StatTile label="Savings plans" value="€650 a month" tint="sky" />
          <StatTile label="Dividends this year" value="€412" tint="butter" />
        </div>
        <div
          className="tf-grid"
          style={
            {
              "--cols": "minmax(0, 1fr) minmax(0, 2fr)",
              "--cols-sm": "1fr",
              gap: 16,
            } as React.CSSProperties
          }
        >
          <Panel title="Allocation">
            <Donut
              center="€38k"
              caption="5 positions"
              data={[
                { label: "Developed markets", value: 48, tint: "sky" },
                { label: "Bonds", value: 19, tint: "mint" },
                { label: "Emerging markets", value: 16, tint: "butter" },
                { label: "Single stocks", value: 11, tint: "lilac" },
                { label: "Crypto", value: 6, tint: "blush" },
              ]}
            />
          </Panel>
          <Panel
            title="Holdings"
            subtitle={period === "today" ? "Change today" : "Change over 1 year"}
          >
            <HoldingsList
              period={period === "today" ? "today" : "1 year"}
              onSelect={() => {}}
              holdings={[
                {
                  id: "1",
                  name: "MSCI World ETF",
                  symbol: "IE00B4L5Y983",
                  value: 18420,
                  change: period === "today" ? 0.6 : 14.2,
                  weight: 48,
                },
                {
                  id: "2",
                  name: "Global Bonds ETF",
                  symbol: "IE00B3F81409",
                  value: 7150,
                  change: period === "today" ? 0 : 2.1,
                  weight: 19,
                },
                {
                  id: "3",
                  name: "Emerging Markets ETF",
                  symbol: "IE00BKM4GZ66",
                  value: 6240,
                  change: period === "today" ? -1.2 : 6.8,
                  weight: 16,
                },
                {
                  id: "4",
                  name: "Apple",
                  symbol: "AAPL",
                  value: 4310,
                  change: period === "today" ? 1.8 : 22.5,
                  weight: 11,
                },
                {
                  id: "5",
                  name: "Bitcoin ETP",
                  symbol: "BTCE",
                  value: 2300,
                  change: period === "today" ? -3.4 : 38.0,
                  weight: 6,
                },
              ]}
            />
          </Panel>
        </div>
      </Stagger>
    </AppShell>
  );
}
```

## Props

### AppShell

| Prop | Type | Notes |
| --- | --- | --- |
| `active?` | `string` |  |
| `brand?` | `ReactNode` | The product name, or a node (a logo mark with the name; collapsed sidebars show it whole). |
| `brandDot?` | `boolean` | The status dot after the brand (default `true`); turn it off next to a logo of your own. |
| `tag?` | `string` |  |
| `nav?` | `NavItem[]` |  |
| `user?` | `{ name: string; email?: string }` |  |
| `onNavigate?` | `(label: string) => void` |  |
| `topExtra?` | `ReactNode` |  |
| `sheetStyle?` | `CSSProperties` |  |
| `contentKey?` | `string \| number` |  |
| `side?` | `ReactNode` |  |
| `dock?` | `boolean` |  |
| `dockItems?` | `DockProps["items"]` |  |
| `railTop?` | `RailItem[]` |  |
| `railBottom?` | `RailItem[]` |  |
| `fill?` | `boolean` | The shell is the whole page: at least the viewport's height (100dvh), no outer radius, the sheet fills the rest; on desktop the sidebar stays in view while the page scrolls, on phones the sheet starts right under the sidebar's bar. |
| `navigation?` | `"top" \| "sidebar"` |  |
| `sidebarGroups?` | `SidebarGroup[]` | With `navigation="sidebar"`: groups instead of the flat `nav` list. |
| `sidebar?` | `Partial<Omit<SidebarProps, "variant" \| "groups">>` | With `navigation="sidebar"`: more sidebar props (collapsed, storageKey, shortcut, linkAs …). |
| `workspaces?` | `WorkspaceSwitcherProps` | With `navigation="sidebar"`: the workspace switcher at the top instead of the brand. |
| `userMenu?` | `(MenuItem \| "-")[]` | The account menu's entries (with `navigation="sidebar"` at the foot of the sidebar). |
| `topbar?` | `boolean \| ReactNode` | With `navigation="sidebar"`: a bar across the top of the frame. The brand (or `workspaces`) moves into its start, as wide as the sidebar below it (expanded or collapsed); `topStart` follows it, `topEnd` sits at the end. Frame, bar and sidebar read as one L around the sheet. Content given here goes between `topStart` and `topEnd`. On phones the bar is the sidebar's bar (menu button and brand) with `topEnd` on the right and `topStart` behind an icon button. |
| `topStart?` | `ReactNode` | With `topbar`: right after the brand, e.g. a search field or a command palette trigger. |
| `topEnd?` | `ReactNode` | With `topbar`: at the end of the bar (buttons, menus); `topExtra` goes there too. |
| `topStartCompact?` | `ReactNode` | With `topbar` on phones: what stands in for `topStart` (default: an icon button that opens `topStart` over the bar). |
| `topStartIcon?` | `IconName` | The icon of that button (default `search`). |
| `topStartLabel?` | `string` | The accessible name of that button (default "Search"). |
| `children?` | `ReactNode` |  |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |

### Donut

| Prop | Type | Notes |
| --- | --- | --- |
| `data` | `{ label: string; value: number; tint?: Tint \| "ink" }[]` | Required |
| `center?` | `string` |  |
| `caption?` | `string` |  |
| `size?` | `number` |  |
| `stroke?` | `number` |  |
| `legend?` | `boolean` |  |
| `label?` | `string` |  |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |

### HoldingsList

| Prop | Type | Notes |
| --- | --- | --- |
| `holdings` | `Holding[]` | Required |
| `currency?` | `string` |  |
| `period?` | `string` | The period of `change` ("today", "1 year"). |
| `onSelect?` | `(id: string) => void` |  |
| `label?` | `string` | Accessible name (default "Holdings"). |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |

### PageHeader

| Prop | Type | Notes |
| --- | --- | --- |
| `crumbs?` | `(string \| Crumb)[]` | A breadcrumb above the title (see `Breadcrumb`): labels, or items with `href`/`onClick`. |
| `crumbLinkAs?` | `ElementType` | The element crumb links render as, e.g. Next.js `Link`. |
| `title` | `string` | Required |
| `subtitle?` | `string` |  |
| `actions?` | `ReactNode[]` |  |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |

### Panel

| Prop | Type | Notes |
| --- | --- | --- |
| `side?` | `boolean` |  |
| `title?` | `string` |  |
| `subtitle?` | `string` |  |
| `action?` | `ReactNode` |  |
| `children?` | `ReactNode` |  |
| `surface?` | `Surface` | `"glass"`: translucent glass over what is behind (maps, 3D, video, photos); `"solid"` opts out inside a glass `UIProvider`. |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |

### Segmented

| Prop | Type | Notes |
| --- | --- | --- |
| `options` | `(string \| Option)[]` | Required |
| `value?` | `string` |  |
| `defaultValue?` | `string` |  |
| `onChange?` | `(v: string) => void` |  |
| `size?` | `"sm"` |  |
| `block?` | `boolean` |  |
| `label?` | `string` |  |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |

### StatTile

| Prop | Type | Notes |
| --- | --- | --- |
| `value` | `ReactNode` | Required |
| `label` | `string` | Required |
| `tint?` | `Tint \| "surface" \| "placeholder"` |  |
| `delta?` | `string` |  |
| `delay?` | `number` |  |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |
