Conditional values
Enterprise plan only
Conditional values requires a Uniform Enterprise plan.
Conditional values let you choose between one or more alternative values for component parameters or content type fields ('properties') based on conditional expressions.
Common use cases#
- Define fallback values when external data is not available.
- Adjust layout settings or content based on current user context such as screen size or device type.
- Map technical details to human-readable values. E.g. map a country code to a country name.
- Translate external data attributes that are not translated by default. E.g. translate a product category name that is retrieved from an external product catalog.
Supported condition criteria#
Criteria | Components & Compositions | Component patterns & composition patterns | Entries & Entry patterns |
---|---|---|---|
Locales | π« Not supported | π« Not supported | π« Not supported |
Dynamic inputs | β
Supported (if attached to a project map node) | π« Not supported | π« Not supported |
Quirks | β Supported | β Supported | π« Not supported |
Dynamic Tokens | β Supported | β Supported | β Supported |
Enabling Conditional values#
Each property must enable conditional values on its component or content type definition. This is done by checking the "Enable conditional values" checkbox when adding or editing a parameter or field.
Conditional values are not supported for fields of type blocks
.
tip
Conditional values work in concert with localized values; when localized, each locale has its own independent set of conditional values.
Creating Conditional values#
To create a conditional value:
Open a component or entry and navigate to the property, that has conditional values enabled, and you want to add conditional values to.
In the property's menu, choose "Manage conditional valuesβ¦". This opens the conditional values editor in a drawer for the current locale.
Manage conditional values menuClick "Add conditional value" to add the first conditional value. The default value is automatically copied to the new conditional value. Adjust the value as needed.
Add conditional value to a parameterThe new conditional value starts of with no conditions, which means it is always used. Click the "No conditions defined" box, or choose "Manage conditions" from the value's menu to open the conditional expression editor.
Manage conditions of a conditional valueChoose a conditional expression to show the component. As you work, the current result of the conditional expression is shown based on your current preview settings (i.e. preview product ID).
Matching conditional value is shown in preview and in parameterClick Accept. The condition is applied.
Order of condition evaluation
When evaluating conditional expressions, Uniform starts at Condition 1 and uses the first matching conditional value. If no conditional values match, then the default value is used instead.
You can reorder conditions in their menu to control the order of evaluation.