# Blazor Splitter, Panels and Dashboard Layout

URL: https://flexcoreui.com/demo/layout  
Section: Components  
Controls: PageLayoutControl, SplitterControl, DashboardLayoutControl, GridLayoutControl, StackLayoutControl  
Keywords: splitter, split pane, dashboard layout, page layout, grid layout, stack layout, collapsible panel

Build app shells in Blazor: collapsible side panels, a splitter users resize from the keyboard, a dashboard of panels, and grid and stack layouts.

## Documentation

### Page layout

| Name | Type | Default | Description |
|---|---|---|---|
| PageLayoutControl.Height | string? | "100%" | Height of the flex row; panels fill it. |
| PageLayoutControl.CssClass | string? | null | Extra classes on the row. |
| Left/RightPanelControl.Width | string? | "250px" | Panel width when open. |
| Left/RightPanelControl.Collapsible | bool | false | Renders a 20px collapse tab just outside the panel's inner edge. In the current version the panel's own overflow clips that tab, so it cannot be seen or clicked; the example leaves it off and hides the panels through Collapsed. |
| Left/RightPanelControl.Collapsed | bool | false | Collapsed state; true sets the panel's width to 0. Two-way with @bind-Collapsed, and works without Collapsible. |
| CenterPanelControl |  |  | Takes the remaining width. Only CssClass and content. |

### Splitter

| Name | Type | Default | Description |
|---|---|---|---|
| PrimaryContent / SecondaryContent | RenderFragment? |  | The two panes. Primary is left or top. |
| Vertical | bool | true | true: vertical bar, panes side by side. false: horizontal bar, panes stacked. |
| PrimarySize | double | 240 | Primary pane size in px, or percent in Proportional mode. Bind it two ways: a parent re-render otherwise resets the pane to the parameter value. |
| SizeMode | SplitterSizeMode | Pixel | Pixel keeps the size through container resizes; Proportional keeps the ratio, pure CSS. |
| OnResizeCommitted | EventCallback<double> |  | Fires once when a drag or key press finishes. Persist from here. |
| ResizeOnRelease | bool | true | Guide while dragging, panes resize on release. false resizes live through the server. |
| MinPrimarySize / MaxPrimarySize | double | 80 / 1200 | Pixel limits. |
| MinPrimary / MaxPrimary / MinSecondary | string? | null | Limits that also take a percentage; they win over the pixel ones. |
| ShrinkPrimaryToContent | bool | false | Caps the primary pane at its content size. |
| DefaultPrimarySize / ResetOnDoubleClick | double? / bool | null / true | Size restored by a double-click; defaults to the first size seen. |
| KeyboardStep | double | 16 | Arrow-key step in px, or percentage points in Proportional mode. |
| SplitterSize | double | 6 | Bar thickness in px. |
| Disabled | bool | false | The bar ignores dragging, arrow keys and double-click; it stays focusable and dims to 60%. |
| Height / Width | string? | null | Container size. |
| Title | string | "Resize" | Bar tooltip and accessible name. |
| CssClass / Style | string? | null | On the container. |

### Dashboard

| Name | Type | Default | Description |
|---|---|---|---|
| Columns | int | 1 | Grid columns, equal width. |
| CellSpacing | double[]? | null (0, 0) | Column and row gap in px, as a two-element array. |
| CellAspectRatio | double | 1 | Height of one cell relative to its width; 1 is square. A panel is exactly its grid box and does not grow for tall content. |
| CssClass | string? | null | Extra classes on the grid. |
| Panel.Row / Panel.Column | int | 0 | Zero-based placement. |
| Panel.SizeX / Panel.SizeY | int | 1 | Column and row span. |
| Panel.ContentTemplate / ChildContent | RenderFragment? |  | Panel content; the template wins when both are set. |

### Css

