ConditionalText
The object for defining conditional properties for a text component, and when the conditional properties are in effect.
Declaration
object ConditionalTextProperties
| Name | Type | Description |
|---|---|---|
conditions Required | (Condition | [Condition]) | An instance or array of conditions that, when met, cause the conditional text component properties to take effect. |
anchor | Anchor | An object that defines vertical alignment with another component. |
animation | (ComponentAnimation | string("none")) | An object that defines an animation to apply to the component. To remove a previously set condition, use |
behavior | (Behavior | string("none")) | An object that defines behavior for a component, like Parallax or Springy. To remove a previously set condition, use |
hidden | boolean | A Boolean value that determines whether the component is hidden. |
inlineTextStyles | ([InlineTextStyle] | string("none")) | An array of Apple News ignores Inline text styles when the To remove a previously set condition, use |
layout | (ComponentLayout | string) | An inline ComponentLayout object that contains layout information, or a string reference to a If you don’t define |
style | (ComponentStyle | string | string("none")) | An inline To remove a previously set condition, use |
textStyle | (ComponentTextStyle | string) | An inline |
Discussion
Use the ConditionalText object to define an array of conditional text properties and the conditions under which to apply them. When a condition is met, the value of a property in ConditionalText overrides the value of the same property if you define it in the parent Text component. See Text.
Example
{
"components": [
{
"role": "text",
"textStyle": "exampleTextStyleSmall",
"text": "Apple News Format allows publishers to craft beautiful editorial layouts. Galleries, audio, video, and fun interactions like animation make stories spring to life.",
"conditional": [
{
"textStyle": "exampleTextStyleMedium",
"conditions": [
{
"minViewportWidth": 415
}
]
},
{
"textStyle": "exampleTextStyleLarge",
"conditions": [
{
"minViewportWidth": 769
}
]
}
]
}
],
"componentTextStyles": {
"exampleTextStyleSmall": {
"fontSize": 16
},
"exampleTextStyleMedium": {
"fontSize": 24
},
"exampleTextStyleLarge": {
"fontSize": 48
}
}
}