# Dashboard

> The dashboard frame. It has a white sidebar, a floating header card with the search, icon actions and the account, and the content area.

The dashboard frame is the second place where every Sosialoka product looks like one family (Alternative A). The menu, search and account sit in the same place in every product, so people who use more than one product never have to look for them.

## When to use

- Use it for every signed-in page of a web app.
- Put lists, details and forms inside it. Don't build a second header or a second sidebar.

### Do and don't

- **Do:** Keep header actions to icons, each named by a tooltip, with the avatar last.
- **Don't:** Don't fill the header with text buttons; they push the search aside and crowd small screens.

_Live preview of the React and Vue versions: https://design.sosialoka.tech/patterns/dashboard/_

## Anatomy

1. Sidebar with the product logo
2. Header card, floating over a blur
3. Search: opens the command palette
4. Language code dropdown, then icon actions with tooltips
5. Avatar and account menu, always last
6. Content on background

- **Sidebar:** 16rem on the white `sidebar` surface, with the product logo on top. The active item uses `sidebar-accent` and has `aria-current="page"`.
- **Header card:** one card, 56px tall (`h-14 rounded-lg border-border bg-card shadow-md`), that stays at the top while the page scrolls under a blur. It holds the search, the icon actions and the avatar, as the Cover Clearance header does.
- **Search:** fills the card's left side without a box of its own and opens the command palette. ⌘K or Ctrl+K opens it too.
- **Actions:** the language as an outlined pill with its code, then 36px ghost icon buttons in `muted-foreground`, each named by a tooltip.
- **Account:** the avatar, always last, opens the account menu.
- **Content:** the page, on `background`.

## Rules