| Name | Description |
|---|---|
| fx-page-layout · fx-left-panel · fx-center-panel · fx-right-panel | Flex row and its panels. Side panels: gray, bordered, scroll their own content; .fx-panel-collapsed at zero width. |
| fx-panel-toggle · -left · -right | The 20×40px collapse tab from Collapsible, placed outside the panel edge, where the panel's own overflow clips it. |
| fx-splitter · -vertical · -horizontal · -disabled | Container and orientation. |
| fx-splitter-pane · -primary · -secondary · fx-splitter-bar · fx-splitter-grip | Panes, the bar and its grip. |
| fx-splitter-overlay · fx-splitter-guide · fx-splitter-server-guide | Drag-time overlay and the guide line. |
| fx-dashboard-layout · fx-dashboard-panels · fx-dashboard-panel | The grid, a display: contents wrapper, and each item with its grid placement and aspect ratio inline. |
| fx-grid-layout · responsive | GridLayoutControl: tracks, gap and alignment are inline. .responsive, from CollapseOnSmallScreen, carries the 600px media rule. |
| fx-grid-layout-item | GridLayoutItemControl: placement, spans, self-alignment and min-width: 0 inline. |
| fx-stack-layout | StackLayoutControl: every flex property is inline; the library has no stylesheet for it. |

### Grid layout

| Name | Type | Default | Description |
|---|---|---|---|
| Columns | string | "repeat(2,minmax(0,1fr))" | Written into grid-template-columns as given, so any CSS track list works: repeat(3,minmax(0,1fr)), 160px 1fr, repeat(auto-fill,minmax(160px,1fr)). |
| Rows | string | "auto" | Written into grid-template-rows. |
| Gap | string | "12px" | Written into gap: one length for both directions, or the row gap then the column gap. |
| AlignItems | string | "stretch" | Written into align-items: block-axis alignment of every cell, such as start, center or end. |
| JustifyItems | string | "stretch" | Written into justify-items: inline-axis alignment of every cell. |
| CollapseOnSmallScreen | bool | true | Adds the responsive class. In a viewport 600px wide or less the grid becomes one column of automatic rows, and every GridLayoutItemControl inside it goes back to column 1 with its spans and row reset. Those rules are !important, so they win over the inline values. |
| ChildContent | RenderFragment? |  | The cells. Plain elements fill the next empty cell; wrap one in GridLayoutItemControl to place or span it. |
| CssClass / Style | string? | null | CssClass joins fx-grid-layout; Style is appended after the generated grid properties, so it can override them. |
| Id | string? | null | Rendered as the grid's id. |
| Visible | bool | true | false appends display:none. |

### Grid item

| Name | Type | Default | Description |
|---|---|---|---|
| Column / Row | int? | null | First column or row of the cell, counted from 1 like CSS grid lines (DashboardLayoutPanel counts from 0). null leaves it to auto-placement. |
| ColumnSpan / RowSpan | int | 1 | Columns and rows the cell covers; values below 1 count as 1. |
| AlignSelf / JustifySelf | string | "auto" | Written into align-self and justify-self for this cell only. |
| ChildContent | RenderFragment? |  | The cell's content. |
| CssClass / Style | string? | null | CssClass joins fx-grid-layout-item; Style is appended after the placement. |
| Id | string? | null | Rendered as the cell's id. |

### Stack

| Name | Type | Default | Description |
|---|---|---|---|
| Orientation | FlexOrientation | FlexOrientation.Horizontal | Horizontal writes flex-direction: row, Vertical column. |
| Gap | string | "12px" | Written into gap between items. |
| AlignItems | FlexAlignment | FlexAlignment.Stretch | Cross-axis alignment, written into align-items. The three Space values are not valid there, so the browser drops them and items stretch. |
| JustifyContent | FlexAlignment | FlexAlignment.Start | Main-axis distribution, written into justify-content. Stretch writes stretch, which a flex container treats as Start. |
| Wrap | bool | false | true writes flex-wrap: wrap. false keeps every item on one line, and items that cannot shrink further overflow the stack. |
| ChildContent | RenderFragment? |  | The items, in order. |
| CssClass / Style | string? | null | CssClass joins fx-stack-layout; Style is appended after the generated flex properties. |
| Visible | bool | true | false appends display:none. |

