Stack
A FluentStack
is a container-type component that can be used to arrange its child components in a horizontal or vertical stack.
Characteristics
Although the FluentStack
component has a number of different parameters, there are some in particular that define
the overall layout that the component has:
- Orientation: Refers to whether the stacking of child components is horizontal (default) or vertical.
- Alignment: Refers to how the child components are aligned inside the container. This is controlled via the
HorizontalAlignment
andVerticalAlignment
parameters. -
Spacing: Refers to the space that exists between child components inside the
Stack
. This is controlled via theHorizontalGap
andVerticalGap
parameters.
Wrapping
Aside from the previously mentioned parameters, there is another parameter called Wrap
that determines
if items overflow the FluentStack
container or wrap around it. The wrap property only works in the direction of the FluentStack
,
which means that the children components can still overflow in the perpendicular direction (i.e. in a vertical FluentStack
, items might
overflow horizontally and vice versa).
Nesting
Stacks can be nested inside one another in order to be able to configure the layout of the application as desired.
Examples
Default example
FluentStack
is using all the default settings for its parameters. To make it clear what the default size is, it is rendered with a border here.
Using the FluentStack component
FluentStack
s. The first FluentStack
has its Orientation
parameter set
to Orientation.Vertical
. Its height has been set to 200 pixels and the VerticalGap
has been set to 20 pixels. The second,
nested, FluentStack
has its Orientation
parameter set to Orientation.Horizontal
. The HorizontalGap
has been set to 4 pixels. Its first element contains a forced break. No height has been set, so the container height adjusts to the height
of the highest element.
The alignment of the contents of both
FluentStack
s can be changed by selecting one the different options from each
of the listboxes (which are placed in a FluentStack
themselves as well).
Alignment of the Stack content elements:
Result:
item 1
Documentation
FluentStack Class
Parameters
Name | Type | Default | Description |
---|---|---|---|
ChildContent | RenderFragment? | Gets or sets the content to be rendered inside the component. | |
HorizontalAlignment | HorizontalAlignment | Left | Gets or sets the horizontal alignment of the components in the stack. Default is HorizontalAlignment.Left |
HorizontalGap | int? | 10 | Gets or sets the gap between horizontally stacked components (in pixels). Default is 10 pixels. |
Orientation | Orientation | Horizontal | Gets or sets the orientation of the stacked components. Default is Orientation.Horizontal . |
Reversed | bool? | Gets or sets a value indicating whether the stack is reversed. | |
VerticalAlignment | VerticalAlignment | Top | Gets or sets the vertical alignment of the components in the stack. Default is VerticalAlignment.Top |
VerticalGap | int? | 10 | Gets or sets the gap between vertically stacked components (in pixels). Default is 10 pixels. |
Width | string? | 100% | Gets or sets the width of the stack as a percentage string (default = 100%). |
Wrap | bool | False | Gets or sets a value indicating whether the stack wraps. |