Contents

FlexibleSpacer

The component for redistributing empty space inside a horizontal stack collection.

Declaration

object FlexibleSpacer

Properties

NameTypeDescription
role Requiredstring

Always spacer for this object.

anchorAnchor

An object that defines vertical alignment with another component.

animation(ComponentAnimation | string("none"))

An object that defines an animation you apply to the component.

Use the none value for conditional design elements. Adding it here has no effect.

behavior(Behavior | string("none"))

An object that defines behavior for a component, like Parallax or Springy.

The none value is used for conditional design elements. Adding it here has no effect.

conditional(ConditionalComponent | [ConditionalComponent])

An instance or array of component properties that can be applied conditionally, and the conditions that cause Apple News Format to apply them.

hiddenboolean

A Boolean value that determines whether the component is hidden.

identifierstring

An optional unique identifier for this component. If used, this identifier must be unique across the entire document. You will need an identifier for your component if you want to anchor other components to it.

layout(ComponentLayout | string)

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

The width of the spacer is determined automatically based on any remaining horizontal space, and the height is that of the parent container. Any top or bottom margins specified on a spacer component’s layout decreases the height of the layout within the parent container.

All properties of ComponentLayout object are supported except minimumHeight and minimumWidth.

style(ComponentStyle | string | string("none"))

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

The none value is used for conditional design elements. Adding it here has no effect.

Mentioned in

Discussion

Use the FlexibleSpacer object to redistribute the extra space between child components in a HorizontalStackDisplay. Otherwise, if you have two child components in a horizontal stack that don’t use up all of the space, the extra space is always on the right side. The FlexibleSpacer object does not have an intrinsic size, but is sized to fit any remaining width, and to fit the height of the parent container. The object is ignored when used outside of the HorizontalStackDisplay context.

Example

{
  "components": [
    {
      "role": "container",
      "components": [
        {
          "role": "image",
          "URL": "bundle://summer.jpg",
          "layout": {
            "minimumWidth": "60cw",
            "maximumWidth": "60cw"
          }
        },
        {
          "role": "spacer"
        },
        {
          "role": "image",
          "URL": "bundle://winter.jpg",
          "layout": {
            "minimumWidth": "35cw",
            "maximumWidth": "35cw"
          }
        }
      ],
      "contentDisplay": {
        "type": "horizontal_stack"
      }
    }
  ]
}

See Also

Article Structure