### Flex

| Name | Description |
|---|---|
| FlexOrientation.Horizontal | flex-direction: row. |
| FlexOrientation.Vertical | flex-direction: column. |
| FlexAlignment.Start | flex-start. |
| FlexAlignment.Center | center. |
| FlexAlignment.End | flex-end. |
| FlexAlignment.Stretch | stretch: items fill the cross axis in AlignItems; in JustifyContent it behaves as Start. |
| FlexAlignment.SpaceBetween | space-between: first and last item at the edges, equal space between. JustifyContent only. |
| FlexAlignment.SpaceAround | space-around: equal space on both sides of each item. JustifyContent only. |
| FlexAlignment.SpaceEvenly | space-evenly: equal space between items and at both edges. JustifyContent only. |

### Vars

| Name | Type | Description |
|---|---|---|
| --fx-splitter-size | 6px | Bar thickness; set by SplitterSize. |
| --fx-zoom | 1 | Scales the collapse-tab glyph. |

## Examples

### Shell

```razor
@using Fx.ControlKit
@using Fx.ControlKit.Layout

<div class="frame">
    <PageLayoutControl Height="340px">
        <LeftPanelControl Width="170px" @bind-Collapsed="_leftCollapsed">
            <div class="pane">
                <h4>Navigation</h4>
                <ul>
                    @foreach (var sec in _data.Keys)
                    {
                        <li><ButtonControl BareStyle="true" CssClass="@($"nav-item {(sec == _section ? "active" : "")}")" OnClick="@(() => Go(sec))">@sec</ButtonControl></li>
                    }
                </ul>
            </div>
        </LeftPanelControl>
        <CenterPanelControl>
            <SplitterControl Height="100%" @bind-PrimarySize="_listSize" MinPrimary="140px" MaxPrimary="60%" MinSecondary="200px"
                             OnResizeCommitted="@(_ => _commits++)" Title="Resize the list">
                <PrimaryContent>
                    <div class="pane">
                        <h4>@_section</h4>
                        <ul>
                            @foreach (var it in _data[_section])
                            {
                                <li><ButtonControl BareStyle="true" CssClass="@($"nav-item {(it == _selected ? "active" : "")}")" OnClick="@(() => _selected = it)">@it.Title</ButtonControl></li>
                            }
                        </ul>
                    </div>
                </PrimaryContent>
                <SecondaryContent>
                    <div class="pane">
                        @* Sidebar toggles the way editors do them: icon buttons, pressed while hidden, tooltip for the words. *@
                        <div class="pane-head">
                            <h4>@_selected.Title</h4>
                            <div class="icon-row">
                                <TooltipControl Text="@(_leftCollapsed ? "Show navigation" : "Hide navigation")" Placement="PopupPlacement.BottomEnd">
                                    <ToggleButtonControl @bind-Selected="_leftCollapsed" IconCss="bi bi-layout-sidebar" aria-label="Hide navigation" />
                                </TooltipControl>
                                <TooltipControl Text="@(_rightCollapsed ? "Show properties" : "Hide properties")" Placement="PopupPlacement.BottomEnd">
                                    <ToggleButtonControl @bind-Selected="_rightCollapsed" IconCss="bi bi-layout-sidebar-reverse" aria-label="Hide properties" />
                                </TooltipControl>
                            </div>
                        </div>
                        <p>@_selected.Summary</p>
                    </div>
                </SecondaryContent>
            </SplitterControl>
        </CenterPanelControl>
        <RightPanelControl Width="190px" @bind-Collapsed="_rightCollapsed">
            <div class="pane">
                <h4>Properties</h4>
                <dl class="props">
                    @foreach (var (key, value) in _selected.Props)
                    {
                        <dt>@key</dt><dd>@value</dd>
                    }
                </dl>
            </div>
        </RightPanelControl>
    </PageLayoutControl>
</div>
<span class="result">List pane @_listSize.ToString("0") px, @_commits @(_commits == 1 ? "commit" : "commits") · navigation @(_leftCollapsed ? "hidden" : "shown"), properties @(_rightCollapsed ? "hidden" : "shown")</span>
```

