Skip to content
IzzyBlazor

Enter all results ↑ ↓ move Esc close

Splitter

Since 0.1.0-alpha.21
Divides a view into panes the user resizes, such as a mail list beside the open message.

Panes side by side, or stacked, with a bar between each two that resizes them.

Three panes

Put a SplitterPane for each pane in a Splitter, which needs a height. A pane with a Size starts at it, and a pane with none fills the rest.

Static

Preview

Ada Lovelace

Quarterly numbers

Grace Hopper

Release checklist

Alan Turing

Lunch on Friday?

Radia Perlman

Network change tonight

Quarterly numbers

The figures are in. Revenue is up on last quarter, and the new plan's sign-ups are ahead of what we set.

Code

Usage.razor
@* A mail layout: folders, the list, and the message. Folders collapses; the sizes are kept. *@
<Splitter LayoutKey="example-mail" Height="Length.Rem(22)" Border="1" Radius="Radius.Md" Grow>
    <SplitterPane Label="Folders" Size="Length.Rem(11)" Min="Length.Rem(8)" Max="Length.Rem(16)" Collapsible>
        <NavMenu Padding="2">
            <NavItem Href="#" Icon="Lucide.Inbox" Badge="4">Inbox</NavItem>
            <NavItem Href="#" Icon="Lucide.Send">Sent</NavItem>
            <NavItem Href="#" Icon="Lucide.Archive">Archive</NavItem>
        </NavMenu>
    </SplitterPane>
    <SplitterPane Label="Messages" Size="Length.Percent(40)" Min="Length.Rem(12)">
        <Stack Gap="0">
            @foreach (var (from, subject) in _messages)
            {
                <Box PaddingX="4" PaddingY="3" BorderBottom="1">
                    <TextBlock Weight="FontWeight.Semibold">@from</TextBlock>
                    <TextBlock Size="TextSize.Sm" Color="Color.Muted">@subject</TextBlock>
                </Box>
            }
        </Stack>
    </SplitterPane>
    <SplitterPane Label="Message" Min="Length.Rem(14)">
        <Stack Padding="4" Gap="2">
            <Heading Level="3">Quarterly numbers</Heading>
            <TextBlock>The figures are in. Revenue is up on last quarter, and the new plan's sign-ups are ahead of what we set.</TextBlock>
        </Stack>
    </SplitterPane>
</Splitter>

@code {
    private readonly (string From, string Subject)[] _messages =
    [
        ("Ada Lovelace", "Quarterly numbers"),
        ("Grace Hopper", "Release checklist"),
        ("Alan Turing", "Lunch on Friday?"),
        ("Radia Perlman", "Network change tonight"),
    ];
}

Add this example to a page with the izzy CLI:

bash
izzy add component Splitter --at <file>:<line>

Min and Max hold a pane between them. Collapsible adds a button on the bar that collapses the pane.

To keep the sizes each person leaves, set LayoutKey. The server renders them on the next visit.

Stacked

To stack the panes, set Orientation to Vertical. A Size in percent keeps the pane's share as the splitter resizes.

Static

Preview

csharp
var total = orders.Sum(o => o.Amount);
Console.WriteLine($"Total: {total:C}");

Total: $12,480.00

Code

Stacked.razor
@* An editor over its output, stacked; the output pane collapses. *@
<Splitter Orientation="Orientation.Vertical" Height="Length.Rem(20)" Border="1" Radius="Radius.Md" Grow>
    <SplitterPane Label="Editor" Min="Length.Rem(5)">
        <Code Block Language="csharp">var total = orders.Sum(o => o.Amount);
Console.WriteLine($"Total: {total:C}");</Code>
    </SplitterPane>
    <SplitterPane Label="Output" Size="Length.Percent(35)" Min="Length.Rem(4)" Collapsible>
        <Box Padding="4"><TextBlock Family="FontFamily.Mono">Total: $12,480.00</TextBlock></Box>
    </SplitterPane>
</Splitter>

One pane on phones

For a list and its detail, set OnePaneBelow to a breakpoint. Below that window width the bars go and one pane fills the splitter: the pane marked Current.

Static

Preview

No order chosen

Choose an order from the list.

Code

OnePane.razor
@inject NavigationManager Navigation

