Tones
The palette graph parts colour themselves from — eight tones on Tailwind's colours, each one variable, with soft, mid and ink shades mixed from it.
- neutral
- blue
- purple
- amber
- green
- pink
- coral
- red
Installation
pnpm dlx shadcn@latest add @pipecat/graph-toneEvery graph part installs this with it, so you rarely add it yourself. It puts the
palette in your theme: a --graph-* variable for each tone, and the graph-tone colours
for Tailwind.
Tones
A tone is a named colour. Give tone to a Graph, a
NodeGroup, a GraphNode or a
NodeConnector, and that element and everything
inside it is in that tone until something inside names another:
<GraphNode tone="green">
{/* Green, from the node. */}
<NodeConnector>…</NodeConnector>
{/* Coral, its own. */}
<NodeConnector tone="coral">…</NodeConnector>
</GraphNode>Parts never name a colour. They use four utilities that read the tone in scope, and so can your own content:
| Utility | Is | Used for |
|---|---|---|
bg-graph-tone | The tone itself. | A port's ring, a filled port. |
bg-graph-tone-mid | The tone, part-way to the card colour. | The stack behind a subflow. |
bg-graph-tone-soft | A tint of the tone on the card colour. | A group's island, icon tiles. |
text-graph-tone-ink | The tone, darkened or lightened until it reads. | Kind words, icons, tinted text. |
Any of them works as a text, border, ring or fill colour: border-graph-tone,
text-graph-tone-ink, ring-graph-tone/40.
The palette
Each tone is a variable named after it, set to one of Tailwind's colours: the 600 in light, the 400 in dark, so a port's ring stands out from the card in both.
| Tone | Variable | Colour |
|---|---|---|
neutral | --graph-neutral | --muted-foreground |
blue | --graph-blue | blue |
purple | --graph-purple | violet |
amber | --graph-amber | amber |
green | --graph-green | emerald |
pink | --graph-pink | pink |
coral | --graph-coral | orange |
red | --graph-red | red |
With no tone set anywhere, everything is neutral.
A tone of your own
A tone is only a name. Define --graph-<name> where your theme lives and use the name:
:root {
--graph-brand: var(--color-teal-600);
}
.dark {
--graph-brand: var(--color-teal-400);
}<GraphNode tone="brand">…</GraphNode>That one variable is enough: the mid, soft and ink shades are mixed from it and your
theme's --card and --foreground, so they follow light and dark. To choose a shade
yourself, define it beside the colour, for as many of the three as you want:
:root {
--graph-brand: var(--color-teal-600);
--graph-brand-mid: var(--color-teal-300);
--graph-brand-soft: var(--color-teal-100);
--graph-brand-ink: var(--color-teal-800);
}The tones that ship work the same way, so the same variables retune them:
--graph-green, --graph-green-soft and so on. Set one on a Graph, or any element, to
change it for what is inside:
<Graph className="[--graph-green:var(--color-lime-600)]">…</Graph>A name with no --graph-<name> variable falls back to neutral. Three names are taken,
tone, canvas and grid: the graph has variables of its own by those names.
Outside a part
graphToneStyle puts a tone in scope on an element of your own:
import { graphToneStyle } from "@/components/pipecat/graph/tone";
<span
style={graphToneStyle("green")}
className="bg-graph-tone-soft text-graph-tone-ink"
>
Booked
</span>;