---
title: ConditionalContainer
framework: applenewsformat
role: symbol
role_heading: Object
path: applenewsformat/conditionalcontainer
---

# ConditionalContainer

The object for defining conditional properties for a container component, and when the conditional properties are in effect.

## Declaration

```data
object ConditionalContainer
```

## Properties

conditions: An instance or array of conditions that, when met, cause the conditional container properties to take effect. allowAutoplacedAds: A Boolean value that allows the placement of ad banners between components. Nested components inherit the value of the outermost container that explicitly sets allowAutoplacedAds. The default value is true. anchor: An object that defines vertical alignment with another component. animation: An object that defines an animation to apply to the component. To remove a previously set condition, use none. behavior: An object that defines behavior for a component, like Parallax or Springy. To remove a previously set condition, use none. contentDisplay: An object that defines how to position child components within this ConditionalContainer  component. A HorizontalStackDisplay, for example, allows for displaying child components side by side. To remove a previously set condition, use none. hidden: A Boolean value that determines whether the component is hidden. layout: An inline ComponentLayout object that contains layout information, or a string reference to a ComponentLayout object that you define at the top level of the document. If you don’t define layout, Apple News bases the size and position on various factors, such as the device type, the length of the content, and the role of this component. style: An inline ComponentStyle object that defines the appearance of this component, or a string reference to a ComponentStyle that you define at the top level of the document. To remove a previously set condition, use none.

## Discussion

Discussion Use the ConditionalContainer object to define an array of conditional container properties and the conditions under which to apply them. When a condition is met, the value of a property in ConditionalContainer overrides the value of the same property if you define it in the parent Container component. See Container. Example {   "components": [     {       "role": "container",       "components": [         {           "role": "container",           "style": {             "backgroundColor": "#DDD"           },           "additions": [             {               "type": "link",               "URL": "https://apple.news/TqT-jfrI0QXaYqGoz68HYeQ"             }           ],           "components": [             {               "role": "heading",               "layout": {                 "padding": 25               },               "textStyle": {                 "textAlignment": "center"               },               "text": "Top Stories"             }           ],           "hidden": true,           "conditional": [             {               "hidden": false,               "conditions": [                 {                   "maxViewportWidth": 415                 }               ]             }           ]         },         {           "role": "container",           "style": {             "backgroundColor": "#c6c6c6"           },           "additions": [             {               "type": "link",               "URL": "https://apple.news/TEa7q5ujiSdm1_YFSrEYYSw"             }           ],           "components": [             {               "role": "heading",               "layout": {                 "padding": 25               },               "textStyle": {                 "textAlignment": "center"               },               "text": "Top Videos"             }           ],           "hidden": true,           "conditional": [             {               "hidden": false,               "conditions": [                 {                   "minViewportWidth": 416                 }               ]             }           ]         }       ]     }   ] }

## Relationships

### Inherits From

- [ConditionalComponent](applenewsformat/conditionalcomponent.md)

### Inherited By

- [ConditionalSection](applenewsformat/conditionalsection.md)

## See Also

### Conditional Design Elements

- [Condition](applenewsformat/condition.md)
- [ConditionalComponent](applenewsformat/conditionalcomponent.md)
- [ConditionalComponentLayout](applenewsformat/conditionalcomponentlayout.md)
- [ConditionalAutoPlacement](applenewsformat/conditionalautoplacement.md)
- [ConditionalSection](applenewsformat/conditionalsection.md)
- [ConditionalDocumentStyle](applenewsformat/conditionaldocumentstyle.md)
- [ConditionalText](applenewsformat/conditionaltext.md)
- [ConditionalTextStyle](applenewsformat/conditionaltextstyle.md)
- [ConditionalComponentTextStyle](applenewsformat/conditionalcomponenttextstyle.md)
- [ConditionalComponentStyle](applenewsformat/conditionalcomponentstyle.md)
- [ConditionalDivider](applenewsformat/conditionaldivider.md)
- [ConditionalButton](applenewsformat/conditionalbutton.md)
