# Complex App

**complex-app.tsx**

```tsx
import {
  ActionGroup,
  Avatar,
  Breadcrumb,
  Button,
  Content,
  ContextMenu,
  ContextMenuTrigger,
  CounterBadge,
  Flex,
  HeaderNavigation,
  Heading,
  IconApp,
  IconCronjob,
  IconDashboard,
  IconDatabase,
  IconDomain,
  IconEmail,
  IconLogout,
  IconMember,
  IconMenu,
  IconMonitoring,
  IconNotification,
  IconSearch,
  IconSettings,
  IconSshSftp,
  Initials,
  Label,
  LayoutCard,
  Link,
  MenuItem,
  Modal,
  ModalTrigger,
  Navigation,
  NavigationGroup,
  ProgressBar,
  Section,
  Text,
  typedList,
} from "@mittwald/flow-react-components";
import styles from "./complex-app.module.css";

interface Mailbox {
  id: string;
  address: string;
  type: string;
  color: "blue" | "teal" | "violet";
  storage?: { used: number; max: number };
}

const mailboxes: Mailbox[] = [
  {
    id: "1",
    address: "max.mustermann@mittwald.de",
    type: "E-Mail-Adresse",
    color: "blue",
    storage: { used: 1, max: 2 },
  },
  {
    id: "2",
    address: "kontakt@mittwald.de",
    type: "E-Mail-Adresse",
    color: "blue",
    storage: { used: 0.5, max: 2 },
  },
  {
    id: "3",
    address: "info@mittwald.de",
    type: "Weiterleitungsadresse",
    color: "teal",
  },
  {
    id: "4",
    address: "hallo@mittwald.de",
    type: "Catch-All-Adresse",
    color: "violet",
    storage: { used: 0, max: 2 },
  },
];

const MailboxList = typedList<Mailbox>();

export default () => (
  <Flex direction="column" className={styles.app}>
    <Topbar />
    <Flex
      direction="column"
      gap="l"
      grow
      className={styles.content}
    >
      <Flex gap="l" align="stretch" className={styles.body}>
        <ProjectSidebar />
        <Flex
          elementType="main"
          direction="column"
          gap="m"
          className={styles.main}
        >
          <Breadcrumb>
            <Link href="#">Projekt</Link>
            <Link href="#">E-Mails</Link>
          </Breadcrumb>
          <Heading level={1}>E-Mails</Heading>
          <LayoutCard>
            <MailboxList.List
              batchSize={4}
              aria-label="E-Mail-Adressen"
              getItemId={(m) => m.id}
            >
              <MailboxList.StaticData data={mailboxes} />
              <ActionGroup>
                <Button>Anlegen</Button>
              </ActionGroup>
              <MailboxList.Search />
              <MailboxList.Filter
                property="type"
                name="Typ"
                mode="some"
              />
              <MailboxList.Sorting
                property="address"
                name="Alphabetisch"
                direction="asc"
                directionName="aufsteigend"
                defaultEnabled
              />
              <MailboxList.Sorting
                property="address"
                name="Alphabetisch"
                direction="desc"
                directionName="absteigend"
              />
              <MailboxList.Item
                textValue={(m) => m.address}
              >
                {(m) => (
                  <MailboxList.ItemView
                    l={[3, 1]}
                    m={[2, 1]}
                    s={[1]}
                  >
                    <Avatar color={m.color}>
                      <IconEmail />
                    </Avatar>
                    <Heading>{m.address}</Heading>
                    <Text>{m.type}</Text>
                    {m.storage && (
                      <Content>
                        <ProgressBar
                          size="s"
                          showMaxValue
                          value={m.storage.used}
                          maxValue={m.storage.max}
                          formatOptions={{
                            style: "unit",
                            unit: "gigabyte",
                          }}
                        >
                          <Label>Speicher</Label>
                        </ProgressBar>
                      </Content>
                    )}
                    <ContextMenu>
                      <MenuItem>Details anzeigen</MenuItem>
                      <MenuItem>Bearbeiten</MenuItem>
                      <MenuItem>Löschen</MenuItem>
                    </ContextMenu>
                  </MailboxList.ItemView>
                )}
              </MailboxList.Item>
            </MailboxList.List>
          </LayoutCard>
        </Flex>
      </Flex>
      <Footer />
    </Flex>
  </Flex>
);

/*
 * The global navigation links, shared by the top bar and the off-canvas. Each
 * renders them through its own props context, so the same Links read as a
 * header bar in one and as a navigation list in the other.
 */
const GlobalNavigationLinks = () => (
  <>
    <Link href="#">Dashboard</Link>
    <Link href="#">Organisation</Link>
    <Link href="#">Server</Link>
    <Link href="#" aria-current="page">
      Projekte
    </Link>
  </>
);

const Topbar = () => (
  <header className={styles.header}>
    <Flex
      align="center"
      wrap="wrap"
      gap="m"
      className={styles.headerContent}
    >
      <span
        className={styles.logo}
        role="img"
        aria-label="mittwald"
      />
      <HeaderNavigation
        aria-label="Hauptnavigation"
        className={styles.topnav}
      >
        <GlobalNavigationLinks />
        <SearchButton />
        <NotificationButton />
        <ContextMenuTrigger>
          <Button aria-label="Konto">
            <Avatar>
              <Initials>Max Mustermann</Initials>
            </Avatar>
          </Button>
          <ContextMenu>
            <MenuItem>
              <IconSettings />
              <Text>Profil</Text>
            </MenuItem>
            <MenuItem>
              <IconLogout />
              <Text>Abmelden</Text>
            </MenuItem>
          </ContextMenu>
        </ContextMenuTrigger>
      </HeaderNavigation>
      <HeaderNavigation className={styles.mobileActions}>
        <SearchButton />
        <NotificationButton />
        <MobileMenu />
      </HeaderNavigation>
    </Flex>
  </header>
);

/*
 * Search and the bell keep their place next to the burger: both are worth
 * reaching without opening the menu first.
 */
const SearchButton = () => (
  <Button
    variant="plain"
    color="secondary"
    aria-label="Suche"
  >
    <IconSearch />
  </Button>
);

const NotificationButton = () => (
  <Button aria-label="Benachrichtigungen">
    <IconNotification />
    <CounterBadge count={2} />
  </Button>
);

/*
 * On a narrow screen the top bar has no room for the navigation and the
 * sidebar has no column of its own, so both move in here. The burger is then
 * the shell's only navigation control.
 */
const MobileMenu = () => (
  <ModalTrigger>
    <Button aria-label="Menü öffnen">
      <IconMenu />
    </Button>
    <Modal offCanvas showCloseButton>
      <Heading>Menü</Heading>
      <Content>
        <Section>
          <Navigation aria-label="Hauptnavigation">
            <GlobalNavigationLinks />
          </Navigation>
        </Section>
        <Section>
          <Heading>Mein Projekt</Heading>
          <ProjectNavigation />
        </Section>
      </Content>
      <ActionGroup>
        <Button variant="soft" color="secondary">
          <IconLogout />
          <Text>Abmelden</Text>
        </Button>
      </ActionGroup>
    </Modal>
  </ModalTrigger>
);

const ProjectSidebar = () => (
  <LayoutCard className={styles.sidebar}>
    <Section>
      <Heading>Mein Projekt</Heading>
      <ProjectNavigation />
    </Section>
  </LayoutCard>
);

const ProjectNavigation = () => (
  <Navigation aria-label="Projektnavigation">
    <NavigationGroup>
      <Label>Allgemein</Label>
      <Link href="#">
        <IconDashboard />
        <Text>Dashboard</Text>
      </Link>
      <Link href="#">
        <IconMonitoring />
        <Text>Monitoring</Text>
      </Link>
    </NavigationGroup>
    <NavigationGroup>
      <Label>Komponenten</Label>
      <Link href="#">
        <IconApp />
        <Text>Apps</Text>
      </Link>
      <Link href="#">
        <IconDomain />
        <Text>Domains</Text>
      </Link>
      <Link href="#" aria-current="page">
        <IconEmail />
        <Text>E-Mails</Text>
      </Link>
      <Link href="#">
        <IconDatabase />
        <Text>Datenbanken</Text>
      </Link>
      <Link href="#">
        <IconCronjob />
        <Text>Cronjobs</Text>
      </Link>
      <Link href="#">
        <IconSshSftp />
        <Text>SSH/SFTP</Text>
      </Link>
    </NavigationGroup>
    <NavigationGroup>
      <Label>Verwaltung</Label>
      <Link href="#">
        <IconMember />
        <Text>Mitglieder</Text>
      </Link>
      <Link href="#">
        <IconSettings />
        <Text>Einstellungen</Text>
      </Link>
    </NavigationGroup>
  </Navigation>
);

const Footer = () => (
  <Flex
    elementType="footer"
    justify="center"
    wrap="wrap"
    gap="l"
    className={styles.footer}
  >
    <Link href="#" target="_blank" color="dark">
      Datenschutz
    </Link>
    <Link href="#" target="_blank" color="dark">
      Impressum
    </Link>
  </Flex>
)
```