- **One search:** the card and ⌘K open the same palette. The block listens for ⌘K once per page, so it never opens a second palette over a search card from [Command](https://design.sosialoka.tech/components/command/).
- **Menu:** use five to seven items with icons. Settings go last. A product with more pages follows [Navigation menu](https://design.sosialoka.tech/patterns/navigation-menu/).
- **Actions:** the language first, then at most three icon actions in this order: mode, help, notifications. Build the mode with `DashboardModeSelect` and the others with `DashboardIconButton`, whose `label` becomes its tooltip and name.
- **Mode:** `DashboardModeSelect`, a menu of Light, Dark and Auto. **Auto follows the device's setting and is where new users start.** While on Auto, the page switches along when the device does, with no reload. The icon shows the pick (sun, moon, or monitor for Auto) and the tooltip names it, such as "Mode: Auto". `useColorMode()` sets `data-theme` on `<html>` and remembers the pick; set the same mode in an inline `<head>` script so the page doesn't flash. Flutter: `ThemeMode.light`, `ThemeMode.dark` and `ThemeMode.system` (Auto).
- **Language:** `DashboardLanguageSelect`, as in Lokasign: an outlined dropdown trigger with the current code, "ID" or "EN", in mono and a chevron. It opens a menu of languages with the current one marked. It is a pill (`rounded-full`), the one pill in the header, and stays a menu so more languages can join.
- **Notifications:** `badge` shows the unread count; leave it out at zero. The bell opens the panel from [Notifications](https://design.sosialoka.tech/patterns/notifications/).
- **Account menu:** show the name and one detail line, then the actions. "Keluar" goes last as a destructive item.
- **Small screens:** below `md` the sidebar becomes a sheet that opens from the menu button.
- **Preview frames:** `collapsible="none"` keeps the sidebar in the page flow, such as inside a frame on a docs page.

## Props

| React | Vue | Flutter | Type | Default | Use |
| --- | --- | --- | --- | --- | --- |
| `nav` | `nav` | `ShadButton.ghost` list | pages, parents or sections | none | The menu. For sections, sub menus and counts, see [Navigation menu](https://design.sosialoka.tech/patterns/navigation-menu/). |
| `logo` | `#logo` slot | widget | element | none | The product logo at the top of the sidebar. |
| `account` | `account` | `ShadAvatar` | `{ name, initials, detail?, menu }` | none | The avatar and its menu. A menu item can set `onSelect` and `destructive`. |
| `actions` | `#actions` slot | `ShadButton.outline` and `ShadIconButton.ghost` in a `ShadTooltip` | elements | none | Actions between the search and the avatar: `DashboardLanguageSelect` (`value`, `options`, `onValueChange`, `label`; Vue `v-model`), `DashboardModeSelect` (`value`, `onValueChange`, `labels`; Vue `v-model`) with `useColorMode(storageKey?)`, then `DashboardIconButton` (`label`, `badge?`, the icon as its child). |
| `search` | `search` | `ShadInput` in a `ShadCard` | `{ groups: { heading, items }[] }` | none | What the palette lists. An item runs its `onSelect`. |
| `collapsible` | `collapsible` | none | `offcanvas`, `icon`, `none` | `offcanvas` | How the sidebar collapses. |
| `labels` | `labels` | `Text` | `{ search, empty, account, menu }` | English | Text for the search card, the palette and screen readers. The example passes Indonesian. |
| `children` | default slot | `Expanded` child | element | none | The page content. |

## Code

**React**
```tsx
import { useState } from "react"
import { BarChart3Icon, BellIcon, DiscIcon, FileTextIcon, HomeIcon, SettingsIcon } from "lucide-react"
import {
  DashboardIconButton,
  DashboardLanguageSelect,
  DashboardModeSelect,
  DashboardShell,
  useColorMode,
} from "@/components/blocks/dashboard-shell"
import { Card, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"

const nav = [
  { title: "Dasbor", href: "#", icon: HomeIcon, active: true },
  { title: "Rilis", href: "#rilis", icon: DiscIcon },
  { title: "Royalti", href: "#royalti", icon: BarChart3Icon },
  { title: "Dokumen", href: "#dokumen", icon: FileTextIcon },
  { title: "Pengaturan", href: "#pengaturan", icon: SettingsIcon },
]

const stats = [
  { label: "Rilis aktif", value: "24" },
  { label: "Streaming bulan ini", value: "182.430" },
  { label: "Royalti bulan ini", value: "Rp4.812.500,00" },
]

export default function DashboardShellDemo() {
  const [mode, setMode] = useColorMode()
  const [language, setLanguage] = useState("id")
  return (
    <DashboardShell
      nav={nav}
      actions={
        <>
          <DashboardLanguageSelect
            label="Bahasa"
            value={language}
            onValueChange={setLanguage}
            options={[
              { code: "id", label: "Bahasa Indonesia" },
              { code: "en", label: "English" },
            ]}
          />
          <DashboardModeSelect
            value={mode}
            onValueChange={setMode}
            labels={{ mode: "Mode", light: "Terang", dark: "Gelap", auto: "Auto" }}
          />
          <DashboardIconButton label="Notifikasi" badge={3}>
            <BellIcon />
          </DashboardIconButton>
        </>
      }
      labels={{ search: "Cari rilis, artis, atau dokumen", empty: "Tidak ada yang cocok.", account: "Akun {name}", menu: "Buka menu" }}
      logo={
        <span className="flex items-center gap-2 font-semibold">
          <span className="size-7 rounded-md bg-primary" />
          Produkmu
        </span>
      }
      account={{
        name: "Raka Pratama",
        initials: "RP",
        detail: "raka@contoh.id",
        menu: [{ label: "Profil" }, { label: "Pengaturan akun" }, { label: "Keluar", destructive: true }],
      }}
      search={{
        groups: [
          { heading: "Rilis", items: [{ label: "Senja di Kota" }, { label: "Kaset Pertama" }] },
          { heading: "Menu", items: nav.map((item) => ({ label: item.title })) },
        ],
      }}
    >
      <h1 className="text-2xl font-semibold">Dasbor</h1>
      <p className="mt-1 text-sm text-muted-foreground">Ringkasan katalogmu minggu ini.</p>
      <div className="mt-6 grid gap-4 sm:grid-cols-3">
        {stats.map((stat) => (
          <Card key={stat.label}>
            <CardHeader>
              <CardDescription>{stat.label}</CardDescription>
              <CardTitle className="text-2xl tabular-nums">{stat.value}</CardTitle>
            </CardHeader>
          </Card>
        ))}
      </div>
    </DashboardShell>
  )
}
```

**Vue**
```vue
<script setup lang="ts">
import { BarChart3, Bell, Disc, FileText, Home, Settings } from "@lucide/vue"
import { ref } from "vue"
import {
  DashboardIconButton,
  DashboardLanguageSelect,
  DashboardModeSelect,
  DashboardShell,
  useColorMode,
} from "@/components/blocks/dashboard-shell"
import { Card, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"

const nav = [
  { title: "Dasbor", href: "#", icon: Home, active: true },
  { title: "Rilis", href: "#rilis", icon: Disc },
  { title: "Royalti", href: "#royalti", icon: BarChart3 },
  { title: "Dokumen", href: "#dokumen", icon: FileText },
  { title: "Pengaturan", href: "#pengaturan", icon: Settings },
]

const stats = [
  { label: "Rilis aktif", value: "24" },
  { label: "Streaming bulan ini", value: "182.430" },
  { label: "Royalti bulan ini", value: "Rp4.812.500,00" },
]

const account = {
  name: "Raka Pratama",
  initials: "RP",
  detail: "raka@contoh.id",
  menu: [{ label: "Profil" }, { label: "Pengaturan akun" }, { label: "Keluar", destructive: true }],
}

const search = {
  groups: [
    { heading: "Rilis", items: [{ label: "Senja di Kota" }, { label: "Kaset Pertama" }] },
    { heading: "Menu", items: nav.map((item) => ({ label: item.title })) },
  ],
}
const mode = useColorMode()
const modeLabels = { mode: "Mode", light: "Terang", dark: "Gelap", auto: "Auto" }
const language = ref("id")
const languages = [
  { code: "id", label: "Bahasa Indonesia" },
  { code: "en", label: "English" },
]
const labels = { search: "Cari rilis, artis, atau dokumen", empty: "Tidak ada yang cocok.", account: "Akun {name}", menu: "Buka menu" }
</script>

<template>
  <DashboardShell :nav="nav" :account="account" :search="search" :labels="labels">
    <template #logo>
      <span class="flex items-center gap-2 font-semibold">
        <span class="size-7 rounded-md bg-primary" />
        Produkmu
      </span>
    </template>
    <template #actions>
      <DashboardLanguageSelect v-model="language" label="Bahasa" :options="languages" />
      <DashboardModeSelect v-model="mode" :labels="modeLabels" />
      <DashboardIconButton label="Notifikasi" :badge="3">
        <Bell />
      </DashboardIconButton>
    </template>

    <h1 class="text-2xl font-semibold">Dasbor</h1>
    <p class="mt-1 text-sm text-muted-foreground">Ringkasan katalogmu minggu ini.</p>
    <div class="mt-6 grid gap-4 sm:grid-cols-3">
      <Card v-for="stat in stats" :key="stat.label">
        <CardHeader>
          <CardDescription>{{ stat.label }}</CardDescription>
          <CardTitle class="text-2xl tabular-nums">{{ stat.value }}</CardTitle>
        </CardHeader>
      </Card>
    </div>
  </DashboardShell>
</template>
```

**Flutter**
```dart
// Flutter has no registry blocks: build the dashboard frame (Alt A) from widgets with the Sosialoka theme.
// A white sidebar, then the floating header card: the search, the language (code + chevron), the mode menu
// (Terang, Gelap, Auto = ThemeMode.system), notifications and the account avatar last. Every icon action has a
// tooltip that names it. Give the app's `themeMode` the picked mode and save it; new users start on Auto.
// On narrow screens, move the menu into a sheet opened from a menu button.
import 'package:flutter/material.dart' show ThemeMode;
import 'package:flutter/widgets.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import 'package:sosialoka_ui/sosialoka_ui.dart';

const _menu = ['Dasbor', 'Rilis', 'Royalti', 'Dokumen', 'Pengaturan'];
const _stats = [('Rilis aktif', '24'), ('Streaming bulan ini', '182.430'), ('Royalti bulan ini', 'Rp4.812.500,00')];

const _modes = {
  ThemeMode.light: ('Terang', LucideIcons.sun),
  ThemeMode.dark: ('Gelap', LucideIcons.moon),
  ThemeMode.system: ('Auto', LucideIcons.monitor),
};

class DashboardShellDemo extends StatefulWidget {
  const DashboardShellDemo({super.key, this.height = 560});

  final double height;

  @override
  State<DashboardShellDemo> createState() => _DashboardShellDemoState();
}

class _DashboardShellDemoState extends State<DashboardShellDemo> {
  final _modeMenu = ShadContextMenuController();
  // In the app this comes from storage and goes to MaterialApp/ShadApp `themeMode`.
  var _mode = ThemeMode.system;

  @override
  void dispose() {
    _modeMenu.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    final theme = ShadTheme.of(context);
    final c = context.sosialoka;
    return SizedBox(
      height: widget.height,
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.stretch,
        children: [
          Container(
            width: 256,
            padding: const EdgeInsets.all(8),
            decoration: BoxDecoration(
              color: theme.colorScheme.card,
              border: Border(right: BorderSide(color: theme.colorScheme.border)),
            ),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.stretch,
              children: [
                for (final item in _menu)
                  ShadButton.ghost(
                    mainAxisAlignment: MainAxisAlignment.start,
                    backgroundColor: item == 'Dasbor' ? c.primarySoft : null,
                    foregroundColor: item == 'Dasbor' ? c.primaryText : theme.colorScheme.foreground,
                    onPressed: () {},
                    child: Text(item),
                  ),
              ],
            ),
          ),
          Expanded(
            child: ColoredBox(
              color: theme.colorScheme.background,
              child: Padding(
                padding: const EdgeInsets.all(24),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    ShadCard(
                      padding: const EdgeInsets.symmetric(horizontal: 8),
                      child: SizedBox(
                        height: 54,
                        child: Row(
                          children: [
                            Expanded(
                              child: ShadInput(
                                placeholder: const Text('Cari rilis, artis, atau dokumen'),
                                leading: const Icon(LucideIcons.search, size: 16),
                                decoration: const ShadDecoration(border: ShadBorder.none, focusedBorder: ShadBorder.none),
                                readOnly: true,
                                onPressed: () {},
                              ),
                            ),
                            // Language first, as in Lokasign: the current code with a chevron, opening a menu of languages.
                            ShadButton.outline(
                              height: 36,
                              decoration: const ShadDecoration(border: ShadBorder(radius: BorderRadius.all(Radius.circular(18)))),
                              padding: const EdgeInsets.only(left: 12, right: 8),
                              onPressed: () {},
                              trailing: Icon(LucideIcons.chevronDown, size: 14, color: theme.colorScheme.mutedForeground),
                              child: Text('ID', style: TextStyle(fontFamily: theme.textTheme.family, fontFeatures: const [FontFeature.tabularFigures()], fontSize: 12, fontWeight: FontWeight.w500)),
                            ),
                            const SizedBox(width: 4),
                            ShadContextMenu(
                              controller: _modeMenu,
                              items: [
                                for (final MapEntry(key: mode, value: (label, icon)) in _modes.entries)
                                  ShadContextMenuItem(
                                    leading: Icon(icon, size: 16),
                                    trailing: mode == _mode ? const Icon(LucideIcons.check, size: 16) : null,
                                    onPressed: () {
                                      setState(() => _mode = mode);
                                      _modeMenu.hide();
                                    },
                                    child: Text(label),
                                  ),
                              ],
                              child: ShadTooltip(
                                builder: (context) => Text('Mode: ${_modes[_mode]!.$1}'),
                                child: ShadIconButton.ghost(icon: Icon(_modes[_mode]!.$2, size: 18), onPressed: _modeMenu.toggle),
                              ),
                            ),
                            ShadTooltip(
                              builder: (context) => const Text('Notifikasi'),
                              child: Stack(
                                clipBehavior: Clip.none,
                                children: [
                                  ShadIconButton.ghost(icon: const Icon(LucideIcons.bell, size: 18), onPressed: () {}),
                                  Positioned(
                                    top: 4,
                                    right: 4,
                                    child: Container(
                                      constraints: const BoxConstraints(minWidth: 16),
                                      height: 16,
                                      alignment: Alignment.center,
                                      decoration: BoxDecoration(color: theme.colorScheme.destructive, borderRadius: BorderRadius.circular(8)),
                                      child: Text('3', style: TextStyle(fontSize: 10, fontWeight: FontWeight.w600, color: theme.colorScheme.destructiveForeground)),
                                    ),
                                  ),
                                ],
                              ),
                            ),
                            const SizedBox(width: 4),
                            const ShadAvatar('', placeholder: Text('RP'), size: Size.square(36)),
                          ],
                        ),
                      ),
                    ),
                    const SizedBox(height: 24),
                    Text('Dasbor', style: theme.textTheme.h3),
                    const SizedBox(height: 16),
                    Row(
                      children: [
                        for (final (label, value) in _stats) ...[
                          Expanded(
                            child: ShadCard(
                              description: Text(label),
                              title: Text(value, style: theme.textTheme.h4),
                            ),
                          ),
                          if (label != _stats.last.$1) const SizedBox(width: 16),
                        ],
                      ],
                    ),
                  ],
                ),
              ),
            ),
          ),
        ],
      ),
    );
  }
}
```

## Install

**React**
```bash
npx shadcn@latest add https://design.sosialoka.tech/r/react/dashboard-shell.json
```

**Vue**
```bash
npx shadcn-vue@latest add https://design.sosialoka.tech/r/vue/dashboard-shell.json
```

The block lands in `components/blocks/` and installs the Sosialoka Sidebar, Command, Dropdown Menu and Avatar with it.

## Flutter

Flutter has no blocks. The Flutter code builds the same frame from widgets: a sidebar column, the header card with the search, the icon actions and the avatar, and the content. On phones, move the menu into a sheet.

## Accessibility

- The active menu item has `aria-current="page"`.
- The search is a button, and its name is the search text. The ⌘K hint is shown beside it.
- Each icon action is named by its `label`, and a count is read with it, such as "Notifikasi (3)".
- The mode button is read with the current pick, such as "Mode: Auto", and the menu marks the pick as checked.
- The avatar button is named "Akun" followed by the account name.
