Skip to content
Page PageColumns

PageColumns

Masonry-style CSS columns: items of different heights pack without gaps.

On this page

Examples

Three columns

Items run down each column in reading order, then continue in the next.

Short

One line.

Longer

Cards of different heights pack without gaps, in reading order down each column, so a testimonial wall needs no JavaScript.

Medium

Two lines of text, enough to show the packing.

Tall

A taller card with more words: the quick brown fox jumps over the lazy dog, then does it again for good measure.

Tiny

Hi.

Regular

A regular card with a regular amount of text.

Razor
<KlyPageColumns Columns="3" Class="w-full gap-4 *:mb-4">
    @foreach (var (title, text) in _items)
    {
        <KlyPageCard Variant="PageCardVariant.Subtle" Title="@title" Description="@text" />
    }
</KlyPageColumns>

@code {
    private readonly (string Title, string Text)[] _items =
    [
        ("Short", "One line."),
        ("Longer", "Cards of different heights pack without gaps, in reading order down each column, so a testimonial wall needs no JavaScript."),
        ("Medium", "Two lines of text, enough to show the packing."),
        ("Tall", "A taller card with more words: the quick brown fox jumps over the lazy dog, then does it again for good measure."),
        ("Tiny", "Hi."),
        ("Regular", "A regular card with a regular amount of text."),
    ];
}

API

KlyPageColumns

Multi-column layout where items of different heights pack without gaps.

Parameters

Name Type Default Description
Class string Classes added to the root element, merged last so they win over the theme.
Columns int 3 Number of columns from the lg breakpoint, 2 to 4: one column on phones, two from sm.
Ui PageColumnsUi Per-instance class overrides of the slots of the page columns, see PageColumnsUi . They are merged after the theme and the Class parameter wins on the root slot.

Slots

Name Type Description
ChildContent RenderFragment The items. Each direct child is kept whole: it is never split across two columns.

Ui slots

Ui takes a PageColumnsUi with one class string per slot, merged after the theme.

Slot Styles
Root Classes merged into the root slot of KlyPageColumns , after the theme and the app configuration.