Skip to content
Vertical Jump Designs-uiFront-End Studio
Get Pro

v3.9 is out.

Templates

Dashboard

Free

An app frame with a sidebar, key numbers, a recent orders table, team activity and a goal.

Open full screen

The download follows the framework picked above the code. Unzip it and run npm install, then npm run dev.

Live preview

Preview width

Code

tsx
import { useState, type MouseEvent } from "react";
import {
  Avatar,
  Badge,
  Box,
  Button,
  Card,
  Flex,
  Grid,
  Heading,
  HomeIcon,
  IconButton,
  List,
  MailIcon,
  MenuIcon,
  Progress,
  SettingsIcon,
  Sidebar,
  Stat,
  StatGroup,
  Table,
  Text,
  UsersIcon,
  useMediaQuery,
} from "@vjdesigns/vjdesigns-ui";

const orders = [
  { id: "#1042", customer: "Northwind", total: "$1,280.00", status: "Paid" },
  { id: "#1041", customer: "Contoso", total: "$640.00", status: "Pending" },
  { id: "#1040", customer: "Fabrikam", total: "$2,115.50", status: "Paid" },
  { id: "#1039", customer: "Tailspin", total: "$89.00", status: "Refunded" },
];

const statusTone = { Paid: "success", Pending: "warning", Refunded: "neutral" } as const;

const activity = [
  { name: "Priya Patel", text: "Invited 2 people to Marketing", time: "5 min ago" },
  { name: "Sam Rivera", text: "Closed the Q3 report", time: "1 hour ago" },
  { name: "Jordan Lee", text: "Updated billing details", time: "Yesterday" },
];

/** An app frame with a collapsible sidebar, key numbers, a recent orders table, team activity and a goal. Swap the sample data for your own. */
export function DashboardPage() {
  const [page, setPage] = useState("overview");
  // Below 768px the sidebar becomes a drawer, opened from the menu button.
  const small = useMediaQuery("(max-width: 767px)");
  const [navOpen, setNavOpen] = useState(false);
  const item = (id: string) => ({
    href: `#${id}`,
    active: page === id,
    onClick: (event: MouseEvent<HTMLElement>) => {
      event.preventDefault();
      setPage(id);
    },
  });

  return (
    <Box display="flex" minHeight="100vh" surface="sunken">
      <Sidebar
        aria-label="App"
        mode={small ? "overlay" : "static"}
        open={navOpen}
        onOpenChange={setNavOpen}
        closeOnNavigate
      >
        <Sidebar.Header>
          <Text weight="black">Acme</Text>
          <Sidebar.Toggle />
        </Sidebar.Header>
        <Sidebar.Body>
          <Sidebar.Section>
            <Sidebar.Item {...item("overview")} icon={<HomeIcon />}>
              Overview
            </Sidebar.Item>
            <Sidebar.Item {...item("inbox")} icon={<MailIcon />} badge={4} badgeLabel="4 unread">
              Inbox
            </Sidebar.Item>
            <Sidebar.Item {...item("customers")} icon={<UsersIcon />}>
              Customers
            </Sidebar.Item>
            <Sidebar.Item {...item("settings")} icon={<SettingsIcon />}>
              Settings
            </Sidebar.Item>
          </Sidebar.Section>
        </Sidebar.Body>
      </Sidebar>

      <Box as="main" p={6} style={{ flex: 1, minWidth: 0 }}>
        <Flex align="center" justify="between" gap={4} wrap="wrap" style={{ marginBottom: "1.5rem" }}>
          <Flex align="center" gap={3}>
            {small && (
              <IconButton aria-label="Open navigation" variant="ghost" tone="neutral" onClick={() => setNavOpen(true)}>
                <MenuIcon />
              </IconButton>
            )}
            <Box>
              <Heading level={1} size="3xl">
                Overview
              </Heading>
              <Text tone="muted">Here's how this month is going.</Text>
            </Box>
          </Flex>
          <Button tone="primary">New order</Button>
        </Flex>

        <StatGroup columns={{ base: 1, sm: 2, lg: 4 }} variant="card">
          <Stat
            label="Revenue"
            value={48200}
            format={{ style: "currency", currency: "USD", maximumFractionDigits: 0 }}
            change={0.124}
            comparisonLabel="vs last month"
          />
          <Stat label="Orders" value={1284} change={0.061} comparisonLabel="vs last month" />
          <Stat label="New customers" value={312} change={-0.018} comparisonLabel="vs last month" />
          <Stat
            label="Refund rate"
            value={0.012}
            format={{ style: "percent", maximumFractionDigits: 1 }}
            change={-0.002}
            positiveIsGood={false}
            comparisonLabel="vs last month"
          />
        </StatGroup>

        <Grid columns={{ base: 1, lg: 3 }} gap={6} style={{ marginTop: "1.5rem" }}>
          <Grid.Item colSpan={{ base: 1, lg: 2 }}>
            <Card padding="lg">
              <Card.Header title="Recent orders" />
              <Card.Body>
                <Table hoverable aria-label="Recent orders">
                  <Table.Head>
                    <Table.Row>
                      <Table.HeaderCell>Order</Table.HeaderCell>
                      <Table.HeaderCell>Customer</Table.HeaderCell>
                      <Table.HeaderCell numeric>Total</Table.HeaderCell>
                      <Table.HeaderCell>Status</Table.HeaderCell>
                    </Table.Row>
                  </Table.Head>
                  <Table.Body>
                    {orders.map((order) => (
                      <Table.Row key={order.id}>
                        <Table.HeaderCell>{order.id}</Table.HeaderCell>
                        <Table.Cell>{order.customer}</Table.Cell>
                        <Table.Cell numeric>{order.total}</Table.Cell>
                        <Table.Cell>
                          <Badge tone={statusTone[order.status as keyof typeof statusTone]} variant="soft">
                            {order.status}
                          </Badge>
                        </Table.Cell>
                      </Table.Row>
                    ))}
                  </Table.Body>
                </Table>
              </Card.Body>
            </Card>
          </Grid.Item>

          <Flex direction="column" gap={6}>
            <Card padding="lg">
              <Card.Header title="Team activity" />
              <Card.Body>
                <List variant="divided">
                  {activity.map((entry) => (
                    <List.Item
                      key={entry.text}
                      start={<Avatar name={entry.name} size="sm" colorFromName />}
                      title={entry.name}
                      description={entry.text}
                      meta={entry.time}
                    />
                  ))}
                </List>
              </Card.Body>
            </Card>
            <Card padding="lg">
              <Card.Header title="Monthly goal" />
              <Card.Body>
                <Progress label="Revenue goal: $60,000" value={80} showValue tone="primary" />
              </Card.Body>
            </Card>
          </Flex>
        </Grid>
      </Box>
    </Box>
  );
}