motherduck-dive-components
Build Dive UIs from a reusable React component kit (stat cards, gauges, area, heatmap, Sankey, treemap, timeline, date picker), brand themes, and custom components.
Install this skill
No account required. Pick your tool, or use the command that detects it for you.
Run in your terminal. It detects your AI tool.
npx @skills-hub-ai/cli install motherduck-motherduck-dive-componentsManual setup by platform
Claude Code
~/.claude/skills/motherduck-motherduck-dive-components/SKILL.md
Signing
SignedSLSA L2- Signed by
- skills-hub.ai distributor
- Method
- Distributor-signed by skills-hub.aiCryptographically signed by the skills-hub.ai distributor key at publish time.
- Signed
Instructions
MotherDuck Dive Components
A component kit for Dives, copied into the Dive as source the way shadcn/ui works: a Dive is one .tsx file that may import only the runtime libraries get_dive_guide lists, so nothing is installed. Use it when a Dive needs more than the basic charts, a consistent look across several Dives, a brand theme, or a component the kit lacks. motherduck-create-dive owns the Dive mechanics (runtime contract, saving, sharing, embedding, write-back); this skill owns the visual building blocks.
When MotherDuck MCP is available, call get_dive_guide before writing Dive code and before every save_dive, update_dive, or edit_dive_content.
Start Here
- Open
artifacts/gallery/index.htmlin a browser to see every component on sample data, with each block's data behind its</>button. It needs no MotherDuck account. - Read
artifacts/components.json: for each component, the data shape it renders, when to use it, and the other renderers it can switch to. - Pick components for the question, write the Dive's queries, and build blocks from the rows.
Kit
| Path | What it holds |
|---|---|
artifacts/kit/core.tsx | Themes, makeTheme, ThemeCtx, formatting (N, fmt, niceTicks), primitives (Card, Badge, Button, Segmented, Skeleton, Delta, Sparkline), registerComponent, BlockView |
artifacts/kit/blocks.tsx | KPI row, line, bar, table, callouts, text |
artifacts/kit/stats.tsx | Metric cards, compact stats, radial gauges |
artifacts/kit/area.tsx | Area chart with headline value, legend toggles, crosshair |
artifacts/kit/heatmap.tsx | Calendar (daily activity) and matrix heatmaps |
artifacts/kit/sankey.tsx | Flows from one set of categories to another |
artifacts/kit/treemap.tsx | Part-to-whole, grouped, click to zoom |
artifacts/kit/timeline.tsx | Events in order |
artifacts/kit/datepicker.tsx | Single date and range picker with presets (an input, not a block) |
artifacts/examples/funnel.tsx | A custom component to copy |
artifacts/assemble.py | Concatenates the kit, custom files, and your Dive into one index.tsx |
Blocks
Every component renders a block: a plain object with id, type, title, and data in the shape components.json gives. Components never run SQL. Query with useSQLQuery, convert values with N(), build the block, and render it with BlockView:
// @imports
import { useSQLQuery } from '@motherduck/react-sql-query';
// @imports-end
export const REQUIRED_DATABASES = [{ type: 'database', path: 'md:analytics', alias: 'analytics' }];
export default function DailyVisits() {
const q = useSQLQuery(`SELECT strftime(day, '%Y-%m-%d') AS x, count(*) AS visits
FROM "analytics"."main"."events" GROUP BY 1 ORDER BY 1`);
const rows = Array.isArray(q.data) ? q.data : [];
const block = {
id: 'daily', type: 'heatmap', mode: 'calendar', title: 'Daily visits',
x: { kind: 'time', grain: 'day' },
series: [{ key: 'visits', label: 'Visits', format: 'count' }],
data: rows.map((r: any) => ({ x: String(r.x), visits: N(r.visits) })),
};
return (
<ThemeCtx.Provider value={makeTheme('motherduck')}>
<Card title={block.title} icon={componentIcon(block.type)}>
{q.isLoading ? <Skeleton h={140} /> : <BlockView block={block} />}
</Card>
</ThemeCtx.Provider>
);
}
Any block can also carry narrative and context:
insight: a "so what" line, rendered by<BlockInsight>.about:{ definitions: [{ term, text }], why }, which<SourceFooter>shows with the source.probeandhypothesis: mark a follow-up query.
Callout items can carry continuity (new, ongoing, worsening, improving, resolved) with first_seen and times_seen. Pass a nav with rate and rating to add thumbs up and down.
For any input, use the form fields in kit/field.tsx, modelled on shadcn/ui Field:
- Layout:
FieldSetandFieldLegendgroup fields;FieldGroupstacks them. - One field:
Field(orientationvertical,horizontalorresponsive, plusinvalid) wraps aFieldLabel, the control, aFieldDescriptionand aFieldError. - Controls:
Input,Textarea,SelectandChoiceGroup(radio or checkbox choice cards, or chips). - From a spec: a
formblock renders a whole form and sends the answers tonav.submit(blockId, values). Use native controls: they work in every Dive.
A questions block asks viewers about a date or a segment the data can't explain. Each answer is a note: { kind: 'date' | 'topic', x, grain?, dimension?, value?, category, note }. Pass a nav with annotate and noteFor to take answers. withNotes(block, notes) pins notes to every block that shows that date or value, as markers on line and area charts. <NotesLine> lists them under a block, and <NoteForm>, built on the form fields, adds one from any chart.
Formats are count, currency, pct (a fraction), number, delta_pct, text, and row (read _format per row). Set good: 'down' on measures where lower is better, so deltas colour by meaning rather than direction.
Assemble and preview with the MotherDuck CLI:
python3 artifacts/assemble.py app.tsx -o my-dive/index.tsx --components kpi,line,heatmap
motherduck dive watch my-dive
Omit --components to include the whole kit. Before save_dive or update_dive, follow the review step that get_dive_guide sets for your client: when it asks you to show the final source or preview and get the user's go-ahead, do that once, unless the user already said to save without review.
Variants
A block can render with any registered component whose accepts(block) takes its data: a KPI row as stats, metric cards, compact stats, or gauges; a line as area, bar, heatmap, or table; a bar as treemap or table. variantsFor(block) lists them. Offer the switch with Segmented, and keep the viewer's choice in useDiveState.
Themes and Brands
motherduck is the default theme and follows the visual rules in get_dive_guide: flat, no card chrome, the MotherDuck palette. Use it unless the user asks for another look or the Dive already has one. The kit also ships swiss (greyscale, one red accent), paper (cards), duck (brutalist brand), and night (dark).
For a brand, ask for the accent colour, flat or card look, and a font, then derive a theme:
const theme = makeTheme({ base: 'paper', name: 'Acme', accent: '#0f766e', font: 'Georgia, serif', radius: 6 });
Dives cannot load web fonts, so offer system font stacks. Read references/THEMING.md for the token list and the contrast and colour checks.
Custom Components
When no kit component shows the data well, copy artifacts/examples/funnel.tsx, render only from the block with useTheme() tokens, and register it with registerComponent(type, { label, icon, render, variants, accepts }). Pass the file to assemble.py --extra. Read references/CUSTOM_COMPONENTS.md for the contract, the catalog entry, and how a Flight can plan the new component.
Rules
- Keep SQL out of components; a block is data only.
- Run every value through
N()before maths or charts; format dates in SQL. - Use inline styles for colours and sizes; arbitrary Tailwind values do not resolve.
- Each kit file declares its imports between
// @importsand// @imports-end;assemble.pymerges them. Do not name a component after an icon or chart it imports (Gauge,Treemap,Sankey). - After adding or changing a component, add a sample block to
artifacts/gallery/app.tsx, rebuild the page withpython3 artifacts/gallery/build_page.py(needs Node.js), and check it in the default theme and one other at desktop and phone width.
References
references/THEMING.md-- built-in themes,makeThemetokens, asking for a brand, contrast checksreferences/CUSTOM_COMPONENTS.md-- writing, registering, and cataloguing a new component
Related Skills
Load related skills only for missing capabilities; reuse established context.
motherduck-create-divefor the Dive runtime contract, saving, sharing, embedding, and write-backmotherduck-clifordive watch,dive push, and keeping Dive source in filesmotherduck-queryfor validating the SQL each block renders
Security
Reviews (0)
Related skills
Browse all →More from MotherDuck Agent Skills
View source →More Build skills
Browse category →Frequently asked questions about motherduck-dive-components
What does the motherduck-dive-components skill do?
Build Dive UIs from a reusable React component kit (stat cards, gauges, area, heatmap, Sankey, treemap, timeline, date picker), brand themes, and custom components. It's a reusable SKILL.md instruction set that loads into your AI coding assistant on demand, no prompt engineering, no copy-pasting every session.
How do I install the motherduck-dive-components skill?
Run `npx @skills-hub-ai/cli install motherduck-motherduck-dive-components` from your terminal. The CLI writes the SKILL.md to the correct location for your AI tool (e.g. ~/.claude/skills/motherduck-motherduck-dive-components/ for Claude Code or ~/.cursor/skills/ for Cursor with --target cursor) and adds it to your project's .skills.json lockfile.
Which AI tools does motherduck-dive-components work with?
motherduck-dive-components runs in Claude Code. It follows the open Agent Skills standard (SKILL.md), so the same skill works in every supported tool without modification.
Is the motherduck-dive-components skill free?
Yes. Every skill on skills-hub.ai is free and open-source. There are no premium tiers, paywalls, or usage limits. You only pay for whatever AI assistant you're already using.
How do I use motherduck-dive-components after installing it?
In Claude Code, type `/motherduck-motherduck-dive-components` (or whatever slash command the skill registers) and the AI follows the skill's instructions immediately. You can also reference it by name in natural language, your AI loads the skill into context when relevant.
Can I share the motherduck-dive-components skill with my team?
Yes. Commit your project's .skills.json lockfile and teammates run `npx @skills-hub-ai/cli install` (no args) to install every skill at the exact version you pinned. Organization-scoped installs work via skills-hub.ai organizations.