Skip to content

Conditional

A conditional expression that selects between two values based on a prop’s state. Introduced in schema 0.13.0.

interface Conditional {
if: {
condition: ConditionExpression;
then: string | boolean | number | null;
else: string | boolean | number | null;
};
}

Properties

PropertyTypeRequiredDescription
if.conditionConditionExpressionYesThe test to evaluate
if.thenstring | boolean | number | nullYesValue when condition is true
if.elsestring | boolean | number | nullYesValue when condition is false

ConditionExpression

PropertyTypeRequiredDescription
operationstringYesOperation to perform
args.valuePropBindingYesThe prop to test
args.compareTostring | number | boolean | nullNoComparison value (omitted for unary operations)

Operations

OperationArityDescription
isNullUnaryProp value is null
isNotNullUnaryProp value is not null
equalsBinaryProp value equals compareTo
notEqualsBinaryProp value does not equal compareTo

Example

Show or hide based on whether a slot prop has content:

if:
condition:
operation: isNull
args:
value:
$binding: "#/props/icon"
then: false
else: true

Further Reading