@provenancekit/ui is a theme-aware React component library. Add a <ProvenanceBadge> to any piece of AI-generated content and users can instantly inspect its full provenance chain.
Installation
@xyflow/react (the interactive graph engine) is included as a dependency and installed automatically — no extra steps needed.
Setup
1. Add the stylesheet
Import the design tokens and graph base styles once in your global CSS:
This single import provides:
- All
--pk-* CSS custom properties (light and dark mode)
- ReactFlow base styles for
<ProvenanceGraph>
No additional CSS configuration required.
2. Wrap your app with the provider
That’s it. Components auto-fetch provenance data and render correctly in light and dark mode with no further configuration.
Provider props
Next.js App Router
Components are marked "use client" internally. Re-export from a client boundary so Server Components can import them without errors:
Then import from components/ui/pk-ui in any Server Component.
Dark Mode
Add the .dark class to your root <html> element. All components — cards, popovers, graph canvas, node cards — switch to dark surfaces automatically.
Headless Mode
Every data-fetching component accepts data directly — no network requests needed. Useful for SSR, testing, and Storybook:
CSS Design Tokens
All styling uses CSS custom properties. Override any token globally or per-scope. Light-mode defaults are in :root; dark-mode overrides apply under .dark.
--pk-badge-bg stays dark in both light and dark mode by design — the “Pr” tag is a permanent provenance mark that needs to stand out on any background.
Or use the theme prop on ProvenanceKitProvider for common overrides without touching CSS:
Font — Red Hat Display
The "Pr" squircle badge defaults to Red Hat Display (700/800 weight). Load it from Google Fonts once in your app’s <head>:
In Next.js use next/font/google and expose it as a CSS variable:
Then in your global CSS wire the variable into the badge token:
Override with any font via --pk-badge-font-family if you prefer a different typeface.
Available Hooks
Troubleshooting
Graph doesn’t render / canvas is blank
You forgot @import "@provenancekit/ui/styles.css" in your global CSS. This import includes the ReactFlow base styles that the graph canvas requires.
“Pr” badge font looks wrong
The badge uses --pk-badge-font-family. Set it to your loaded font variable — see the Font section above.
Badge popover doesn’t open
Make sure you are not wrapping the <ProvenanceBadge> in a container that intercepts click events (e.g. an <a> tag or a draggable layer). If you need to nest it inside a link, use e.stopPropagation() on the link’s click handler.
TypeScript error: “Property ‘x’ does not exist on type ‘IntrinsicAttributes’”
You are likely on a stale cached version of @provenancekit/ui. Run npm install @provenancekit/ui@latest to get the current types.
Server Component import error in Next.js
Components are "use client" internally. Re-export them from a client wrapper file:
Then import from components/ui/pk-ui in Server Components.