An if/else block routes a run down one of several branches by evaluating
conditions against the data. The If / Else component renders that evaluation as a
breakdown table: a summary of every branch (IF, ELSE IF, ELSE) and its
verdict up top, then a per-branch breakdown of each comparison — the field, the
operator, the expected and actual values, and whether it held. The branch that
was taken is highlighted, and branches skipped because an earlier one matched are
dimmed.
Branches
| Branch | Condition | Verdict |
|---|---|---|
IF | total_amount > 50000andcurrency = "USD" | Not matched |
ELSE IFTaken | total_amount > 10000andstatus = "approved" | Matched |
ELSE | otherwise | Skipped |
Breakdown
combined with and| Field | Operator | Expected | Actual | Result |
|---|---|---|---|---|
| total_amount | > | 50000 | 13541.34 | false |
| currency | = | "USD" | "USD" | true |
Breakdown
Takencombined with and| Field | Operator | Expected | Actual | Result |
|---|---|---|---|---|
| total_amount | > | 10000 | 13541.34 | true |
| status | = | "approved" | "approved" | true |
Sub-conditions are combined with the branch's logical operator (AND / OR),
shown inline in the formula and colored green or red by outcome.
Usage
Pass a run describing the branches and which one was taken. Everything is
presentation only — wire it to whatever your evaluation data looks like.
import { ConditionalBreakdownTable } from "@/registry/new-york-v4/blocks/conditional-block"
export function Example() {
return (
<div className="h-[520px] overflow-hidden rounded-xl border">
<ConditionalBreakdownTable
run={{
selectedBranchId: "if",
branches: [
{
id: "if",
kind: "if",
logicalOperator: "and",
matched: true,
subConditions: [
{
path: "data.total_amount",
operator: "is_greater_than",
expected: 10000,
actual: 13541.34,
matched: true,
},
],
},
{ id: "else", kind: "else", matched: true, skipped: true },
],
}}
/>
</div>
)
}The ConditionalBlock export wraps the table with a sample evaluation so it
renders on its own with no props.
API
ConditionalRun
| Field | Type | Description |
|---|---|---|
branches | BranchEval[] | The branches, in evaluation order. |
selectedBranchId | string | null | The id of the branch that was taken — highlighted in the table. |
BranchEval
| Field | Type | Description |
|---|---|---|
id | string | Stable identifier, matched against selectedBranchId. |
kind | "if" | "else_if" | "else" | Drives the branch badge and label. |
logicalOperator | "and" | "or" | How sub-conditions combine. Ignored for else. |
subConditions | SubConditionEval[] | The comparisons in this branch. Omit/empty for else. |
matched | boolean | Whether the branch evaluated to true. |
skipped | boolean | True when a prior branch matched first — the row is dimmed and no breakdown is shown. |
SubConditionEval
| Field | Type | Description |
|---|---|---|
path | string | Field path read from the input (a leading data. / likelihoods. prefix is stripped for display). |
operator | string | Operator key such as is_greater_than, is_equal_to, contains, exists — rendered with a readable symbol/label. |
expected | unknown | Value compared against. Hidden for unary operators (exists, is_empty, is_true, …). |
actual | unknown | Value found in the input. |
matched | boolean | Whether this comparison held — shown as a true/false pill. |
Components
| Export | Props | Description |
|---|---|---|
ConditionalBreakdownTable | { run: ConditionalRun } | The full breakdown table. |
ConditionalBlock | { run?: ConditionalRun } | The table preloaded with a sample evaluation; pass run to override. |