Experiment Results

1 个变体

An A/B test results card with confidence intervals, a probability-to-beat-control meter, and a ship-the-winner flow.

A/B test

A/B test results with confidence intervals on a zero-lift axis, a probability-to-beat-control meter, and metric tabs that roll every number. Shipping the winner confirms in a dialog, then the status rolls to Shipped and the losing variants fade.

One-page checkout

Significant

Day 14 of 21 · 48,210 users · Primary: Conversion

99.1%One-page chance to beat control
target 95%
  • Control3.12%Baseline
  • One-page3.41%+9.3%
    One-page: +9.3%, interval +3.1% to +15.6%
  • Saved cards first3.05%−2.2%
    Saved cards first: −2.2%, interval −8.4% to +4.1%
+9.3%
  • Page load p95: ok
  • Payment errors: ok
  • Refund rate: watch
2 guardrails OK, 1 watch95% confidence
"use client";

import { ExperimentResults } from "@/components/premium/experiment-results";

export function ExperimentResultsAbTestPreview() {
  return (
    <div className="w-full px-4 py-10">
      <ExperimentResults />
    </div>
  );
}

安装

$ bunx --bun shadcn add @beui-pro/experiment-results-ab-test

API 参考

除标注为必填的属性外,其余均为可选。数据、文案和颜色默认使用示例内容。

ExperimentResults9 个属性
  • experiment

    Experiment to show. Defaults to the sample checkout test.

    Experiment
  • labels

    Text overrides merged over the default labels.

    Partial<{ running: string; significant: string; shipped: string; users: string; primary: string; metricsAriaLabel: string; beatControl: string; target: string; control: string; baseline: string; winner: string; ... 15 more ...; confidence: string; }>
  • formatters

    Formatter overrides for values, lifts, and user counts.

    Partial<ExperimentFormatters>
  • target

    Chance to beat control that counts as a win, 0 to 100. Defaults to 95.

    number

    默认值 95

  • defaultMetricId

    Metric tab selected on mount. Defaults to the primary metric.

    string
  • defaultTrendOpen

    Opens the cumulative lift chart on mount.

    boolean

    默认值 false

  • onShip

    Runs the ship after it is confirmed; a rejected promise shows an error.

    ((winnerId: string) => void | Promise<void>)
  • onMetricChange

    Called with the metric id when the tab changes.

    ((metricId: string) => void)
  • className

    Classes merged onto the root element.

    string
BeatControlMeter5 个属性
  • variant必填

    Leading variant for the selected metric.

    ExperimentVariant
  • probability必填

    Its chance to beat control, 0 to 100.

    number
  • target必填

    Decision threshold drawn as a target line, 0 to 100.

    number
  • active必填

    Fills the track once the card is in view.

    boolean
  • labels必填

    Text for the caption and target.

    Pick<{ running: string; significant: string; shipped: string; users: string; primary: string; metricsAriaLabel: string; beatControl: string; target: string; control: string; baseline: string; winner: string; ... 15 more ...; confidence: string; }, "target" | "beatControl">
ExperimentStatusPill3 个属性
  • status必填

    Status that sets the label and tint.

    "running" | "significant" | "shipped"
  • labels必填

    Status names.

    Pick<{ running: string; significant: string; shipped: string; users: string; primary: string; metricsAriaLabel: string; beatControl: string; target: string; control: string; baseline: string; winner: string; ... 15 more ...; confidence: string; }, ExperimentStatus>
  • className

    Classes merged onto the root element.

    string
IntervalBar9 个属性
  • low必填

    Lower bound of the lift interval in percent.

    number
  • high必填

    Upper bound of the lift interval in percent.

    number
  • estimate必填

    Point estimate of the lift in percent.

    number
  • range必填

    Axis half-range in percent; the axis runs from -range to +range.

    number
  • active必填

    Collapsed at zero until true, then the interval grows out from zero.

    boolean
  • delay

    Seconds before the first grow-in.

    number

    默认值 0

  • baseline

    Draws only the zero line and a muted dot, for the control row.

    boolean

    默认值 false

  • label

    Accessible summary, such as "+9.3%, 95% interval +3.1% to +15.6%".

    string
  • className

    Classes merged onto the root element.

    string
LiftTrend6 个属性
  • points必填

    Daily cumulative lift, oldest first.

    readonly LiftPoint[]
  • viewKey必填

    Key that replays the draw when the metric changes.

    string
  • open必填

    Whether the chart is shown.

    boolean
  • onOpenChange必填

    Called when the disclosure is toggled.

    (open: boolean) => void
  • labels必填

    Text for the toggle and caption.

    Pick<{ running: string; significant: string; shipped: string; users: string; primary: string; metricsAriaLabel: string; beatControl: string; target: string; control: string; baseline: string; winner: string; ... 15 more ...; confidence: string; }, "trend" | "trendCaption">
  • formatLift必填

    Formats the latest lift beside the toggle.

    (lift: number) => string
