Column

Column widget

Column is designed to arrange child widgets vertically, where the intrinsic sizes of child widgets dictate the layout's appearance.

Best Practices

  • If a single vertical scrollbar is needed for the entire screen, consider using scrollableView: true at the View level.
  • If the entire screen's vertical space is used without a need for scrolling (or if the scrolling is inside some nested section), considered using FlexColumn](/widgets/flex-column.md) to fill the entire vertical space.
  • Use Column to lay out the children vertically from top to bottom. Enable scrollable if the children might exceed the available space.
  • Avoid using child widgets with no height constraint or sized itself to the parent inside the Column.
  • Avoid using nested scrollable Column for better UX.

Key Concepts

  • mainAxisSize: By default the height of a Column is determined by its parent's height constraint (if available), otherwise it will be the combined height of its children. You may force the Column to do the later (size itself to the children's combined height) with mainAxisSize=min. Note that a Column does not pass a height constraint to its children, so a Column inside another Column will always size itself to its children.
  • mainAxis: This property controls the vertical alignment of the children within the Column. This property is useful only when the mainAxisSize is set to max (default) as there are available spaces to align the children.
  • crossAxis: This property controls the horizontal alignment of the children within the Column.
  • scrollable: Enable vertical scrolling when the child widgets grow wider than the available space.

Test in Kitchen Sink (opens in a new tab)

Reference

Properties

PropertyTypeDescription
childrenWidget[]List of child widgets
item-templateItemTemplateList of templated widgets, appearing after the children
stylesobjectSee properties

item-template

PropertyTypeDescription
datastringBind to an array of data from an API response or a variable
namestringSet the name to reference as you iterate through the array of data
templatewidgetThe widget to render for each item

styles

PropertyTypeDescription
mainAxisSizeintegerIf 'max', stretch the Column to fill its parent's height. Otherwise (min) the column's height will be its children's combined. min max
mainAxisstringControl our children's layout vertically. start center end spaceBetween spaceAround spaceEvenly
crossAxisstringControl the horizontal alignment of the children. start center end stretch baseline
fontSizeintegerSets the size of the text.
fontFamilystringSet the font family applicable for all widgets inside this container, see the list of all available font families here (opens in a new tab).
gapintegerThe gap between the children in the main direction
scrollablebooleanSet to true so content can scroll vertically as needed
autoFitbooleanExplicitly make the column's width as wide as the largest child, but only if our column's parent does not already assign a width. This attribute is useful for sizing children who don't have a width (e.g Divider)
borderRadiusstring or integerThe border radius of the widget.This can be specified using CSS-like notation with 1 to 4 integers. Minimum value: 0.
borderColorColorSets the border color, starting with '0xFF' for full opacity. transparent black blue white red grey teal amber pink purple yellow green brown cyan indigo lime orange
borderWidthintegerThickness of the border. Minimum value should be 0.
shadowColorinteger or stringSets the box shadow color starting with '0xFF' for full opacity. transparent black blue white red grey teal amber pink purple yellow green brown cyan indigo lime orange
shadowOffsetarrayThe values in array define the horizontal and vertical offset of the shadow. Example: if the shadowOffset is set to [2, 4], the shadow will be offset by 2 pixels horizontally and 4 pixels vertically from its original position.
shadowRadiusstring or integerThe border radius of the widget.This can be specified using CSS-like notation with 1 to 4 integers. Minimum value: 0.
shadowStylestringThe blur style to apply on the shadow normal, solid, outer, inner
stackPositionTopintegerThe distance of the child's top edge from the top of the stack. This is applicable only for Stack's children.
stackPositionBottomintegerThe distance that the child's bottom edge from the bottom of the stack. This is applicable only for Stack's children.
stackPositionLeftintegerThe distance that the child's left edge from the left of the stack. This is applicable only for Stack's children.
stackPositionRightintegerThe distance that the child's right edge from the right of the stack. This is applicable only for Stack's children.
captureWebPointerbooleanApplicable for Web only. When overlaying widgets on top of certain HTML container (e.g. Maps), the mouse click is captured by the HTML container, causing issue interacting with the widget. Use this to capture and maintain the mouse pointer on your widget.
marginstring or integerMargin with CSS-style notation
paddingstring or integerPadding with CSS-style value
widthintegerThe width property determines the horizontal size of an element, allowing control over its width dimension within the layout.
heightintegerThe height property determines the vertical size of an element, allowing control over its height dimension within the layout.
backgroundImageBackgroundImageBackground image of the box.
backgroundGradientGradientBackground gradient of the box
backgroundColorColorBackground color of the box. which can be represented in different formats. It can be specified as a number, a predefined color name, or a hexadecimal value starting with '0x'. transparent black blue white red grey teal amber pink purple yellow green brown cyan indigo lime orange
expandedbooleanIf the parent is a Row or Column, this flag will stretch this widget in the appropriate direction. (e.g. stretch horizontally for parent of type Row)
visibilityTransitionDurationnumberSpecify the duration in seconds when a widget animates between visible and not visible state. Note that setting this value will cause the widget to still occupy the UI space even when it is not visible.
elevationintegerThe z-coordinate at which to place this material relative to its parent. A non-zero value will show a shadow, with its size relative to the elevation value. Minimum value: 0, Maximum value: 24
elevationShadowColorColorThe shadow color for the elevation, which can be represented in different formats. It can be specified as a number, a predefined color name, or a hexadecimal value starting with '0x'. transparent black blue white red grey teal amber pink purple yellow green brown cyan indigo lime orange
elevationBorderRadiusstring or integerThe border radius of the widget.This can be specified using CSS-like notation with 1 to 4 integers. Minimum value: 0.
alignmentstringThe alignment of the widget relative to its parent. topLeft, topCenter, topRight, centerLeft, center, centerRight, bottomLeft, bottomCenter, bottomRight
visiblebooleanToggle a widget visibility on/off. Note that an invisible widget will not occupy UI space, unless the visibilityTransitionDuration is specified.