```csharp
private bool _leftCollapsed, _rightCollapsed;

private double _listSize = 200;

private int _commits;

// Shell data: three sections, each a short list; the detail pane and properties follow the selection.
private sealed record Item(string Title, string Summary, (string Key, string Value)[] Props);

private static readonly Dictionary<string, Item[]> _data = new()
{
    ["Requests"] = new[]
    {
        new Item("LIS-0001 Door", "Lisbon city break, four nights · 3 lines · Quoted · $1,720", new[] { ("Traveler", "Albus Door"), ("Status", "Quoted"), ("Lines", "3"), ("Total", "$1,720") }),
        new Item("KYO-0001 Thistlewood", "Kyoto long weekend · 6 lines · Draft · $4,860 · last saved today at 9:12 AM", new[] { ("Traveler", "Juniper Thistlewood"), ("Status", "Draft"), ("Lines", "6"), ("Total", "$4,860") }),
        new Item("AMF-0002 Puddleby", "Amalfi coast drive · 9 lines · Booked · $6,240", new[] { ("Traveler", "Barnaby Puddleby"), ("Status", "Booked"), ("Lines", "9"), ("Total", "$6,240") }),
    },
    ["Suppliers"] = new[]
    {
        new Item("Overhead Bin Airways", "Net 30 · 3 open bookings", new[] { ("Contact", "H. Quickfoot"), ("Terms", "Net 30"), ("Open bookings", "3") }),
        new Item("Hotel Lisbon Central", "Net 15 · 1 open booking", new[] { ("Contact", "P. Teacup"), ("Terms", "Net 15"), ("Open bookings", "1") }),
        new Item("Lisbon Walks", "Prepaid · no open bookings", new[] { ("Contact", "M. Butterworth"), ("Terms", "Prepaid"), ("Open bookings", "0") }),
    },
    ["Settings"] = new[]
    {
        new Item("Company", "Razor Sharp Getaways · USD · fiscal year starts in July", new[] { ("Currency", "USD"), ("Fiscal year", "July"), ("Users", "12") }),
        new Item("Numbering", "Requests by destination code (LIS-####, KYO-####), invoices INV-####", new[] { ("Requests", "City code-####"), ("Invoices", "INV-####") }),
    },
};

private string _section = "Requests";

private Item _selected = _data["Requests"][1];

private void Go(string section) { _section = section; _selected = _data[section][0]; }
```

### Dashboard

```razor
@using Fx.ControlKit
@using Fx.ControlKit.Charts
@using Fx.ControlKit.Layout

@* .dash is the page-scoped ancestor that the stylesheet's ::deep rules need *@
<div class="dash">
<DashboardLayoutControl Columns="3" CellSpacing="@(new double[] { 12, 12 })" CellAspectRatio="0.35">
    <DashboardLayoutPanels>
        @foreach (var k in _kpis)
        {
            var t = _place[k.Key];
            <DashboardLayoutPanel @key="k.Key" Row="t.Row" Column="t.Col" SizeX="t.SizeX" SizeY="t.SizeY">
                <TooltipControl Text="@k.Detail" CssClass="tile-anchor" Placement="PopupPlacement.BottomStart">
                    <div class="tile @(_focus == k.Key ? "focused" : "")" @onclick="() => Toggle(k.Key)">
                        <CardControl Elevation="0" CssClass="dash-card"><ChartControl Type="ChartType.KpiCard" KpiValue="@k.Value" KpiLabel="@k.Label" KpiTrend="@k.Trend" Height="100px" /></CardControl>
                    </div>
                </TooltipControl>
            </DashboardLayoutPanel>
        }
        <DashboardLayoutPanel Row="ChartsRow" Column="0" SizeX="2" SizeY="3">
            <CardControl Elevation="0" CssClass="dash-card"><ChartControl Type="ChartType.Line" ColorPalette="@ChartPalette.Site" Title="Bookings by day" Height="200px" Series="_byDay" YAxis="@(new ChartAxis { Min = 0, Max = 10, TickCount = 6 })" /></CardControl>
        </DashboardLayoutPanel>
        <DashboardLayoutPanel Row="ChartsRow" Column="2" SizeY="3">
            <CardControl Elevation="0" CssClass="dash-card"><ChartControl Type="ChartType.Donut" ColorPalette="@ChartPalette.Site" Title="Bookings by destination" Height="200px" InnerRadius="0.5" Series="_byDestination" /></CardControl>
        </DashboardLayoutPanel>
    </DashboardLayoutPanels>
</DashboardLayoutControl>
</div>
<span class="result">@(_focus is null ? "Three KPI cards on rows 0–1, charts on rows 2–4." : $"{_kpis.First(k => k.Key == _focus).Label} spans the row; the others moved down.")</span>
```

