ComponentLayout
The object for defining the positioning for a specific component within the article’s column system.
Declaration
object ComponentLayoutProperties
| Name | Type | Description |
|---|---|---|
columnSpan | integer | A number that indicates how many columns the component spans, based on the number of columns in the document. By default, the component spans the entire width of the document or the width of its container component. |
columnStart | integer | A number that indicates which column the component’s start position is in, based on the number of columns in the document or parent container. By default, the component starts in the first column (note that the first column is 0, not 1). |
conditional | (ConditionalComponentLayout | [ConditionalComponentLayout]) | An instance or array of component layout properties that you can apply conditionally, and the conditions that cause Apple News Format to apply them. |
horizontalContentAlignment | string | A string value that sets the alignment of the content within the component. This property applies only when the width of the content is less than the width of the component. Apple News supports this property for LinkButton, Image, Logo, Divider, and MediumRectangleAdvertisement. All other components ignore this property. |
ignoreDocumentGutter | (boolean | string("none" | "left" | "right" | "both")) | A value that indicates whether Apple News ignores the gutters (if any) to the left and right of the component. The gutter size is defined in the Use this option if you want to position two components right next to each other without a gutter between them. This property applies only when a gutter actually exists to the left or right of the component. The first column doesn’t have a left gutter, and the last column doesn’t have a right gutter. Valid values:
You can also set this property to |
ignoreDocumentMargin | (boolean | string("none" | "left" | "right" | "both")) | A value that indicates whether the component applies or ignores the document’s margins. Ignoring document margins positions the component based on the document’s width and margin. Valid values:
Instead of specifying margins, you can set this property to The layout of a parent component always constrains any child components. As such, setting Specifying a value other than On device with a screen size wider than the document |
ignoreViewportPadding | (boolean | string("none" | "left" | "right" | "both")) | A value that indicates whether the component applies or ignores the viewport padding. Ignoring viewport padding positions the component at the edge of the display screen. This property affects the layout only if the component is in the first or last column. Valid values:
Instead of specifying the padding, you can also set this property to The layout of a parent component always constrains any child components. Setting If If By default, components don’t ignore the viewport padding, even if you previously specified |
margin | (Margin | integer) | A value that sets the margins for the top and bottom of the component as a single integer that Apple News applies to the top and bottom margins, or as an object containing separate properties for top and bottom. |
maximumContentWidth | (SupportedUnits | number) | A value that sets the maximum width of the content within the component. Specify this value as a number in points or using one of the available units of measure for components. See Specifying Measurements for Components. Apple News supports this property for LinkButton, Image, Logo, Divider, and MediumRectangleAdvertisement. All other components ignore this property. |
minimumHeight | (SupportedUnits | number) | A value that sets the minimum height of the component. A component is taller than its defined |
minimumWidth | (SupportedUnits | number) | A value that defines the minimum width of the layout when you use it within a Container with HorizontalStackDisplay as the specified |
maximumWidth | (SupportedUnits | number) | A value that defines the maximum width of the layout when you use it within a Container with HorizontalStackDisplay as the specified |
padding | (SupportedUnits | Padding | number) | A value that defines the padding between the content of the component and the edges of the component. You can define padding as a number in points or using one of the available units of measure for components. See Specifying Measurements for Components. |
Mentioned in
Discussion
Use the ComponentLayout object to define a position for a specific component within the column system defined using the Layout object.
For information on setting the units for the width and height, see Specifying Measurements for Components. For information on aligning components, see Anchor.
You can use this object in ArticleDocument.
Example
{
"components": [
{
"role": "heading1",
"layout": "heading1Layout",
"text": "Heading Text"
},
{
"role": "body",
"text": "Apple News Format allows publishers to craft beautiful editorial layouts. Galleries, audio, video, and fun interactions like animation make stories spring to life."
}
],
"componentLayouts": {
"heading1Layout": {
"columnStart": 0,
"columnSpan": 7,
"margin": {
"top": 24,
"bottom": 10
}
}
}
}