Single-Input Visuals
Build custom visualizations that display data from a single card
Single-input visuals receive data from one query and render it however you want. They're the most common type of custom visual.
When to Use Single-Input
Build a single-input visual when you need:
- Custom KPIs - Branded metric cards with unique layouts, animations, or comparison displays
- Specialized charts - Visualizations not available in Semaphor's built-in library (Sankey diagrams, gauge charts, custom maps)
- Branded components - Match your product's design system exactly
- Domain-specific displays - Healthcare timelines, financial tickers, logistics trackers
If your visual needs to combine data from multiple queries (like a KPI with a trend chart), see Multi-Input Visuals.
Tutorial: Build a Custom KPI Card
This tutorial walks through creating a KPI card that displays a primary metric with comparison data.
Step 1: Create the Component File
Step 2: Define the Component with SingleInputVisualProps
Step 3: Access Card Metadata
The cardMetadata prop gives you read-only context about the card: its title, description, type, and KPI configuration.
Step 4: Apply Number Formatting
Use formatConfig from cardMetadata to format numbers according to the user's configuration in Semaphor.
Step 5: Handle Theming
Use the theme prop to match your visual with the dashboard's color scheme and dark mode.
Step 6: Register in components.config.ts
SingleInputVisualProps Reference
Every single-input visual receives these props from Semaphor:
CardMetadata
Semaphor automatically builds cardMetadata from the source card's configuration. This is read-only context your visual can use.
Using cardMetadata
FormatConfig for Number Formatting
The formatConfig object contains formatting rules configured by users in Semaphor's visual editor. Use it to format numbers consistently.
Structure
Applying KPI Formatting
Color Ranges
Apply conditional coloring based on value thresholds:
Inline Filters
Semaphor passes pre-rendered filter components via inlineFilters. You decide where they appear in your layout.
Inline filters differ from dashboard filters: they only affect the card they're in, not the entire dashboard.
Common Patterns
Empty State
Always handle missing or empty data gracefully:
Loading State
Check the editing prop to show placeholder content in the editor:
Responsive Layout
Use flex and grid layouts to adapt to different card sizes:
Examples
Basic KPI Card
A minimal KPI that displays a single value with title:
KPI with Comparison and Trend
A KPI card showing current value, comparison, and a trend indicator:
KPI with Currency Formatting from formatConfig
A KPI that uses Semaphor's format configuration for proper currency display:
Next Steps
- Multi-Input Visuals - Combine data from multiple cards
- Custom Components Guide - Full plugin development reference
- Theming - Match your visuals to dashboard themes