### Grid stack

```razor
@using Fx.ControlKit
@using Fx.ControlKit.Layout

<ButtonGroupControl Items="_columnItems" Values="@(new[] { _columns.ToString() })" ValuesChanged="PickColumns" AriaLabel="Columns" />
<SwitchControl @bind-Checked="_wrapTags" Label="Wrap services" />
<div class="summary">
    <StackLayoutControl Orientation="FlexOrientation.Vertical" Gap="14px">
        <StackLayoutControl AlignItems="FlexAlignment.Center" Gap="8px">
            <h4>Lisbon Explorer</h4>
            @if (_held)
            {
                <BadgeControl Variant="BadgeVariant.Success" Text="Place held" />
            }
        </StackLayoutControl>
        <GridLayoutControl Columns="@GridColumns" Gap="12px 20px">
            @foreach (var (label, value) in Fields)
            {
                <div><span class="field-label">@label</span><span class="field-value">@value</span></div>
            }
            <GridLayoutItemControl ColumnSpan="_columns">
                <span class="field-label">Included</span>
                <StackLayoutControl Gap="6px" Wrap="_wrapTags" CssClass="tags">
                    @foreach (var service in _services)
                    {
                        <BadgeControl Variant="BadgeVariant.Light" Text="@service" />
                    }
                </StackLayoutControl>
            </GridLayoutItemControl>
        </GridLayoutControl>
        <StackLayoutControl Gap="8px" JustifyContent="FlexAlignment.End" Wrap="true" CssClass="actions">
            <ButtonControl CssClass="btn-sm" OnClick="NextSeason">Next season</ButtonControl>
            <ButtonControl CssClass="btn-sm btn-primary" OnClick="@(() => _held = !_held)">@(_held ? "Release the place" : "Hold a place")</ButtonControl>
        </StackLayoutControl>
    </StackLayoutControl>
</div>
<span class="result">Columns @GridColumns · wrap @(_wrapTags ? "on" : "off") · @_seasons[_season] departure, @(_held ? "place held" : "no place held")</span>
```

```csharp
// Grid and stack: the Lisbon Explorer package; the column buttons, the wrap switch and the two buttons change page state.
private static readonly string[] _seasons = { "Spring", "Summer", "Fall", "Winter" };
private static readonly string[] _services = { "Airport transfers", "Seven nights in a guesthouse", "Old-town walking tour", "Sintra day trip", "Fado evening with dinner", "City transport pass" };
private int _season, _columns = 3;
private bool _wrapTags = true, _held;
private string GridColumns => $"repeat({_columns},minmax(0,1fr))";
private (string Label, string Value)[] Fields => new[]
{
    ("Destination", "Lisbon, Portugal"),
    ("Region", "Southern Europe"),
    ("Nights", "7"),
    ("Season", _seasons[_season]),
    ("Group size", "Up to 12"),
    ("Departs", "Saturdays"),
};
private readonly SelectionItem[] _columnItems = { new("1", "1 column"), new("2", "2 columns"), new("3", "3 columns") };
private void PickColumns(IReadOnlyList<string> values) => _columns = int.Parse(values[0]);
private void NextSeason() => _season = (_season + 1) % _seasons.Length;
```

