Contents

Condition

The object for defining a condition that, when met, causes conditional properties to go into effect.

Declaration

object Condition

Properties

NameTypeDescription
appstring

The application in which a person views the Apple News article.

Valid values:

  • any: The person is viewing the Apple News article in either the Apple News app or in the Stocks app.

  • news: The person is viewing the Apple News article in the Apple News app.

  • stocks: The person is viewing the Apple News article in the Stocks app.

following(boolean | string)

A Boolean or a string value to indicate whether the person viewing the article is following the channel that published the article. When you set the value to true or false, the system infers the channel ID from the article. When you set the value to a channel ID string, the conditional validates to true when the person is following that channel.

horizontalSizeClassstring

A string describing the width at which Apple News displays the article. The value indicates whether iOS considers the article width constrained (compact) or expansive (regular). When Apple News displays the article at the specified size class, the conditional properties are in effect. The horizontal size class is always regular in macOS.

maxColumnsinteger

The maximum number of columns in which Apple News displays the article. When a person views the article with the specified number of columns or fewer, the conditional properties are in effect. For more information about the column system, see Planning the Layout for Your Article.

maxContentSizeCategorystring

A string indicating a dynamic type size at which Apple News displays the article. When the article is displayed at the specified size or smaller, the conditional properties are in effect. The default content size category in iOS and macOS is L.

maxSpecVersionstring

An Apple News Format version that an Apple News client can use to display an article. When the Apple News Format version is equal to or less than the specified value, the conditional properties are in effect.

maxViewportAspectRatiofloat

A number indicating a width divided by a height. When the aspect ratio of the person’s viewport is the specified value or smaller, the conditional properties are in effect.

maxViewportWidthinteger

A number indicating width in points. When the width of the person’s viewport is the specified value or smaller, the conditional properties are in effect.

minColumnsinteger

The minimum number of columns in which Apple News displays the article. When a person views the article with the specified number of columns or more, the conditional properties are in effect. For more information about the column system, see Planning the Layout for Your Article.

minContentSizeCategorystring

A string indicating a dynamic type size at which Apple News displays the text in the article. When Apple News displays the article at the specified dynamic type size or greater, the conditional properties are in effect. The default content size category in iOS and macOS is L.

minSpecVersionstring

An Apple News Format version that can be used by an Apple News client that is displaying an article. When the Apple News Format version is equal to or greater than the specified value, the conditional properties are in effect.

minViewportAspectRatiofloat

A number indicating a width divided by a height. When the aspect ratio of the person’s viewport is the specified value or greater, the conditional properties are in effect.

minViewportWidthinteger

A number indicating the width in points. When the width of the person’s viewport is the specified value or greater, the conditional properties are in effect.

platformstring

A platform on which a person can view an article. When the person views the article on the specified platform, the conditional properties are in effect.

preferredColorSchemestring

A string describing the person’s preferred color theme for the system.

Valid values:

  • any. The person has no preference.

  • light. The person hasn’t enabled Dark Mode.

  • dark. The person has enabled Dark Mode.

subscriptionStatusstring

The type of subscription the person has. When the subscription is of the specified type, the conditional properties are in effect.

verticalSizeClassstring

A string describing the height at which Apple News displays the article. The value indicates whether iOS considers the article width constrained (compact) or expansive (regular). When Apple News displays the article at the specified size class, the conditional properties are in effect. The vertical size class is always regular in macOS.

territorystring

The territory of the person. When the value is specified, the conditional properties are in effect.

viewLocationstring

The context of the article. When the context is of the specified type, the conditional properties are in effect.

Mentioned in

Discussion

Use the Condition object to define the condition under which the associated properties are applied.

You can use this object in ConditionalComponent, ConditionalContainer, ConditionalSection, ConditionalText, ConditionalComponentLayout, ConditionalComponentStyle, ConditionalComponentTextStyle, ConditionalTextStyle, ConditionalDocumentStyle, ConditionalDivider, and ConditionalAutoPlacement.

Example

{
  "components": [
    {
      "role": "photo",
      "URL": "bundle://summer.jpg",
      "layout": "exampleLayout",
      "caption": "Thanks to the record drought, mountain lions have begun to descend from the peaks.",
      "hidden": false,
      "conditional": {
        "hidden": true,
        "conditions": {
          "maxViewportWidth": 320
        }
      }
    }
  ],
  "componentLayouts": {
    "exampleLayout": {
      "ignoreDocumentMargin": true,
      "conditional": [
        {
          "ignoreDocumentMargin": false,
          "conditions": [
            {
              "minViewportWidth": 768
            }
          ]
        }
      ]
    }
  }
}

See Also

Conditional Design Elements