Skip to content

List

Download .md

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.

  • Use it for any collection people browse, search and act on.
  • For one record, use a Detail page. For an empty collection, show the empty state instead of an empty table.
  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) 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.
  • 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.
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>
)
}

Button, Card, Input, Toggle Group, Table, Badge and Dropdown Menu.

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.