Widget frame
A titled box for a chart: menu, loading, error with retry, empty, and full size in a dialog.
import { WidgetFrame } from "@forgeron/ui";Revenue by region
Last 30 days
Updated 2 minutes ago
import { BarChart, WidgetFrame } from "@forgeron/ui";
export default function Default() {
return (
<div style={{ width: "100%", maxWidth: 440, height: 280 }}>
<WidgetFrame
title="Revenue by region"
subtitle="Last 30 days"
expandable
menu={[
{ id: "refresh", label: "Refresh" },
{ id: "export", label: "Export CSV" },
{ separator: true },
{ id: "remove", label: "Remove", danger: true },
]}
onMenuSelect={() => {}}
footer="Updated 2 minutes ago"
>
<BarChart
title="By region"
highlight="EMEA"
format={(n) => `€${n}k`}
data={[
{ label: "EMEA", value: 84 },
{ label: "Americas", value: 61 },
{ label: "APAC", value: 33 },
]}
/>
</WidgetFrame>
</div>
);
}Open tickets
By team
Loading
import { Segmented, WidgetFrame } from "@forgeron/ui";
import { useState } from "react";
type State = "ready" | "loading" | "error" | "empty";
export default function States() {
const [state, setState] = useState<State>("loading");
return (
<div
style={{ display: "flex", flexDirection: "column", gap: 12, width: "100%", maxWidth: 440 }}
>
<Segmented
label="State"
value={state}
onChange={(next) => setState(next as State)}
options={(["ready", "loading", "error", "empty"] as const).map((s) => ({
value: s,
label: s,
}))}
/>
<div style={{ height: 220 }}>
<WidgetFrame
title="Open tickets"
subtitle="By team"
loading={state === "loading"}
error={state === "error" ? "The ticket service did not answer." : undefined}
onRetry={() => setState("loading")}
empty={state === "empty"}
>
<p style={{ margin: 0 }}>37 open, 12 waiting for a customer.</p>
</WidgetFrame>
</div>
</div>
);
}API → Props
| Prop | Type | Default | Description |
|---|---|---|---|
title / subtitle | ReactNode | — | The heading and one line under it. |
menu / onMenuSelect | ActionMenuEntry[] / (id) => void | — | The rows of the … menu. |
expandable | boolean | — | A button opens the content in a dialog. expanded, defaultExpanded and onExpandedChange control it. |
loading | boolean | — | Skeletons in place of the content. |
error / onRetry | ReactNode / () => void | — | A message and a Retry button. error true gives the default message. |
empty / emptyText | boolean / ReactNode | — | Nothing to show for these filters. |
dragHandle | ReactNode | — | Before the title: the grip to drag by. |
actions / footer | ReactNode | — | Controls before the menu; a line under the content. |
headingLevel | 2 | 3 | 4 | 3 | Of the title. |
className | string | — | Extra classes. |