**complex-app.module.css**

```css
.app {
  /* Header and content share one maximum width, so their edges line up. */
  --page-width: 1800px;

  /* The header's tint is mixed from the gradient's first stop. */
  --header-ground: var(--neutral--color--200);

  /* The header's rendered height; the sticky sidebar starts just below it. */
  --header-height: 72px;

  /* Container-relative here; use 100dvh in a real full-page app. */
  min-height: 100%;
  background: var(--texture--grain), var(--color--background-gradient);
  background-blend-mode: overlay, normal;
}

/*
 * The header stays at the top while the page scrolls beneath it. Its tint is
 * translucent and blurred, so the navigation stays legible above the content.
 */
.header {
  position: sticky;
  top: 0;
  z-index: 1;
  padding-block: var(--size-px--m);
  background-color: color-mix(in srgb, var(--header-ground) 40%, transparent);
  backdrop-filter: blur(var(--blur));
}

.headerContent {
  max-width: var(--page-width);
  margin-inline: auto;
  padding-inline: var(--size-px--xl);
}

.content {
  width: 100%;
  max-width: var(--page-width);
  margin-inline: auto;
  padding-block: var(--size-px--s) var(--size-px--l);
  padding-inline: var(--size-px--xl);
}

/*
 * The wordmark rides on `currentColor` through a CSS mask, so it follows the
 * theme. Swap the masked SVG for your own logo.
 */
.logo {
  width: 7rem;
  max-width: 100%;
  aspect-ratio: 300 / 57;
  background: currentcolor;
  mask: url("./mittwald.svg") no-repeat center / contain;
  -webkit-mask: url("./mittwald.svg") no-repeat center / contain;
}

/* The global navigation is pushed to the far end of the top bar. */
.topnav {
  margin-inline-start: auto;
}

/* The bell and the burger take that place once the navigation gives it up. */
.mobileActions {
  margin-inline-start: auto;
}

/* Sidebar and content fill the space between top bar and footer. */
.body {
  flex: 1;
  min-height: 0;
}

/*
 * The navigation card keeps a fixed width beside the flexible content. It stays
 * below the header while the page scrolls, and scrolls its own links once they
 * outgrow the viewport.
 */
.sidebar {
  flex: 0 0 17rem;
  position: sticky;
  top: calc(var(--header-height) + var(--size-px--s));
  align-self: flex-start;
  max-height: calc(
    100dvh - var(--header-height) - var(--size-px--s) - var(--size-px--l)
  );
  overflow: auto;
}

.main {
  flex: 1 1 auto;
  min-width: 0;
}

.footer {
  margin-block-start: auto;
}

/*
 * Below this width neither the global navigation nor the sidebar fits, so both
 * hand their links to the off-canvas behind the burger.
 */
@media (max-width: 768px) {
  .topnav,
  .sidebar {
    display: none;
  }

  .headerContent,
  .content {
    padding-inline: var(--size-px--m);
  }
}

@media (min-width: 769px) {
  .mobileActions {
    display: none;
  }
}

@media (prefers-contrast: more), (prefers-reduced-transparency) {
  .header {
    background-color: var(--header-ground);
    backdrop-filter: none;
  }
}

/* The dark gradient starts darker than the neutral token. */
[data-theme="dark"] .app {
  --header-ground: #121518;
}
```

