Guides and Sample Code

Developer

Apple News Format Reference

On This Page

Container

A container component has child components that are rendered relative to the parent component. Containers can also include layout and styling information. The minimum size of a container component is determined by the size of its child components.

image: ../Art/photo_recommanded_2x.png
image: ../Art/photo_notrecommanded_2x.png

Extended by

Aside

Chapter

Header

Section

Required Properties

Property and type

Description

Version

role

String

This component always has the role container.

1.0

Optional Properties

Property and type

Description

Version

anchor

Anchor

An anchor object that aligns this component with another component.

1.0

contentDisplay

Collection Display

Defines how child components are positioned within this container component. For example, this property can allow for displaying child components side-by-side and can make sure they are sized equally.

  • On versions of News prior to iOS 11, child components will be positioned as if contentDisplay were not defined.

1.5

components

Array of Component

An array of components to display as child components. Child components are positioned and rendered relative to their parent component.

1.0

identifier

String

A unique identifier for this component. If used, identifier must be unique across the entire document. An identifier is required if you want to anchor other components to this component. See Anchor.

1.0

layout

Component Layout or String

Either an inline component layout object that contains layout information, or a string reference to a component layout that is defined at the top level of the document.

  • If layout is not defined, size and position will be based on various factors, such as the device type, the length of the content, and the role of this component.

1.0

style

Component Style or String

Either an inline component style object that defines the appearance of this component, or a string reference to a component style that is defined at the top level of the document.

1.0

Container Component and Properties Example

  1. {
  2. "role": "container",
  3. "layout": {
  4. "columnStart": 0,
  5. "columnSpan": 7,
  6. "ignoreDocumentMargin": true
  7. },
  8. "components": [
  9. {
  10. "role": "title",
  11. "layout": {
  12. "columnStart": 0,
  13. "columnSpan": 7,
  14. "margin": {
  15. "top": 45,
  16. "bottom": 15
  17. }
  18. },
  19. "textStyle": "sectionTitle",
  20. "text": "Season Preview: Nobody Saw This Coming"
  21. },
  22. {
  23. "role": "quote",
  24. "textStyle": "body",
  25. "text": "We wanted to make the audience's head spin."
  26. }
  27. ]
  28. }