adding-dashboard-v2-panel-types
Skill733 starsChanged 5 days agoMITView on GitHub
Guides adding or changing a panel type in dashboards v2 (`products/dashboards_v2/frontend/panels/`): the PanelSpec, definePanel, config schema, tile slots (Component, Loading, HeaderExtra, Footer), menuActions, allowedCustomizations and lazy loading, with the markdown type as the worked example. Use when creating a new kind of tile content for a dashboards v2 host, changing a panel type's config, or reviewing a diff under `frontend/panels/`. Not for v1 dashboard widgets (`manage-dashboard-widgets`).
1 other project uses a version of this.
Adopted by
Most recently taken up by
- PostHog/posthogword for word, first seen Nov 29, 2026
Other versions1 project uses a version of this.
Word for word · 1
- PostHog/posthog★ 41k100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository131 other files it gives its agents.
- AGENTS.mdAGENTS.md
- common/AGENTS.mdAGENTS.md
- hog/AGENTS.mdAGENTS.md
- proto/AGENTS.mdAGENTS.md
- rust/AGENTS.mdAGENTS.md
- .cursor/rules/django-python.mdcCursor rule
- .cursor/rules/react-typescript.mdcCursor rule
- .cursor/rules/rust.mdcCursor rule
- adding-activity-loggingSkill
- adding-api-scopesSkill
- adding-dashboard-v2-custom-contentSkill
- adding-inbound-webhooksSkill
- adding-inbox-sourcesSkill
- adding-ingestion-warningsSkill
- adding-mcp-store-serversSkill
- adding-personhog-rpcSkill
- adding-product-alertingSkill
- adding-project-secret-api-key-authSkill
- adding-today-highlightsSkill
- adopting-generated-api-typesSkill
- analyzing-experiment-precompute-canarySkill
- analyzing-experiment-query-performanceSkill
- analyzing-insights-across-teamsSkill
- announcing-behavior-changesSkill
- auditing-warehouse-source-coverageSkill
- authenticating-to-clickhouseSkill
- authoring-ci-workflowsSkill
- building-on-capture-v1Skill
- building-product-empty-statesSkill
- building-the-toolbarSkill
- calling-the-ai-gatewaySkill
- clickhouse-migrationsSkill
- creating-customer-analytics-account-widgetsSkill
- debugging-ci-failuresSkill
- debugging-local-replaySkill
- debugging-local-task-agent-runsSkill
- debugging-mcp-analyticsSkill
- debugging-signals-pipelineSkill
- debugging-table-access-deniedSkill
- depot-ciSkill
- depot-container-buildsSkill
- depot-github-runnersSkill
- developing-subscriptionsSkill
- developing-the-cliSkill
- django-migrationsSkill
- django-startup-timeSkill
- documenting-warehouse-sourcesSkill
- editing-agents-mdSkill
- establishing-code-ownershipSkill
- exporting-recordings-to-customer-s3Skill
- extending-hobby-smoke-testsSkill
- extending-personhog-test-harnessSkill
- extending-the-admin-consoleSkill
- fixing-flaky-testsSkill
- formatting-slack-messagesSkill
- gating-production-deploysSkill
- gating-sensitive-actionsSkill
- generating-clickhouse-query-performance-reportsSkill
- hogliSkill
- implementing-mcp-toolsSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 15
Read products/dashboards_v2/.agents/primitives.md and .agents/performance.md first.
- Very specific: line 44
Add the type to DEFAULT_PANELS only when every host should get it.
- Distinctive: line 78
Follow it only when a host must configure the type.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Adding a dashboards v2 panel type
A panel type is the content a tile shows, such as a chart or markdown.
The tile owns the frame: title, description, menu, dragging, resizing and the error boundary.
Read products/dashboards_v2/.agents/primitives.md and .agents/performance.md first.
Files
Give the type its own folder, frontend/panels/<type>/:
<type>Spec.tsholds the config schema, thePanelSpecand thedefinePanelcall.- Each component has its own file, such as
<Type>Panel.tsx.
The layout functions, validateDashboard and tools that write dashboards as code load the spec file, sometimes outside the browser.
So the spec file loads its components with React.lazy and never imports one directly.
panelDefinition.tsx depends only on React, so keep it that way: UI such as messages and error reporting goes in PanelView or the tile.
Rules
- Define
configas az.strictObject, and take its TypeScript type from the schema withz.infer.definePanelchecks every saved config against the schema before any part of the type gets it, so the parts never castconfigand never type it asunknown. - Give the spec its config type and its literal type name:
PanelSpec<MarkdownConfig, 'markdown'>. - The
typeand every config field are saved in dashboard documents. Renaming one breaks saved dashboards, so it needs a migration, not a rename. - A panel type fills only its slots:
Component,Loading,HeaderExtra,FooterandmenuActions. Do not draw a title or add an error boundary in a panel. - Give the type a
Loadingshaped like its content when it has one. Off-screen tiles and suspended tiles show it, so a tile looks like itself before it mounts. - A type that shows data takes a
sampleDataoption in its factory, ascreateChartPaneldoes. The host sets it while it has no real data, and the type then draws made-up data inComponentand runs no queries. Mark it as sample data and keep its made-up numbers out of tooltips. - Components read only the small contexts they need, such as
FiltersContextandPanelHostContext, and never the dashboard state. A component that changes the dashboard's filters or time range readsFilterControlsContext. showOnInteractiveOnly(panel)returning true leaves the tile out of snapshots, such as images and printed pages.movable(panel)returning false stops a person dragging, resizing, moving or removing the tile. Left out, every tile is movable.duplicable(panel)returning false takes Duplicate off the tile's menu. Left out, every tile can be duplicated.keepMounted(panel)returning true keeps the panel mounted after it scrolls out of view. Use it only for a panel that holds state a person would lose, because the panel then stays in memory.- To show a product's own component rather than add a type, use
/adding-dashboard-v2-custom-content. allowedCustomizationslists the tile customizations the type allows, such as['backgroundColor']. The values a person picks are saved on the tile'spanel.appearance.menuActions(actions, context)returns the tile's menu. Append entries toactionswith a stablekey, and change the config withcontext.setConfig, which saves one undo step.- Add the type to
DEFAULT_PANELSonly when every host should get it. Otherwise a host passes the type in its own list. - A pure function in the spec, such as
sizeFor, gets a unit test.
Example: markdown
frontend/panels/markdown/markdownSpec.ts:
export const markdownConfigSchema = z.strictObject({ text: z.string() })
export type MarkdownConfig = z.infer<typeof markdownConfigSchema>
export const markdownSpec: PanelSpec<MarkdownConfig, 'markdown'> = {
type: 'markdown',
size: { w: 8, h: 8, minW: 3, minH: 4 },
configSchema: markdownConfigSchema,
allowedCustomizations: ['backgroundColor'],
}
const MarkdownPanel = lazy(() => import('./MarkdownPanel').then((module) => ({ default: module.MarkdownPanel })))
export const markdownPanel = definePanel({
...markdownSpec,
addTileOptions: [
{ label: 'Text', create: () => ({ type: 'markdown', config: { text: 'Write notes in **Markdown**.' } }) },
],
Component: MarkdownPanel,
})MarkdownPanel gets panel: ContentPanel<MarkdownConfig>, so panel.config.text is a checked string.
A host passes the type in its list, such as panels={[createChartPanel({ runQuery }), markdownPanel]}.
The chart type is a factory instead, createChartPanel, because a host adds its own kinds of chart and its query runner.
Follow it only when a host must configure the type.
Before you report done
pnpm --filter=@posthog/frontend typescript:checkand the dashboards v2 Jest tests pass.- The new type renders on the
/dashboard-v2kitchen sink: its content, its loading state, and the "not valid" message for a broken config. - Its tile can still be moved, resized and removed when the panel throws.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

