APL Container (APL 1.4)


(This is not the most recent version of APL. Use the Other Versions option to see the documentation for the most recent version of APL)

A Container component displays multiple child items. The Container uses a subset of Flexbox/Yoga as the layout language.

Properties

The Container component has the following properties:

Property Type/Value Default Styled Dynamic Description
alignItems stretch, center, start, end, baseline stretch No No Alignment for children in the cross-axis.
direction column, row, columnReverse, rowReverse column No No Direction in which to display the child components.
justifyContent start, end, center, spaceBetween, spaceAround start No No How to distribute free space when there is room on the main axis. Defaults to start.
numbered boolean false No No When true, assign ordinal numbers to children. Defaults to false.
wrap noWrap | wrap | wrapReverse noWrap No No How to wrap child components to multiple lines.

Unlike standard Flexbox containers, The APL Container component doesn't scroll. Place the Container within a ScrollView to create a scrolling component.

When the Container is the source or target of an event, the following values are reported in event.source or event.target:

{
  // Container-specific values
  "type": "Container",

  // General component values
  "bind": Map,         // Access to component data-binding context
  "checked": Boolean,  // Checked state
  "disabled": Boolean, // Disabled state
  "focused": Boolean,  // Focused state
  "height": Number,    // Height of the component, in dp (includes the padding)
  "id": ID,            // ID of the component
  "opacity": Number,   // Opacity of the component [0-1]
  "pressed": Boolean,  // Pressed state
  "uid": UID,          // Runtime-generated unique ID of the component
  "width": Number      // Width of the component, in dp (includes the padding)
}

alignItems

The Flexbox specification for how to align the child components in the cross-axis of the container. Defaults to stretch.

direction

The direction of layout in the container. Defaults to column. The direction property can take the following values:

Type Description
column Lay out the child components in a vertical column (Default).
row Lay out the child components in a horizontal row.
columnReverse Lay out the child components in a vertical column, but start from the opposite side
rowReverse Lay out the child components in a horizontal row , but start from the opposite side

justifyContent

The Flexbox specification for how to distribute free space when there is room on the main axis. This property applies when the container is larger than the size of its children. Defaults to start.

numbered

When true, set the data-binding ordinal for each of the items in the Container. The ordinals start with "1" and increment by one unless the numbering property in a child is set to "skip" or "reset". Note that the firstItem and lastItem properties don't participate in ordinal numbering. Defaults to false.

wrap

The Flexbox wrapping behavior of the children. The wrap property takes the following values:

Type Description
noWrap The Container lays out the children in a single line on the main axis. The Container might overflow. (Default)
wrap The child components can break into multiple lines.
wrapReverse The child components can break into multiple lines, but start from the opposite side.

Multichild properties

A Container is a multi-child component. The Container inherits all of the multi-child properties.

Container child components

The child components of a Container have additional properties to control positioning within the parent container.

Property Type Default Styled Dynamic Description
alignSelf auto, start, end, center, baseline, stretch auto No No Cross-axis layout position. Defaults to auto.
bottom Dimension none No No Specifies the distance from the bottom edge of the parent container. Used only for absolute positioning. Defaults to auto.
grow Number 0 No No If positive, this component will stretch if there is extra space in the Container. Defaults to 0.
left Dimension none No No Specifies the distance from the left edge of the parent container. Used only for absolute positioning. Defaults to 0.
numbering normal, skip, reset normal No No Control ordinal numbering of the next child. Defaults to normal.
position relative, absolute relative No No If absolute, this component will be positioned only with respect to the parent container. Defaults to 'relative'.
right Dimension none No No Specifies the distance from the right edge of the parent container. Used only for absolute positioning. Defaults to auto.
shrink Number 0 No No If positive, this component will shrink if there is not enough space in the Container. Defaults to 0.
spacing Absolute Dimension 0 No No Additional space to add between this component and the previous component in the layout. Defaults to 0. The spacing property is not currently supported.
top Dimension none No No Specifies the distance from the top edge of the parent container. Used only for absolute positioning. Defaults to 0.

alignSelf

Overrides the alignItems property for this child component.

position, bottom, left, right, top

When position is "absolute", this child is taken out of the normal layout ordering for the container and instead positioned absolutely relative to the parent. The top, bottom, left, and right properties are dimensional offsets from the sides of the parent container.

In an "absolute"-positioned element where the size of the element is fixed, the left property overrides the right property when both have values. The top property overrides the bottom property when both have values. If neither properties have values, the Container positions the element in the top-left position of the parent container.

For example, the following child component displays 5 units from the top-right of its parent container. The 5 setting for bottom is ignored:

{
  "position": "absolute",
  "width": 100,
  "height": 100,
  "top": 5,
  "bottom": 5,
  "right": 5
}

grow, shrink

Flexbox grow and shrink properties. A positive grow value stretches the component proportionally when there is extra space in the container. A positive shrink value allows the component to shrink below its normal size when there is not enough space in the container.

Negative grow or shrink values are ignored.

numbering

Controls the ordinal value when the parent has set numbered. This property controls how the ordinal value updates for the next child in the sequence, not the current child in the sequence.

  • normal: The next child's ordinal = ordinal + 1.
  • skip: The next child's ordinal = ordinal
  • reset: The next child's ordinal = 1

spacing

An amount of spacing to add between this component and the previous child component in the layout. The first item in the layout ignores spacing. Specify the spacing in absolute dimensions. The spacing property doesn't support relative dimensions.

The spacing properties applies to child components where position is relative. The property is ignored for child components where position is absolute.


Was this page helpful?

Last updated: Nov 28, 2023