Layout

Sections, groups and columns for longer forms

By default, StellarAdmin displays a form's fields one below the other, in a single column. In most cases, however, it makes for a better user experience group fields together in logical sections and even display multiple fields next to each other in a row.

The trip edit page with a Trip section in two columns and a Pricing section in three

Splitting a form into sections

To add a section, call AddSection() with the section's title. In the section builder you can add fields, display fields, details sections, groups and other sections. You can also provide more useful information to the user about the information contained in the section using the Description property.

resource.AllowEdit(edit => edit.Fields(fields =>
{
    fields.AddSection("Trip", section =>
    {
        section.Description = "What people see when they browse trips.";

        section.Columns(2);
        section.Add(trip => trip.Title).ColumnSpanFull();
        section.Add(trip => trip.DestinationId);
        section.Add(trip => trip.LeadGuideId);
        section.Add(trip => trip.Summary).ColumnSpanFull();
    });
}));

Section layout

You can specify various layouts for a form section.

LayoutHow the section looks
StackedThe title and description are above the fields.
SplitThe title and description are beside the fields, when there's room. This is the default.
CardThe title, description and fields are in a bordered card.
The Trip section in each layout: Stacked
Stacked
The Trip section in each layout: Split
Split
The Trip section in each layout: Card
Card

You can set the layout on a global level for all forms in the application, on a form level for all sections on a specific form, or on an individual section level. The example below displays every form's sections in cards, the trip edit page's sections stacked, and its Pricing section split:

using StellarAdmin.UI;

builder.Services.AddStellarAdmin(admin =>
{
    // Configures the layout for every form in the application
    admin.ConfigureUI(ui => ui.ConfigureForms(forms => forms.SectionLayout = FormSectionLayout.Card));

    admin.AddEfCoreResource<Trip>(resource =>
    {
        resource.AllowEdit(edit =>
        {
            // Configures the layout for the trip edit page
            edit.SectionLayout = FormSectionLayout.Stacked;

            edit.Fields(fields =>
            {
                fields.AddSection("Pricing", section =>
                {
                    // Configures the layout for this section
                    section.Layout = FormSectionLayout.Split;
                    section.Add(trip => trip.BasePrice);
                });
            });
        });
    });
});

Grouping fields together

A group lays out fields together, without a title or a border. Use a group to put several small fields on one row of a larger form. To add a group, call AddGroup(). The example below puts the price, duration and group size in three columns:

fields.AddGroup(group =>
{
    group.Columns(3);

    group.Add(trip => trip.BasePrice);
    group.Add(trip => trip.DurationDays);
    group.Add(trip => trip.MaxGroupSize);
});

Laying out fields in columns

You can specify the number of columns for a form, section, details section, or group, using the Columns() method. The example below gives the form two columns, and makes Name span both:

fields.Columns(2);
fields.Add(trip => trip.Title).ColumnSpanFull();
fields.Add(trip => trip.BasePrice);
fields.Add(trip => trip.DurationDays);

Columns(2) displays two columns from the medium breakpoint and above, but below the medium breakpoint, they will be displayed in a single column. You can specify the number of columns at each breakpoint using a column builder. The example below uses two columns from the small breakpoint, and three from the large breakpoint:

section.Columns(columns => columns.Small(2).Large(3));

The breakpoints are the following sizes:

BreakpointMinimum width
BaseNone
Small30rem
Medium40rem
Large56rem

Base defaults to one column, and a breakpoint you don't set uses the number of columns of the breakpoint below it. The number of columns must be from 1 to 12.

The breakpoints measure the width of the form, section or group, not the width of the browser window. A narrow section, or a create page that opens in a side sheet from a lookup, displays fewer columns.

You can also set the number of columns an items spans, or the column number it should start in.

MethodWhat it does
ColumnSpan(2)Spans two columns.
ColumnSpan(span => span.Medium(2))Spans two columns from the Medium breakpoint.
ColumnSpanFull()Spans every column.
ColumnStart(1)Starts in the first column, so the item starts a new row.

StellarAdmin ignores ColumnStart() when the grid has one column, or when the item would extend past the last column.

On this page