ShipDialog5 个属性
  • winner必填

    Variant that will get all traffic.

    ExperimentVariant
  • variants必填

    Every variant, for the traffic split.

    readonly ExperimentVariant[]
  • onConfirm必填

    Called when the ship is confirmed.

    () => void
  • onCancel必填

    Called when the dialog is dismissed.

    () => void
  • labels必填

    Dialog text.

    Pick<{ running: string; significant: string; shipped: string; users: string; primary: string; metricsAriaLabel: string; beatControl: string; target: string; control: string; baseline: string; winner: string; ... 15 more ...; confidence: string; }, "shipTitle" | ... 3 more ... | "confirm">
VariantRow10 个属性
  • variant必填

    Variant shown in this row.

    ExperimentVariant
  • result必填

    Result for the selected metric.

    VariantResult
  • metric必填

    Selected metric, passed to the value formatter.

    ExperimentMetric
  • range必填

    Axis half-range in percent shared by every row.

    number
  • active必填

    Grows the interval in once the card is in view.

    boolean
  • delay必填

    Seconds before this row's interval grows in.

    number
  • dimmed必填

    Fades the row back after another variant ships.

    boolean
  • winner必填

    Shows the winner tag after shipping.

    boolean
  • labels必填

    Text for the baseline and winner tags.

    Pick<{ running: string; significant: string; shipped: string; users: string; primary: string; metricsAriaLabel: string; beatControl: string; target: string; control: string; baseline: string; winner: string; ... 15 more ...; confidence: string; }, "users" | ... 1 more ... | "winner">
  • format必填

    Value, lift, and user formatters.

    ExperimentFormatters
类型7 个类型

这些属性使用的对象类型及其字段。

Experiment7 个字段
  • name必填

    Experiment name shown in the header.

    string
  • status必填

    Status when the card mounts. Shipping moves it to "shipped".

    ExperimentStatus
  • runtime必填

    Runtime caption, such as "Day 14 of 21".

    string
  • primaryMetricId必填

    Id of the metric that decides the winner.

    string
  • variants必填

    Variants, control first.

    ExperimentVariant[]
  • metrics必填

    Metrics, one tab each.

    ExperimentMetric[]
  • guardrails必填

    Guardrail metrics summarized in the footer.

    Guardrail[]
ExperimentFormatters3 个字段
  • value必填

    Formats a metric value, such as "3.41%" or "$5.12".

    (value: number, metric: ExperimentMetric) => string
  • lift必填

    Formats a relative lift in percent, such as "+9.3%".

    (lift: number) => string
  • users必填

    Formats a user count, such as "48,210".

    (users: number) => string
ExperimentVariant5 个字段
  • id必填

    Unique id, used as the key in each metric's results.

    string
  • name必填

    Variant name shown in the row and the ship dialog.

    string
  • traffic必填

    Share of traffic in percent, such as 34.

    number
  • isControl

    Marks the baseline every other variant is compared against.

    boolean
  • dotClassName必填

    Dot class that identifies the variant, such as `bg-blue-500`.

    string
ExperimentMetric6 个字段
  • id必填

    Unique id, used as the tab value.

    string
  • label必填

    Tab and header label, such as "Conversion".

    string
  • kind必填

    How values read: a percentage or a currency amount.

    "percent" | "currency"
  • decimals必填

    Fraction digits shown for values.

    number
  • results必填

    Results keyed by variant id.

    Record<string, VariantResult>
  • trend必填

    Daily cumulative lift of the leading variant, oldest first.

    LiftPoint[]
Guardrail2 个字段
  • name必填

    Guardrail metric name, such as "Payment errors".

    string
  • status必填

    Ok, watch (drifting), or breach (over its limit).

    GuardrailStatus
VariantResult6 个字段
  • users必填

    Users counted for this metric.

    number
  • value必填

    Metric value, such as 3.41 for 3.41% or 5.12 for $5.12.

    number
  • lift必填

    Relative lift vs control in percent. Control uses 0.

    number
  • low必填

    Lower bound of the lift's confidence interval in percent.

    number
  • high必填

    Upper bound of the lift's confidence interval in percent.

    number
  • probability必填

    Chance to beat control, 0 to 100. Ignored for the control.

    number
LiftPoint3 个字段
  • lift必填

    Cumulative relative lift on that day in percent.

    number
  • low必填

    Lower bound of the confidence band in percent.

    number
  • high必填

    Upper bound of the confidence band in percent.

    number