---

# Verwendung

Eine Complex App erschließt viele Bereiche über mehrere Navigationsebenen aus
globalem Header, Sidebar und Breadcrumb. Das ist die im mStudio typische Form.
Verwende sie, wenn eine flache Navigation nicht mehr ausreicht. Die gestaffelten
Ebenen halten auch eine große Anwendung übersichtlich und zeigen dem Nutzer
jederzeit, wo er sich befindet. Für ein kleines Werkzeug mit wenigen,
gleichrangigen Bereichen genügt eine
[Simple App](https://flow.mittwald.de/templates/app-shells/simple-app).

---

# Aufbau

- **Header** – Eine [HeaderNavigation](https://flow.mittwald.de/components/navigation/header-navigation)
  trägt die globale Navigationsebene und bereichsübergreifende Funktionen. Er
  bleibt beim Scrollen oben stehen, der Inhalt läuft darunter durch.
- **Sidebar** – Eine [Navigation](https://flow.mittwald.de/components/navigation/navigation) führt durch
  die Unterseiten des aktuellen Bereichs. Sie bleibt beim Scrollen unter dem
  Header stehen.
- **Content Header** – [Breadcrumb](https://flow.mittwald.de/components/navigation/breadcrumb) und
  PageTitle (ein [Heading](https://flow.mittwald.de/components/content/heading) der Ebene 1) orientieren
  den Nutzer in der Tiefe.
- **Content** – Der Inhalt ist auf eine maximale Breite begrenzt und wird in der
  Regel in [LayoutCards](https://flow.mittwald.de/components/structure/layout-card) dargestellt.
  Typische Seitentypen sind beispielsweise
  [Detailseiten](https://flow.mittwald.de/templates/seiten/detailseite),
  [Dashboards](https://flow.mittwald.de/templates/seiten/dashboard) und
  [Übersichtsseiten](https://flow.mittwald.de/templates/seiten/uebersichtsseite).
- **Footer** – Hier lassen sich [Links](https://flow.mittwald.de/components/navigation/link) platzieren,
  etwa Verweise auf Datenschutz oder Impressum.

Auf schmalen Screens ist für Header-Navigation und Sidebar kein Platz. Beide
geben ihre Links an ein [OffCanvas](https://flow.mittwald.de/components/overlays/modal) ab, das ein
Burger-Menü in der Kopfleiste öffnet.

---

# Varianten und Abwandlung

## Detailansicht

Die Detailansicht kombiniert zwei Seitentypen: Über die
[Übersichtsseite](https://flow.mittwald.de/templates/seiten/uebersichtsseite) – eine
[List](https://flow.mittwald.de/components/list/list) – navigiert man in die Tiefe zu einem einzelnen
Objekt. [Breadcrumb](https://flow.mittwald.de/components/navigation/breadcrumb) und PageTitle helfen bei
der Orientierung; eine [TabNavigation](https://flow.mittwald.de/components/navigation/tab-navigation)
gliedert das Objekt in Unterbereiche.

**complex-app-detail.tsx**

```tsx
import {
  ActionGroup,
  Avatar,
  Breadcrumb,
  Button,
  ColumnLayout,
  Content,
  ContextMenu,
  ContextMenuTrigger,
  CounterBadge,
  Flex,
  Header,
  HeaderNavigation,
  Heading,
  IconApp,
  IconCronjob,
  IconDashboard,
  IconDatabase,
  IconDomain,
  IconEmail,
  IconLogout,
  IconMember,
  IconMenu,
  IconMonitoring,
  IconNotification,
  IconSearch,
  IconSettings,
  IconSshSftp,
  Initials,
  InlineCode,
  Label,
  LabeledValue,
  LayoutCard,
  Link,
  MenuItem,
  Modal,
  ModalTrigger,
  Navigation,
  NavigationGroup,
  ProgressBar,
  Section,
  Switch,
  Tab,
  TabNavigation,
  Tabs,
  TabTitle,
  Text,
} from "@mittwald/flow-react-components";
import styles from "./complex-app-detail.module.css";

const connections = {
  imap: {
    server: "imap.mittwald.de",
    port: "993 (SSL/TLS)",
  },
  pop3: {
    server: "pop3.mittwald.de",
    port: "995 (SSL/TLS)",
  },
  smtp: {
    server: "smtp.mittwald.de",
    port: "465 (SSL/TLS)",
  },
};

export default () => (
  <Flex direction="column" className={styles.app}>
    <Topbar />
    <Flex
      direction="column"
      gap="l"
      grow
      className={styles.content}
    >
      <Flex gap="l" align="stretch" className={styles.body}>
        <ProjectSidebar />
        <Flex
          elementType="main"
          direction="column"
          gap="m"
          className={styles.main}
        >
          <Breadcrumb>
            <Link href="#">Projekt</Link>
            <Link href="#">E-Mails</Link>
            <Link href="#">E-Mail-Details</Link>
          </Breadcrumb>
          <Heading level={1}>
            max.mustermann@mittwald.de
          </Heading>
          <LayoutCard>
            <TabNavigation aria-label="E-Mail-Bereiche">
              <Link href="#" aria-current="page">
                Allgemein
              </Link>
              <Link href="#">Weiterleitungen</Link>
              <Link href="#">Autoresponder</Link>
            </TabNavigation>
            <Section>
              <Header>
                <Heading>E-Mail-Adresse</Heading>
                <Button variant="soft" color="secondary">
                  Passwort ändern
                </Button>
                <Button>E-Mail-Adresse bearbeiten</Button>
              </Header>
              <ColumnLayout>
                <LabeledValue>
                  <Label>E-Mail-Adresse</Label>
                  <Content>
                    max.mustermann@mittwald.de
                  </Content>
                </LabeledValue>
                <LabeledValue>
                  <Label>Webmailer</Label>
                  <Link href="#" target="_blank">
                    mittwald Webmailer
                  </Link>
                </LabeledValue>
              </ColumnLayout>
            </Section>

            <Section>
              <Header>
                <Heading>Speicherplatz</Heading>
                <Button variant="soft" color="secondary">
                  Bearbeiten
                </Button>
              </Header>
              <Text>
                Die E-Mail-Adresse verfügt über
                Speicherplatz zum Empfangen und Speichern
                von E-Mails. Wir empfehlen mindestens 2 GB.
              </Text>
              <ProgressBar
                showMaxValue
                value={1}
                maxValue={2}
                formatOptions={{
                  style: "unit",
                  unit: "gigabyte",
                }}
              >
                <Label>Speicherplatz</Label>
              </ProgressBar>
            </Section>

            <Section>
              <Heading>Verbindungsinformationen</Heading>
              <Tabs aria-label="Verbindungsprotokoll">
                {Object.entries(connections).map(
                  ([key, c]) => (
                    <Tab key={key} id={key}>
                      <TabTitle>
                        {key.toUpperCase()}
                      </TabTitle>
                      <ColumnLayout>
                        <LabeledValue>
                          <Label>Benutzername</Label>
                          <InlineCode>
                            max.mustermann@mittwald.de
                          </InlineCode>
                        </LabeledValue>
                        <LabeledValue>
                          <Label>Server</Label>
                          <InlineCode>
                            {c.server}
                          </InlineCode>
                        </LabeledValue>
                        <LabeledValue>
                          <Label>Port</Label>
                          <InlineCode>{c.port}</InlineCode>
                        </LabeledValue>
                      </ColumnLayout>
                    </Tab>
                  ),
                )}
              </Tabs>
            </Section>

            <Section>
              <Header>
                <Heading>Spamschutz</Heading>
                <Switch defaultSelected>
                  <Label>Aktivieren</Label>
                </Switch>
              </Header>
              <Text>
                Der Spamfilter schützt dich vor ungewollten
                E-Mails. Wir empfehlen, ihn immer aktiviert
                zu lassen.
              </Text>
            </Section>
          </LayoutCard>
        </Flex>
      </Flex>
      <Footer />
    </Flex>
  </Flex>
);

/*
 * The global navigation links, shared by the top bar and the off-canvas. Each
 * renders them through its own props context, so the same Links read as a
 * header bar in one and as a navigation list in the other.
 */
const GlobalNavigationLinks = () => (
  <>
    <Link href="#">Dashboard</Link>
    <Link href="#">Organisation</Link>
    <Link href="#">Server</Link>
    <Link href="#" aria-current="page">
      Projekte
    </Link>
  </>
);

const Topbar = () => (
  <header className={styles.header}>
    <Flex
      align="center"
      wrap="wrap"
      gap="m"
      className={styles.headerContent}
    >
      <span
        className={styles.logo}
        role="img"
        aria-label="mittwald"
      />
      <HeaderNavigation
        aria-label="Hauptnavigation"
        className={styles.topnav}
      >
        <GlobalNavigationLinks />
        <SearchButton />
        <NotificationButton />
        <ContextMenuTrigger>
          <Button aria-label="Konto">
            <Avatar>
              <Initials>Max Mustermann</Initials>
            </Avatar>
          </Button>
          <ContextMenu>
            <MenuItem>
              <IconSettings />
              <Text>Profil</Text>
            </MenuItem>
            <MenuItem>
              <IconLogout />
              <Text>Abmelden</Text>
            </MenuItem>
          </ContextMenu>
        </ContextMenuTrigger>
      </HeaderNavigation>
      <HeaderNavigation className={styles.mobileActions}>
        <SearchButton />
        <NotificationButton />
        <MobileMenu />
      </HeaderNavigation>
    </Flex>
  </header>
);

/*
 * Search and the bell keep their place next to the burger: both are worth
 * reaching without opening the menu first.
 */
const SearchButton = () => (
  <Button
    variant="plain"
    color="secondary"
    aria-label="Suche"
  >
    <IconSearch />
  </Button>
);

const NotificationButton = () => (
  <Button aria-label="Benachrichtigungen">
    <IconNotification />
    <CounterBadge count={2} />
  </Button>
);

/*
 * On a narrow screen the top bar has no room for the navigation and the
 * sidebar has no column of its own, so both move in here. The burger is then
 * the shell's only navigation control.
 */
const MobileMenu = () => (
  <ModalTrigger>
    <Button aria-label="Menü öffnen">
      <IconMenu />
    </Button>
    <Modal offCanvas showCloseButton>
      <Heading>Menü</Heading>
      <Content>
        <Section>
          <Navigation aria-label="Hauptnavigation">
            <GlobalNavigationLinks />
          </Navigation>
        </Section>
        <Section>
          <Heading>Mein Projekt</Heading>
          <ProjectNavigation />
        </Section>
      </Content>
      <ActionGroup>
        <Button variant="soft" color="secondary">
          <IconLogout />
          <Text>Abmelden</Text>
        </Button>
      </ActionGroup>
    </Modal>
  </ModalTrigger>
);

const ProjectSidebar = () => (
  <LayoutCard className={styles.sidebar}>
    <Section>
      <Heading>Mein Projekt</Heading>
      <ProjectNavigation />
    </Section>
  </LayoutCard>
);

const ProjectNavigation = () => (
  <Navigation aria-label="Projektnavigation">
    <NavigationGroup>
      <Label>Allgemein</Label>
      <Link href="#">
        <IconDashboard />
        <Text>Dashboard</Text>
      </Link>
      <Link href="#">
        <IconMonitoring />
        <Text>Monitoring</Text>
      </Link>
    </NavigationGroup>
    <NavigationGroup>
      <Label>Komponenten</Label>
      <Link href="#">
        <IconApp />
        <Text>Apps</Text>
      </Link>
      <Link href="#">
        <IconDomain />
        <Text>Domains</Text>
      </Link>
      <Link href="#" aria-current="page">
        <IconEmail />
        <Text>E-Mails</Text>
      </Link>
      <Link href="#">
        <IconDatabase />
        <Text>Datenbanken</Text>
      </Link>
      <Link href="#">
        <IconCronjob />
        <Text>Cronjobs</Text>
      </Link>
      <Link href="#">
        <IconSshSftp />
        <Text>SSH/SFTP</Text>
      </Link>
    </NavigationGroup>
    <NavigationGroup>
      <Label>Verwaltung</Label>
      <Link href="#">
        <IconMember />
        <Text>Mitglieder</Text>
      </Link>
      <Link href="#">
        <IconSettings />
        <Text>Einstellungen</Text>
      </Link>
    </NavigationGroup>
  </Navigation>
);

const Footer = () => (
  <Flex
    elementType="footer"
    justify="center"
    wrap="wrap"
    gap="l"
    className={styles.footer}
  >
    <Link href="#" target="_blank" color="dark">
      Datenschutz
    </Link>
    <Link href="#" target="_blank" color="dark">
      Impressum
    </Link>
  </Flex>
)
```

**complex-app-detail.module.css**

```css
.app {
  /* Header and content share one maximum width, so their edges line up. */
  --page-width: 1800px;

  /* The header's tint is mixed from the gradient's first stop. */
  --header-ground: var(--neutral--color--200);

  /* The header's rendered height; the sticky sidebar starts just below it. */
  --header-height: 72px;

  /* Container-relative here; use 100dvh in a real full-page app. */
  min-height: 100%;
  background: var(--texture--grain), var(--color--background-gradient);
  background-blend-mode: overlay, normal;
}

/*
 * The header stays at the top while the page scrolls beneath it. Its tint is
 * translucent and blurred, so the navigation stays legible above the content.
 */
.header {
  position: sticky;
  top: 0;
  z-index: 1;
  padding-block: var(--size-px--m);
  background-color: color-mix(in srgb, var(--header-ground) 40%, transparent);
  backdrop-filter: blur(var(--blur));
}

.headerContent {
  max-width: var(--page-width);
  margin-inline: auto;
  padding-inline: var(--size-px--xl);
}

.content {
  width: 100%;
  max-width: var(--page-width);
  margin-inline: auto;
  padding-block: var(--size-px--s) var(--size-px--l);
  padding-inline: var(--size-px--xl);
}

/*
 * The wordmark rides on `currentColor` through a CSS mask, so it follows the
 * theme. Swap the masked SVG for your own logo.
 */
.logo {
  width: 7rem;
  max-width: 100%;
  aspect-ratio: 300 / 57;
  background: currentcolor;
  mask: url("./mittwald.svg") no-repeat center / contain;
  -webkit-mask: url("./mittwald.svg") no-repeat center / contain;
}

/* The global navigation is pushed to the far end of the top bar. */
.topnav {
  margin-inline-start: auto;
}

/* The bell and the burger take that place once the navigation gives it up. */
.mobileActions {
  margin-inline-start: auto;
}

/* Sidebar and content fill the space between top bar and footer. */
.body {
  flex: 1;
  min-height: 0;
}

/*
 * The navigation card keeps a fixed width beside the flexible content. It stays
 * below the header while the page scrolls, and scrolls its own links once they
 * outgrow the viewport.
 */
.sidebar {
  flex: 0 0 17rem;
  position: sticky;
  top: calc(var(--header-height) + var(--size-px--s));
  align-self: flex-start;
  max-height: calc(
    100dvh - var(--header-height) - var(--size-px--s) - var(--size-px--l)
  );
  overflow: auto;
}

.main {
  flex: 1 1 auto;
  min-width: 0;
}

.footer {
  margin-block-start: auto;
}

/*
 * Below this width neither the global navigation nor the sidebar fits, so both
 * hand their links to the off-canvas behind the burger.
 */
@media (max-width: 768px) {
  .topnav,
  .sidebar {
    display: none;
  }

  .headerContent,
  .content {
    padding-inline: var(--size-px--m);
  }
}

@media (min-width: 769px) {
  .mobileActions {
    display: none;
  }
}

@media (prefers-contrast: more), (prefers-reduced-transparency) {
  .header {
    background-color: var(--header-ground);
    backdrop-filter: none;
  }
}

/* The dark gradient starts darker than the neutral token. */
[data-theme="dark"] .app {
  --header-ground: #121518;
}
```

## Doku-Layout

Eine einfachere Abwandlung ohne globale Objekt-Tiefe: Die
[Navigation](https://flow.mittwald.de/components/navigation/navigation) listet die Bereiche flach, der
Content steht mittig, und rechts führt ein eigenes Inhaltsverzeichnis („Auf
dieser Seite") durch die Abschnitte der Seite. Dieser Styleguide selbst folgt
dem Muster.

**complex-app-doku.tsx**

```tsx
import {
  ActionGroup,
  Badge,
  Button,
  Content,
  Flex,
  HeaderNavigation,
  Heading,
  Icon,
  IconMenu,
  IconSearch,
  Label,
  LayoutCard,
  Link,
  Modal,
  ModalTrigger,
  Navigation,
  NavigationGroup,
  Section,
  Text,
} from "@mittwald/flow-react-components";
import { IconContrastFilled } from "@tabler/icons-react";
import styles from "./complex-app-doku.module.css";

const lorem =
  "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum.";

export default () => (
  <Flex direction="column" className={styles.app}>
    <header className={styles.header}>
      <Flex
        align="center"
        wrap="wrap"
        gap="m"
        className={styles.headerContent}
      >
        <span
          className={styles.logo}
          role="img"
          aria-label="mittwald"
        />
        <HeaderNavigation
          aria-label="Hauptnavigation"
          className={styles.topnav}
        >
          <GlobalNavigationLinks />
          <SearchButton />
          <Button aria-label="Theme wechseln">
            <Icon>
              <IconContrastFilled />
            </Icon>
          </Button>
        </HeaderNavigation>
        <HeaderNavigation className={styles.mobileActions}>
          <SearchButton />
          <MobileMenu />
        </HeaderNavigation>
      </Flex>
    </header>

    <Flex
      direction="column"
      gap="l"
      grow
      className={styles.content}
    >
      <Flex
        gap="l"
        wrap="wrap"
        align="stretch"
        className={styles.body}
      >
        <LayoutCard className={styles.sidebar}>
          <ComponentNavigation />
        </LayoutCard>

        <LayoutCard
          elementType="main"
          className={styles.main}
        >
          <Section>
            <Heading level={1}>Button</Heading>
            <Text>{lorem}</Text>
            <Heading level={2}>Colors</Heading>
            <Text>{lorem}</Text>
            <Heading level={3}>Light und Dark</Heading>
            <Text>{lorem}</Text>
            <Heading level={2}>Sizes</Heading>
            <Text>{lorem}</Text>
            <Heading level={2}>Variants</Heading>
            <Text>{lorem}</Text>
          </Section>
        </LayoutCard>

        <LayoutCard className={styles.toc}>
          <Section>
            <Heading level={4}>Auf dieser Seite</Heading>
            <Navigation aria-label="Auf dieser Seite">
              <Link href="#" aria-current="page">
                Button
              </Link>
              <Link href="#">Colors</Link>
              <Link href="#">Light und Dark</Link>
              <Link href="#">Sizes</Link>
              <Link href="#">Variants</Link>
            </Navigation>
          </Section>
        </LayoutCard>
      </Flex>

      <Flex
        elementType="footer"
        justify="center"
        wrap="wrap"
        gap="l"
        className={styles.footer}
      >
        <Link href="#" target="_blank" color="dark">
          Datenschutz
        </Link>
        <Link href="#" target="_blank" color="dark">
          Impressum
        </Link>
      </Flex>
    </Flex>
  </Flex>
);

/*
 * Search keeps its place next to the burger: it is worth reaching without
 * opening the menu first.
 */
const SearchButton = () => (
  <Button
    variant="plain"
    color="secondary"
    aria-label="Suche"
  >
    <IconSearch />
  </Button>
);

/*
 * The section links, shared by the top bar and the off-canvas. Each renders
 * them through its own props context, so the same Links read as a header bar
 * in one and as a navigation list in the other.
 */
const GlobalNavigationLinks = () => (
  <>
    <Link href="#">Get Started</Link>
    <Link href="#">Foundations</Link>
    <Link href="#">Templates</Link>
    <Link href="#" aria-current="page">
      Components
    </Link>
  </>
);

const ComponentNavigation = () => (
  <Navigation aria-label="Komponenten">
    <NavigationGroup>
      <Label>Actions</Label>
      <Link href="#">Action</Link>
      <Link href="#">ActionGroup</Link>
      <Link href="#" aria-current="page">
        Button
      </Link>
      <Link href="#">ContextMenu</Link>
    </NavigationGroup>
    <NavigationGroup>
      <Label>Form Controls</Label>
      <Link href="#">Autocomplete</Link>
      <Link href="#">Checkbox</Link>
      <Link href="#">CheckboxButton</Link>
      <Link href="#">
        <Text>CodeEditor</Text>
        <Badge color="blue">Neu</Badge>
      </Link>
      <Link href="#">Combobox</Link>
      <Link href="#">DatePicker</Link>
      <Link href="#">Select</Link>
      <Link href="#">Switch</Link>
    </NavigationGroup>
  </Navigation>
);

/*
 * On a narrow screen the top bar has no room for the sections and the
 * component navigation has no column of its own, so both move in here.
 */
const MobileMenu = () => (
  <ModalTrigger>
    <Button aria-label="Menü öffnen">
      <IconMenu />
    </Button>
    <Modal offCanvas showCloseButton>
      <Heading>Menü</Heading>
      <Content>
        <Section>
          <ActionGroup>
            <Button variant="soft" color="secondary">
              <Icon>
                <IconContrastFilled />
              </Icon>
              <Text>Theme wechseln</Text>
            </Button>
          </ActionGroup>
        </Section>
        <Section>
          <Navigation aria-label="Hauptnavigation">
            <GlobalNavigationLinks />
          </Navigation>
        </Section>
        <Section>
          <Heading>Components</Heading>
          <ComponentNavigation />
        </Section>
      </Content>
    </Modal>
  </ModalTrigger>
)
```

**complex-app-doku.module.css**

```css
.app {
  /* Header and content share one maximum width, so their edges line up. */
  --page-width: 1800px;

  /* The header's tint is mixed from the gradient's first stop. */
  --header-ground: var(--neutral--color--200);

  /* The header's rendered height; the sticky sidebar starts just below it. */
  --header-height: 72px;

  /* Container-relative here; use 100dvh in a real full-page app. */
  min-height: 100%;
  background: var(--texture--grain), var(--color--background-gradient);
  background-blend-mode: overlay, normal;
}

/*
 * The header stays at the top while the page scrolls beneath it. Its tint is
 * translucent and blurred, so the navigation stays legible above the content.
 */
.header {
  position: sticky;
  top: 0;
  z-index: 1;
  padding-block: var(--size-px--m);
  background-color: color-mix(in srgb, var(--header-ground) 40%, transparent);
  backdrop-filter: blur(var(--blur));
}

.headerContent {
  max-width: var(--page-width);
  margin-inline: auto;
  padding-inline: var(--size-px--xl);
}

.content {
  width: 100%;
  max-width: var(--page-width);
  margin-inline: auto;
  padding-block: var(--size-px--s) var(--size-px--l);
  padding-inline: var(--size-px--xl);
}

/*
 * The wordmark rides on `currentColor` through a CSS mask, so it follows the
 * theme. Swap the masked SVG for your own logo.
 */
.logo {
  width: 8rem;
  max-width: 100%;
  aspect-ratio: 300 / 57;
  background: currentcolor;
  mask: url("./mittwald.svg") no-repeat center / contain;
  -webkit-mask: url("./mittwald.svg") no-repeat center / contain;
}

/* The global navigation is pushed to the far end of the top bar. */
.topnav {
  margin-inline-start: auto;
}

/* Search and the burger take that place once the navigation gives it up. */
.mobileActions {
  margin-inline-start: auto;
}

/* Navigation, content and table of contents sit in three columns. */
.body {
  flex: 1;
  min-height: 0;
}

/*
 * Both cards keep a fixed width; only the content column flexes. They stay below
 * the header while the page scrolls, and scroll their own links once they
 * outgrow the viewport.
 */
.sidebar,
.toc {
  flex: 0 0 17rem;
  position: sticky;
  top: calc(var(--header-height) + var(--size-px--s));
  align-self: flex-start;
  max-height: calc(
    100dvh - var(--header-height) - var(--size-px--s) - var(--size-px--l)
  );
  overflow: auto;
}

.main {
  flex: 1 1 20rem;
}

.footer {
  margin-block-start: auto;
}

/*
 * Below this width neither the section links nor the component navigation
 * fits, so both hand their links to the off-canvas behind the burger.
 */
@media (max-width: 768px) {
  .topnav,
  .sidebar {
    display: none;
  }

  .headerContent,
  .content {
    padding-inline: var(--size-px--m);
  }
}

@media (min-width: 769px) {
  .mobileActions {
    display: none;
  }
}

@media (prefers-contrast: more), (prefers-reduced-transparency) {
  .header {
    background-color: var(--header-ground);
    backdrop-filter: none;
  }
}

/* The dark gradient starts darker than the neutral token. */
[data-theme="dark"] .app {
  --header-ground: #121518;
}
```