@* Orders and the chosen order. Below 768px one pane shows: the list, then the order with a link back. *@
<Splitter OnePaneBelow="Breakpoint.Md" Height="Length.Rem(20)" Border="1" Radius="Radius.Md" Grow>
    <SplitterPane Label="Orders" Size="Length.Rem(16)" Min="Length.Rem(12)" Current="@(Chosen is null)">
        <ListView Items="_orders" ItemKey="o => o.Number" Label="Orders" ItemHref="@(o => Navigation.GetUriWithQueryParameter("order", o.Number))"
                  ItemCurrent="o => o == Chosen" Context="order">
            <ItemTemplate>
                <Column Gap="1" Grow>
                    <TextBlock Size="TextSize.Sm" Weight="FontWeight.Medium">@order.Number</TextBlock>
                    <TextBlock Size="TextSize.Sm" Color="Color.Muted">@order.Customer</TextBlock>
                </Column>
            </ItemTemplate>
        </ListView>
    </SplitterPane>
    <SplitterPane Label="Order" Current="@(Chosen is not null)">
        @if (Chosen is { } chosen)
        {
            <Column Gap="3" Padding="4">
                <Button Href="@Navigation.GetUriWithQueryParameter("order", (string?)null)" Variant="ButtonVariant.Ghost" StartIcon="Lucide.ArrowLeft" AlignSelf="Align.Start" HiddenFrom="Breakpoint.Md">Orders</Button>
                <Heading Level="3" Size="TextSize.Lg">@chosen.Number</Heading>
                <DescriptionList>
                    <DescriptionItem Term="Customer">@chosen.Customer</DescriptionItem>
                    <DescriptionItem Term="Total">@chosen.Total.ToString("C")</DescriptionItem>
                    <DescriptionItem Term="Status">@chosen.Status</DescriptionItem>
                </DescriptionList>
            </Column>
        }
        else
        {
            <Center Height="Length.Full" Padding="4">
                <EmptyState Icon="Lucide.Package" Title="No order chosen" TitleLevel="3" Description="Choose an order from the list." />
            </Center>
        }
    </SplitterPane>
</Splitter>

@code {
    [SupplyParameterFromQuery(Name = "order")] private string? Number { get; set; }

    private Order? Chosen => _orders.FirstOrDefault(o => o.Number == Number);

    private readonly Order[] _orders =
    [
        new("SO-2041", "Northwind Traders", 1280.00m, "Shipped"),
        new("SO-2042", "Lumen Studio", 349.50m, "Packing"),
        new("SO-2043", "Weber & Sons", 96.00m, "Awaiting payment"),
        new("SO-2044", "Fieldwork Co.", 2140.75m, "Delivered"),
    ];

    private record Order(string Number, string Customer, decimal Total, string Status);
}

Mark the list until an item is chosen, then the detail, and put a link back to the list in the detail. With the chosen item in the address, the two screens work on a static page and the browser's Back returns to the list.

The panes keep their sizes, so they are back when the window widens.

Details

A pane with a Size starts at it; a pane with none fills what's left (if every pane has a size, the last fills). Min and Max hold a pane between them. Each pane scrolls its own content. The page gives the splitter its height, as Height="Length.Full" in an app shell's main area. For a layout that splits both ways, put a Splitter in a pane.

OnePaneBelow is for phones: below that width there are no bars and one pane fills the splitter, the pane marked Current. A list and its detail become two screens: mark the list until an item is chosen, then the detail, and put a link back to the list in the detail.

The sizes are on the server's first paint. With LayoutKey, the sizes and collapsed panes each person leaves are kept in a cookie under that name, and the server draws them, so a reload or another page shows the layout as it was left.

Parts

Written inside Splitter. The API page lists their parameters.

Mode support

What works in each mode, Splitter
FeatureStaticInteractive
Pane sizes, limits and a pane that fills, on the first paintYesYes
Sizes each person leaves, kept and drawn by the serverYesYes
Dragging a bar, and arrow keys on itYesYes
Panes that collapse and restoreYesYes
One pane at a time below a breakpoint, for phonesYesYes

Static: static server-side rendering, with no circuit and no WebAssembly. Interactive: Server, WebAssembly or Auto.

Without JavaScript

Every page starts as plain HTML: before IzzyBlazor's script loads on a static page, while an interactive page prerenders, and with JavaScript off. With JavaScript off, panes keep the sizes they arrive with: the bars don't move and panes don't collapse.

Accessibility

  • Each bar is a focusable separator named after the pane before it ("Resize Folders"), which it controls. Arrow keys move it, Home and End go to the limits, and Enter collapses or restores a collapsible pane.
  • A click on a bar (not a drag) opens its menu: Wider, Narrower, Reset size and, beside a collapsible pane, Collapse. Right-click, a long press, Shift+F10 and the menu key open it too.
  • Give each pane a Label, or the bars are all named "Resize".

Keyboard navigation

On a bar

Splitter keys, On a bar
Press this keyTo do this
Left or RightMove the bar (reversed on right-to-left pages)
Up or DownIn a vertical splitter, move the bar
Shift+Left or Shift+Right or Shift+Up or Shift+DownMove the bar a tenth of the splitter
Home or EndMove the bar as far as it goes either way
EnterCollapse or restore a collapsible pane
Shift+F10 or Menu keyOpen the bar's menu

While dragging

Splitter keys, While dragging
Press this keyTo do this
EscapePut the bar back where it was

Parameters

Splitter parameters
PropTypeDefault
OrientationOrientation.Horizontal puts the panes side by side, the default; Orientation.Vertical stacks them.OrientationOrientation.Horizontal
LayoutKeyKeeps the sizes each person leaves, in a cookie under this name, so the server draws them on the first paint.string?
OnePaneBelowBelow this width the splitter shows one pane, filling it, with no bars: the SplitterPane marked Current, or the first when none is.Breakpoint?
DisabledStops the bars from moving and the panes from collapsing.boolfalse
ChildContentThe SplitterPanes.RenderFragment?

See also

  • AppShell: arranges a header, sidebar, main area, aside and footer with CSS.

Connection lost

Rejoining the server…