VStack
The VStack component in the Scripting app is a layout view that arranges its child views vertically. It provides flexible options for aligning its subviews and controlling the spacing between them.
VStack Component
Type Declaration
Description
The VStack component arranges its child views in a vertical line, making it ideal for creating vertically stacked layouts. You can customize the alignment of subviews and the spacing between them to suit your design needs.
Properties
alignment (Optional)
- Type:
HorizontalAlignment - Default:
"center" - Description: Determines the horizontal alignment of the subviews within the stack. The alignment specifies how views are positioned relative to each other horizontally when placed vertically in the
VStack. - Accepted Values:
"leading": Aligns views to the left."center": Centers views horizontally."trailing": Aligns views to the right.
Example
spacing (Optional)
- Type:
number | undefined - Default: Automatically calculated based on the child views if not specified.
- Description: Sets the distance in pixels between adjacent subviews. Use
undefinedto let the stack automatically determine the optimal spacing.
Example
children (Optional)
- Type:
- Description: The child elements to display within the stack. You can pass individual elements, arrays of elements, or
undefined/nullvalues. Nullish values are ignored, allowing for dynamic layouts.
Example
HorizontalAlignment Type
Horizontal alignment guides control how views are positioned relative to each other when placed vertically in a VStack.
Type Declaration
Alignment Options
leading: Aligns all subviews to the left edge of the stack.center: Centers all subviews horizontally.trailing: Aligns all subviews to the right edge of the stack.
Visual Guide
Below is an illustration of the three alignment options:

Usage Example
Explanation
alignment="leading": Aligns all subviews to the left.spacing={10}: Adds 10 pixels of space between each subview.- Contains two child views:
- An
Imageview displaying a system icon. - Two
Textviews displaying labeled items.
- An
Best Practices
- Use
alignmentto control horizontal positioning when stacking text and icons for better visual consistency. - Leverage
spacingto create breathable and aesthetically pleasing layouts. - Pass dynamic or conditional children without worrying about
nullorundefinedvalues.
This documentation ensures you can confidently use the VStack component to create clean, vertically stacked layouts in your Scripting app projects.
