Splitter
Since 0.1.0-alpha.21Panes 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
Code
@* 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>
{
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:
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
var total = orders.Sum(o => o.Amount);
Console.WriteLine($"Total: {total:C}");Total: $12,480.00
Code
@* 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
Code
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>
{
[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.
SplitterPane: one pane of a Splitter.
Mode support
| Feature | Static | Interactive |
|---|---|---|
| Pane sizes, limits and a pane that fills, on the first paint | Yes | Yes |
| Sizes each person leaves, kept and drawn by the server | Yes | Yes |
| Dragging a bar, and arrow keys on it | Yes | Yes |
| Panes that collapse and restore | Yes | Yes |
| One pane at a time below a breakpoint, for phones | Yes | Yes |
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
| Press this key | To do this |
|---|---|
| Left or Right | Move the bar (reversed on right-to-left pages) |
| Up or Down | In a vertical splitter, move the bar |
| Shift+Left or Shift+Right or Shift+Up or Shift+Down | Move the bar a tenth of the splitter |
| Home or End | Move the bar as far as it goes either way |
| Enter | Collapse or restore a collapsible pane |
| Shift+F10 or Menu key | Open the bar's menu |
While dragging
| Press this key | To do this |
|---|---|
| Escape | Put the bar back where it was |
Parameters
| Prop | Type | Default |
|---|---|---|
OrientationOrientation.Horizontal puts the panes side by side, the default; Orientation.Vertical stacks them. | Orientation | Orientation.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. | bool | false |
ChildContentThe SplitterPanes. | RenderFragment? |
Plus 27 surface props, 17 item props and 4 common props.
Full APISee also
- AppShell: arranges a header, sidebar, main area, aside and footer with CSS.