Node Badges
Small visual indicators on nodes for status, counts, alerts, or contextual info.
NodeBadge Interface
| Property | Type | Default | Description |
|---|---|---|---|
text | string | Required | Badge text or number. |
color | string | '#ffffff' | Text/icon color. |
background | string | '#ef4444' | Background color. |
position | string | 'top-right' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' |
shape | 'circle' | 'rect' | 'circle' | Badge shape. |
icon | 'dot' | 'alert' | 'check' | 'star' | undefined | Built-in icon (overrides text). |
Basic Usage
graph.addNode({
id: 'server-1',
data: { name: 'Web Server', status: 'healthy' },
style: {
fill: '#3b82f6',
label: 'Web Server',
badges: [
{
text: 'OK',
color: '#ffffff',
background: '#10b981',
position: 'top-right',
shape: 'rect',
},
],
},
}); Multiple Badges
graph.addNode({
id: 'user-alice',
data: { name: 'Alice' },
style: {
fill: '#8b5cf6',
label: 'Alice',
badges: [
{ text: '5', color: '#fff', background: '#ef4444', position: 'top-right' },
{ text: '', icon: 'star', color: '#fbbf24', background: '#78350f', position: 'top-left' },
{ text: '', icon: 'dot', color: '#10b981', background: '#064e3b', position: 'bottom-right' },
],
},
}); Built-in Icons
| Icon | Visual | Use Case |
|---|---|---|
'dot' | Filled circle | Online/offline status |
'alert' | Exclamation mark | Warnings, errors |
'check' | Checkmark | Verified, completed |
'star' | Star | Favorites, featured |
const statusBadge = (status) => {
switch (status) {
case 'healthy':
return { icon: 'check', color: '#10b981', background: '#064e3b' };
case 'warning':
return { icon: 'alert', color: '#f59e0b', background: '#78350f' };
case 'critical':
return { icon: 'alert', color: '#ef4444', background: '#7f1d1d' };
}
}; Updating Badges
// Update notification count
graph.updateNode('user-alice', {
style: {
badges: [
{ text: '12', color: '#fff', background: '#ef4444', position: 'top-right' },
],
},
});
// Remove all badges
graph.updateNode('user-alice', { style: { badges: [] } }); Dynamic Badges from Data
graph.batch(() => {
for (const node of graph.getNodes()) {
const count = graph.getNeighbors(node.id).length;
graph.updateNode(node.id, {
style: {
badges: [{
text: String(count),
color: '#e2e8f0',
background: count > 5 ? '#7c3aed' : '#475569',
position: 'bottom-right',
}],
},
});
}
}); “Made with TopoKit” Branding
There are two distinct “Made with TopoKit” surfaces — they look similar but live at different layers and respond to different conditions:
- SDK canvas watermark. Painted directly into the
graph canvas by the renderer (
watermark.ts). Only shown for unlicensed or trial builds; a valid license suppresses it. The SDK usesgetBoundingClientRectto lift the watermark above any bottom-right toolbar so it doesn't overlap controls. - Page-level DOM badge. An
<a class="tk-made-with">element rendered by the host page (TopoKit Play, shared topos at/t/<hash>, embedder pages). This is the badge you see when the SDK watermark is suppressed by a valid license. Style and link target are owned by the host page, not the SDK.
The two are independent: licensed embeds can still surface the page-level DOM badge as soft attribution, and the SDK watermark only ever appears when there is no valid license.
Next Steps
- Legend -- visual key for your graph
- Minimap & UI Components -- navigation components
- Progressive Expand -- badges for expand counts