DDBS UI
dashboard

Dashboard Popover

A trigger with a dismissable panel for menus and notifications, with start or end alignment.

npx shadcn@latest add https://ui.develop-better-solutions.com/r/dash-popover.json
Fullscreen

Usage

dash-popover-example.tsx
"use client";

import { DashPopover } from "@dbs/ui";
import { DashScope } from "./_store";

const trigger =
  "flex h-10 items-center rounded-full border border-[var(--dash-line)] bg-[var(--dash-panel)] px-4 text-sm hover:bg-[var(--dash-hover)]";
const panel =
  "absolute top-full z-20 mt-2 rounded-xl border border-[var(--dash-line)] bg-[var(--dash-panel)] p-2 text-sm shadow-xl";

export default function DashPopoverExample() {
  return (
    <div className="w-full max-w-md">
      <DashScope minHeight={260}>
        <div className="flex justify-between">
          <div className="relative">
            <DashPopover label="Notifications" trigger="Notifications" triggerClassName={trigger} panelBaseClassName={panel} panelClassName="w-64">
              {(close) => (
                <ul>
                  {["Lab results are ready", "Dr. Alami moved your visit", "Refill approved"].map((n) => (
                    <li key={n}>
                      <button type="button" onClick={close} className="w-full rounded-lg px-3 py-2 text-left hover:bg-[var(--dash-hover)]">
                        {n}
                      </button>
                    </li>
                  ))}
                </ul>
              )}
            </DashPopover>
          </div>
          <div className="relative">
            <DashPopover label="Account" align="end" trigger="Account" triggerClassName={trigger} panelBaseClassName={panel} panelClassName="w-44">
              {(close) => (
                <button type="button" onClick={close} className="w-full rounded-lg px-3 py-2 text-left hover:bg-[var(--dash-hover)]">
                  Sign out
                </button>
              )}
            </DashPopover>
          </div>
        </div>
      </DashScope>
    </div>
  );
}