Skip to content

Inlined

The Inlined component arranges elements sequentially in a line, automatically wrapping to the next line when needed. This layout is particularly useful when you need to display a collection of elements horizontally with consistent spacing and alignment options.

Helper method

The following helper method generates sample blocks with random sizes and colors to demonstrate the Inlined component's capabilities:

c#
void RandomBlock(IContainer container)
{
    container
        .Width(Random.Shared.Next(1, 4) * 25)
        .Height(Random.Shared.Next(1, 4) * 25)
        .Border(1)
        .BorderColor(Colors.Grey.Darken2)
        .Background(Placeholders.BackgroundColor());
}

Usage

c#
.Background(Colors.Grey.Lighten3)
.Padding(25)
.Border(1)
.Background(Colors.White)
.Inlined(inlined =>
{
    inlined.Spacing(25);
    inlined.BaselineMiddle();
    inlined.AlignCenter();
    
    foreach (var _ in Enumerable.Range(0, 15))
        inlined.Item().Element(RandomBlock);
});

example

Spacing

OptionDescription
SpacingSets the vertical and horizontal gaps between items.
VerticalSpacingSets the vertical gaps between items.
HorizontalSpacingSets the horizontal gaps between items.

Horizontal alignment

OptionDescription
AlignLeftAligns items horizontally to the left side.
AlignCenterAligns items horizontally to the center.
AlignRightAligns items horizontally to the left right.
AlignJustifyDistributes items horizontally, ensuring even spacing from edge to edge of the container.
AlignSpaceAroundSpaces items equally in a horizontal arrangement, both between items and at the ends.

Baseline alignment

OptionDescription
BaselineTopPositions items vertically such that their top edges align on a single line.
BaselineMiddlePositions items to have their centers in a straight horizontal liąne.
BaselineBottomPositions items vertically such that their bottom edges align on a single line.

Released under the MIT License