# List

> A list page. It has stats, search and filters, a table with row actions, and pagination.

Most screens in a Sosialoka product start as a list: releases, contracts, payouts, artists. Every list page has the same parts in the same order, so people know where to look in any product.

## When to use

- Use it for any collection people browse, search and act on.
- For one record, use a [Detail](https://design.sosialoka.tech/patterns/detail/) page. For an empty collection, show the [empty state](https://design.sosialoka.tech/patterns/states/) instead of an empty table.

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

## Anatomy

1. **Header:** the page title and one primary action, such as "Rilis baru".
2. **Stats:** up to four cards with a label and a number.
3. **Filters:** search on top, then the status chips ([Toggle Group](https://design.sosialoka.tech/components/toggle-group/)) with the count of each status. They sit above the table they filter.
4. **Table:** inside a card, with a status badge column and one row action button at the end.
5. **Pagination:** under the table, inside the same card.

## Rules

- **One primary action** in the header. Every other action lives in the row menu.
- **Row menu:** name the button after the row ("Aksi untuk Senja di Kota"). Put the destructive item last, after a separator.
- **Status:** use the status badges (`success`, `warning`, `info`, `destructive`), never the brand color.
- **Numbers:** right-align them only in money columns. Use `tabular-nums` and show Rupiah with two decimals.
- **Status chips** always have one status on: "Semua" by default, and a click on the active chip keeps it on.
- **Filters** keep their values in the URL, so a shared link opens the same view.
- **On phones,** turn the table into an accordion: see [Responsive table](https://design.sosialoka.tech/patterns/responsive-table/).

## Code

**React**
```tsx
import { useState, type MouseEvent } from "react"
import { MoreHorizontalIcon, PlusIcon, SearchIcon } from "lucide-react"
import { Badge } from "@/components/ui/badge"
import { Button } from "@/components/ui/button"
import { Card, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
import {
  DropdownMenu,
  DropdownMenuContent,
  DropdownMenuItem,
  DropdownMenuSeparator,
  DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu"
import { Input } from "@/components/ui/input"
import {
  Pagination,
  PaginationContent,
  PaginationItem,
  PaginationLink,
  PaginationNext,
  PaginationPrevious,
} from "@/components/ui/pagination"
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"

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

const statuses = [
  { label: "Semua", value: "semua", count: 24 },
  { label: "Terbit", value: "terbit", count: 12 },
  { label: "Menunggu", value: "menunggu", count: 8 },
  { label: "Ditolak", value: "ditolak", count: 4 },
]

const releases = [
  { title: "Senja di Kota", artist: "Raka Pratama", status: "success", label: "Terbit", date: "14 Nov 2026" },
  { title: "Kaset Pertama", artist: "Nadia Senja", status: "warning", label: "Menunggu", date: "21 Nov 2026" },
  { title: "Pulang Sore", artist: "Bima Laras", status: "info", label: "Dijadwalkan", date: "28 Nov 2026" },
  { title: "Lampu Kota", artist: "Sinta Maharani", status: "destructive", label: "Ditolak", date: "2 Nov 2026" },
] as const

/** Two pages of four rows; the demo shows the first page's rows on both. */
const pages = [1, 2]

/** A list page: title and one main action, stats, filters above the table, row actions in a menu, pages below. */
export default function ListPageDemo() {
  const [page, setPage] = useState(1)
  const [status, setStatus] = useState("semua")
  const goTo = (next: number) => (event: MouseEvent) => {
    event.preventDefault()
    setPage(next)
  }
  return (
    <div className="min-h-svh bg-background p-6 text-foreground">
      <div className="mx-auto grid max-w-5xl gap-6">
        <div className="flex items-center justify-between gap-4">
          <h1 className="text-2xl font-semibold">Rilis</h1>
          <Button>
            <PlusIcon />
            Rilis baru
          </Button>
        </div>

        <div className="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>

        <div className="flex flex-wrap items-center gap-3">
          <div className="relative w-full max-w-xs">
            <SearchIcon className="pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-muted-foreground" />
            <Input type="search" aria-label="Cari rilis" placeholder="Cari judul atau artis" className="pl-8" />
          </div>
        </div>

        <ToggleGroup
          variant="outline"
          spacing={2}
          aria-label="Filter status"
          value={[status]}
          // A status filter always has one value: clicking the active chip keeps it on.
          onValueChange={(value) => value.length > 0 && setStatus(value[value.length - 1])}
        >
          {statuses.map((s) => (
            <ToggleGroupItem key={s.value} value={s.value}>
              {s.label}
              <span className="tabular-nums text-muted-foreground">{s.count}</span>
            </ToggleGroupItem>
          ))}
        </ToggleGroup>

        <div className="rounded-xl border border-border bg-card">
          <Table>
            <TableHeader>
              <TableRow>
                <TableHead>Judul</TableHead>
                <TableHead>Artis</TableHead>
                <TableHead>Status</TableHead>
                <TableHead>Tanggal rilis</TableHead>
                <TableHead className="w-12">
                  <span className="sr-only">Aksi</span>
                </TableHead>
              </TableRow>
            </TableHeader>
            <TableBody>
              {releases.map((r) => (
                <TableRow key={r.title}>
                  <TableCell className="font-medium">{r.title}</TableCell>
                  <TableCell className="text-muted-foreground">{r.artist}</TableCell>
                  <TableCell>
                    <Badge variant={r.status}>{r.label}</Badge>
                  </TableCell>
                  <TableCell className="tabular-nums">{r.date}</TableCell>
                  <TableCell>
                    <DropdownMenu>
                      <DropdownMenuTrigger
                        render={<Button variant="ghost" size="icon-sm" aria-label={`Aksi untuk ${r.title}`} />}
                      >
                        <MoreHorizontalIcon />
                      </DropdownMenuTrigger>
                      <DropdownMenuContent align="end">
                        <DropdownMenuItem>Lihat</DropdownMenuItem>
                        <DropdownMenuItem>Ubah</DropdownMenuItem>
                        <DropdownMenuSeparator />
                        <DropdownMenuItem variant="destructive">Hapus</DropdownMenuItem>
                      </DropdownMenuContent>
                    </DropdownMenu>
                  </TableCell>
                </TableRow>
              ))}
            </TableBody>
          </Table>
          <Pagination className="border-t border-border py-2">
            <PaginationContent>
              <PaginationItem>
                <PaginationPrevious href="#" disabled={page === 1} onClick={goTo(page - 1)} />
              </PaginationItem>
              {pages.map((p) => (
                <PaginationItem key={p}>
                  <PaginationLink href="#" isActive={p === page} onClick={goTo(p)}>
                    {p}
                  </PaginationLink>
                </PaginationItem>
              ))}
              <PaginationItem>
                <PaginationNext href="#" disabled={page === pages.length} onClick={goTo(page + 1)} />
              </PaginationItem>
            </PaginationContent>
          </Pagination>
        </div>
      </div>
    </div>
  )
}
```

**Vue**
```vue
<script setup lang="ts">
import { ref } from "vue"
import { MoreHorizontal, Plus, Search } from "@lucide/vue"
import { Badge } from "@/components/ui/badge"
import { Button } from "@/components/ui/button"
import { Card, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
import {
  DropdownMenu,
  DropdownMenuContent,
  DropdownMenuItem,
  DropdownMenuSeparator,
  DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu"
import { Input } from "@/components/ui/input"
import {
  Pagination,
  PaginationContent,
  PaginationItem,
  PaginationNext,
  PaginationPrevious,
} from "@/components/ui/pagination"
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table"

/** A list page: title and one main action, stats, filters above the table, row actions in a menu, pages below. */
const stats = [
  { label: "Rilis aktif", value: "24" },
  { label: "Menunggu dikirim", value: "3" },
  { label: "Royalti bulan ini", value: "Rp4.812.500,00" },
]

const statuses = [
  { label: "Semua", value: "semua", count: 24 },
  { label: "Terbit", value: "terbit", count: 12 },
  { label: "Menunggu", value: "menunggu", count: 8 },
  { label: "Ditolak", value: "ditolak", count: 4 },
]

const releases = [
  { title: "Senja di Kota", artist: "Raka Pratama", status: "success", label: "Terbit", date: "14 Nov 2026" },
  { title: "Kaset Pertama", artist: "Nadia Senja", status: "warning", label: "Menunggu", date: "21 Nov 2026" },
  { title: "Pulang Sore", artist: "Bima Laras", status: "info", label: "Dijadwalkan", date: "28 Nov 2026" },
  { title: "Lampu Kota", artist: "Sinta Maharani", status: "destructive", label: "Ditolak", date: "2 Nov 2026" },
] as const
const status = ref("semua")
// A status filter always has one value: clicking the active chip keeps it on.
function pickStatus(value: unknown) {
  if (typeof value === "string" && value) status.value = value
}
</script>

<template>
  <div class="min-h-svh bg-background p-6 text-foreground">
    <div class="mx-auto grid max-w-5xl gap-6">
      <div class="flex items-center justify-between gap-4">
        <h1 class="text-2xl font-semibold">Rilis</h1>
        <Button><Plus />Rilis baru</Button>
      </div>

      <div class="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>

      <div class="flex flex-wrap items-center gap-3">
        <div class="relative w-full max-w-xs">
          <Search class="pointer-events-none absolute top-1/2 left-2.5 size-4 -translate-y-1/2 text-muted-foreground" />
          <Input type="search" aria-label="Cari rilis" placeholder="Cari judul atau artis" class="pl-8" />
        </div>
      </div>

      <ToggleGroup type="single" variant="outline" :spacing="2" aria-label="Filter status" :model-value="status" @update:model-value="pickStatus">
        <ToggleGroupItem v-for="s in statuses" :key="s.value" :value="s.value">
          {{ s.label }}
          <span class="tabular-nums text-muted-foreground">{{ s.count }}</span>
        </ToggleGroupItem>
      </ToggleGroup>

      <div class="rounded-xl border border-border bg-card">
        <Table>
          <TableHeader>
            <TableRow>
              <TableHead>Judul</TableHead>
              <TableHead>Artis</TableHead>
              <TableHead>Status</TableHead>
              <TableHead>Tanggal rilis</TableHead>
              <TableHead class="w-12"><span class="sr-only">Aksi</span></TableHead>
            </TableRow>
          </TableHeader>
          <TableBody>
            <TableRow v-for="r in releases" :key="r.title">
              <TableCell class="font-medium">{{ r.title }}</TableCell>
              <TableCell class="text-muted-foreground">{{ r.artist }}</TableCell>
              <TableCell><Badge :variant="r.status">{{ r.label }}</Badge></TableCell>
              <TableCell class="tabular-nums">{{ r.date }}</TableCell>
              <TableCell>
                <DropdownMenu>
                  <DropdownMenuTrigger as-child>
                    <Button variant="ghost" size="icon-sm" :aria-label="`Aksi untuk ${r.title}`"><MoreHorizontal /></Button>
                  </DropdownMenuTrigger>
                  <DropdownMenuContent align="end">
                    <DropdownMenuItem>Lihat</DropdownMenuItem>
                    <DropdownMenuItem>Ubah</DropdownMenuItem>
                    <DropdownMenuSeparator />
                    <DropdownMenuItem variant="destructive">Hapus</DropdownMenuItem>
                  </DropdownMenuContent>
                </DropdownMenu>
              </TableCell>
            </TableRow>
          </TableBody>
        </Table>
        <Pagination v-slot="{ page }" :items-per-page="4" :total="8" :default-page="1" class="border-t border-border py-2">
          <PaginationContent v-slot="{ items }">
            <PaginationPrevious />
            <template v-for="(item, index) in items" :key="index">
              <PaginationItem v-if="item.type === 'page'" :value="item.value" :is-active="item.value === page">
                {{ item.value }}
              </PaginationItem>
            </template>
            <PaginationNext />
          </PaginationContent>
        </Pagination>
      </div>
    </div>
  </div>
</template>
```

**Flutter**
```dart
// A list page: title and one main action, stats, filters above the table, row actions in a menu, pages below.
import 'package:flutter/widgets.dart';
import 'package:shadcn_ui/shadcn_ui.dart';
import 'package:sosialoka_ui/sosialoka_ui.dart';

const _stats = [('Rilis aktif', '24'), ('Menunggu dikirim', '3'), ('Royalti bulan ini', 'Rp4.812.500,00')];
const _releases = [
  (title: 'Senja di Kota', artist: 'Raka Pratama', status: 'Terbit', date: '14 Nov 2026'),
  (title: 'Kaset Pertama', artist: 'Nadia Senja', status: 'Menunggu', date: '21 Nov 2026'),
  (title: 'Pulang Sore', artist: 'Bima Laras', status: 'Dijadwalkan', date: '28 Nov 2026'),
];

class ListPageDemo extends StatelessWidget {
  const ListPageDemo({super.key});

  @override
  Widget build(BuildContext context) {
    final theme = ShadTheme.of(context);
    return ConstrainedBox(
      constraints: const BoxConstraints(maxWidth: 880),
      child: Column(
        mainAxisSize: MainAxisSize.min,
        crossAxisAlignment: CrossAxisAlignment.stretch,
        children: [
          Row(
            children: [
              Expanded(child: Text('Rilis', style: theme.textTheme.h3)),
              ShadButton(
                leading: const Icon(LucideIcons.plus, size: 16),
                onPressed: () {},
                child: const Text('Rilis baru'),
              ),
            ],
          ),
          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),
              ],
            ],
          ),
          const SizedBox(height: 16),
          const SizedBox(
            width: 320,
            child: ShadInput(
              placeholder: Text('Cari judul atau artis'),
              leading: Icon(LucideIcons.search, size: 16),
            ),
          ),
          const SizedBox(height: 12),
          // A status filter always has one value: allowDeselection keeps the active chip on.
          ShadToggleGroup<String>(
            initialValue: 'semua',
            allowDeselection: false,
            variant: ShadToggleVariant.outline,
            spacing: 8,
            items: [
              for (final (value, label, count) in const [('semua', 'Semua', 24), ('terbit', 'Terbit', 12), ('menunggu', 'Menunggu', 8), ('ditolak', 'Ditolak', 4)])
                ShadToggleGroupItem(
                  value: value,
                  child: Row(
                    mainAxisSize: MainAxisSize.min,
                    spacing: 6,
                    children: [Text(label), Text('$count', style: theme.textTheme.muted)],
                  ),
                ),
            ],
          ),
          const SizedBox(height: 16),
          ShadCard(
            padding: EdgeInsets.zero,
            child: SizedBox(
              height: 200,
              child: ShadTable.list(
                columnSpanExtent: (index) => switch (index) {
                  0 => const FixedTableSpanExtent(220),
                  1 => const FixedTableSpanExtent(180),
                  2 => const FixedTableSpanExtent(150),
                  3 => const FixedTableSpanExtent(150),
                  _ => const RemainingTableSpanExtent(),
                },
                header: const [
                  ShadTableCell.header(child: Text('Judul')),
                  ShadTableCell.header(child: Text('Artis')),
                  ShadTableCell.header(child: Text('Status')),
                  ShadTableCell.header(child: Text('Tanggal rilis')),
                  ShadTableCell.header(child: SizedBox.shrink()),
                ],
                children: _releases.map(
                  (r) => [
                    ShadTableCell(child: Text(r.title, style: const TextStyle(fontWeight: FontWeight.w500))),
                    ShadTableCell(child: Text(r.artist)),
                    ShadTableCell(child: ShadBadge.outline(child: Text(r.status))),
                    ShadTableCell(child: Text(r.date)),
                    ShadTableCell(child: _RowActions(title: r.title)),
                  ],
                ),
              ),
            ),
          ),
          const SizedBox(height: 8),
          Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              ShadButton.ghost(onPressed: () {}, child: const Text('Sebelumnya')),
              ShadButton.outline(onPressed: () {}, child: const Text('1')),
              ShadButton.ghost(onPressed: () {}, child: const Text('2')),
              ShadButton.ghost(onPressed: () {}, child: const Text('Berikutnya')),
            ],
          ),
        ],
      ),
    );
  }
}

/// The row's actions behind one button, with the destructive one last.
class _RowActions extends StatefulWidget {
  const _RowActions({required this.title});

  final String title;

  @override
  State<_RowActions> createState() => _RowActionsState();
}

class _RowActionsState extends State<_RowActions> {
  final controller = ShadContextMenuController();

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

  @override
  Widget build(BuildContext context) {
    return ShadContextMenu(
      controller: controller,
      items: [
        const ShadContextMenuItem(child: Text('Lihat')),
        const ShadContextMenuItem(child: Text('Ubah')),
        const ShadSeparator.horizontal(margin: EdgeInsets.symmetric(vertical: 4)),
        ShadContextMenuItem(child: Text('Hapus', style: TextStyle(color: context.sosialoka.destructive))),
      ],
      child: Semantics(
        label: 'Aksi untuk ${widget.title}',
        child: ShadIconButton.ghost(icon: const Icon(LucideIcons.ellipsis), onPressed: controller.toggle),
      ),
    );
  }
}
```

## Built from

[Button](https://design.sosialoka.tech/components/button/), [Card](https://design.sosialoka.tech/components/card/), [Input](https://design.sosialoka.tech/components/input/), [Toggle Group](https://design.sosialoka.tech/components/toggle-group/), [Table](https://design.sosialoka.tech/components/table/), [Badge](https://design.sosialoka.tech/components/badge/) and [Dropdown Menu](https://design.sosialoka.tech/components/dropdown-menu/).

## Flutter

`ShadTable.list` holds the rows. shadcn_ui has no pagination widget, so put outline and ghost buttons under the table. Open the row actions from a `ShadContextMenu` and give the button a semantic label.
