Metric Target
Open in playgroundPick a success metric, name a numeric target, pick a timeframe. The spec's "what good looks like" section in one gesture — the only component that combines a categorical pick with a numeric target.
Preview
Usage
import { MetricTarget } from "@/components/socratic-ui/metric-target";
const [value, setValue] = useState({
metricId: null,
target: null,
timeframe: null,
});
<MetricTarget
question="Pick a success metric and target"
metrics={[
{ id: "activation", label: "Activation rate", unit: "%", direction: "increase" },
{ id: "churn", label: "Churn", unit: "%", direction: "decrease" },
]}
timeframes={["30 days", "90 days", "6 months"]}
value={value}
onChange={setValue}
/>
API Reference
| Prop | Type | Default |
|---|---|---|
questionrequiredThe headline shown above the metric list. | string | — |
subtitleOptional supporting copy beneath the question. | string | — |
metricsrequiredThe selectable success metrics. `unit` shows next to the target input; `direction` drives the trend arrow. | { id: string; label: string; subtitle?: string; unit?: string; direction?: 'increase' | 'decrease' }[] | — |
timeframesSelectable timeframe chips. Defaults to a quarterly-ish set if omitted. | string[] | — |
valuerequiredThe currently picked metric, target number, and timeframe. | { metricId: string | null; target: number | null; timeframe: string | null } | — |
onChangerequiredCalled whenever any of the three fields changes. | (value: { metricId: string | null; target: number | null; timeframe: string | null }) => void | — |
targetPlaceholderPlaceholder text for the numeric target input. | string | — |
numberOptional leading question number, e.g. "01". | string | — |
motionOpt-in entrance animation config. Omit for static rendering; pass `{ enabled: true }` (or a preset from `motion.ts`) to animate in on mount. | SocraticMotion | — |