Skip to content
IzzyBlazor

Enter all results ↑ ↓ move Esc close

Kanban

Since 0.1.0-alpha.24
Shows cards in columns, such as tasks by status or deals by stage, and lets people move them between columns.

A board of cards in columns, such as tasks by status or deals by stage. Each KanbanColumn shows the cards whose ColumnOf is its Value, under a header with the column's title and how many cards it holds.

A board

Use a board for work that moves through stages, such as tasks by status. Put a KanbanColumn in Columns for each stage, and return each card's column from ColumnOf.

Static

Preview

To do

Cards: 2
  • Write the release notes
    Ada Lovelace
    Move to
  • Record the demo video
    Alan Turing
    Move to
Drop items here No items

In progress

Cards: 2
  • Update the pricing page
    Grace Hopper
    Move to
  • Email the beta list
    Ada Lovelace
    Move to
Drop items here No items

Done

Cards: 1
  • Set the launch date
    Grace Hopper
    Move to
Drop items here No items

Code

Usage.razor
@* A column for each status: Value is the status as the data stores it, Title what the header
   shows. ColumnOf says which column a task is in. OnMove gives a moved task its
   new status, which is where an app saves it. *@
<Stack Grow>
    <Kanban TItem="LaunchTask" @bind-Items="_tasks" ItemKey="t => t.Id" ColumnOf="t => t.Status" ItemText="t => t.Title" ItemDescription="t => t.Owner"
            OnMove="Moved" Label="Launch tasks">
        <Columns>
            <KanbanColumn Value="todo" Title="To do" />
            <KanbanColumn Value="doing" Title="In progress" />
            <KanbanColumn Value="done" Title="Done" />
        </Columns>
    </Kanban>
</Stack>

@code {
    private IReadOnlyList<LaunchTask> _tasks =
    [
        new("1", "Write the release notes", "Ada Lovelace", "todo"),
        new("2", "Record the demo video", "Alan Turing", "todo"),
        new("3", "Update the pricing page", "Grace Hopper", "doing"),
        new("4", "Email the beta list", "Ada Lovelace", "doing"),
        new("5", "Set the launch date", "Grace Hopper", "done"),
    ];

    // Where an app saves the move.
    private void Moved(KanbanMoveEventArgs<LaunchTask> move) => move.Item.Status = move.ToColumn;
}

Static: Drag a card into another column, or use its menu: the card moves, the counts change, and the board posts the move.

Add this example to a page with the izzy CLI:

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

A column's Value is what ColumnOf returns for its cards, as your data stores it. Title is what its header shows; without one, the header shows the Value.

OnMove runs with each move, with FromColumn and ToColumn. Save the card's new column there, or set Cancel to keep it where it was. It runs on static pages too, where the board posts a form of its own after each move, so don't put the board inside another form.

@bind-Items gives you the cards in their new order after a move. It hands back the same card objects, so change a card in place in OnMove. If your cards are records you replace, leave @bind-Items out and place the new card yourself from ToColumn and ToIndex.

When a page has more than one board, give each its own QueryPrefix.

Each card's ⋯ menu has the same moves as dragging, so the board works without a pointer.

ColumnWidth sets the narrowest a column gets before the board scrolls sideways. MaxHeight sets the tallest a column's cards get before they scroll under its header.

Cards and totals

To draw the cards yourself, set CardTemplate. ItemLabel names each card for screen readers, and ItemHref makes it a link.

Static

Preview

Discovery

Cards: 2
$21,500
  • Mobile app audit

    Mobile app audit

    Initech

    $6,500

    Close Dec 18

    MR
    Move to
  • Analytics dashboard

    Analytics dashboard

    Umbrella Health

    $15,000

    Close Jan 9

    PS
    Move to
Drop items here No items

Qualified

Cards: 2
$21,500
  • Brand refresh

    Brand refresh

    Globex

    $9,500

    Close Dec 12

    JD
    Move to
  • Checkout rebuild

    Checkout rebuild

    Stark Outfitters

    $12,000

    Close Dec 20

    MR
    Move to
Drop items here No items

Proposal

Cards: 1
$18,000
  • Website redesign

    Website redesign

    Acme Co.

    $18,000

    Close Nov 27

    JD
    Move to
Drop items here No items

Negotiation

Cards: 1
$12,000
  • Annual support plan

    Annual support plan

    Northwind

    $12,000

    Close Dec 4

    PS
    Move to
Drop items here No items

Code

Cards.razor
@* A sales pipeline: CardTemplate draws each deal, ItemLabel names it for screen readers, and
   ColumnSummary totals each stage. *@
<Stack Grow>
    <Kanban TItem="Deal" @bind-Items="_deals" ItemKey="d => d.Id" ColumnOf="d => d.Stage" ItemLabel="d => d.Name" ItemHref="@(_ => "#")"
            ColumnSummary="@(deals => deals.Sum(d => d.Value).ToString("C0"))" AddHref="@(_ => "#")"
            OnMove="Moved" QueryPrefix="deals-" Size="ControlSize.Sm" ColumnWidth="Length.Rem(14)" Label="Deal pipeline" Context="deal">
        <Columns>
            <KanbanColumn Value="Discovery" />
            <KanbanColumn Value="Qualified" />
            <KanbanColumn Value="Proposal" />
            <KanbanColumn Value="Negotiation" />
        </Columns>
        <CardTemplate>
            <Stack Gap="2">
                <Stack Gap="0">
                    <TextBlock Size="TextSize.Sm" Weight="FontWeight.Medium">@deal.Name</TextBlock>
                    <TextBlock Size="TextSize.Sm" Color="Color.Muted">@deal.Company</TextBlock>
                </Stack>
                <Row Gap="2" Align="Align.Center">
                    <TextBlock Size="TextSize.Sm" Weight="FontWeight.Medium">@deal.Value.ToString("C0")</TextBlock>
                    <TextBlock Size="TextSize.Xs" Color="Color.Muted">Close @deal.Close</TextBlock>
                    <Spacer />
                    <Avatar Name="@deal.Owner" Size="AvatarSize.Xs" />
                </Row>
            </Stack>
        </CardTemplate>
    </Kanban>
</Stack>

@code {
    private IReadOnlyList<Deal> _deals =
    [
        new("1", "Website redesign", "Acme Co.", 18000, "Nov 27", "Jamie Davis", "Proposal"),
        new("2", "Annual support plan", "Northwind", 12000, "Dec 4", "Priya Shah", "Negotiation"),
        new("3", "Brand refresh", "Globex", 9500, "Dec 12", "Jamie Davis", "Qualified"),
        new("4", "Mobile app audit", "Initech", 6500, "Dec 18", "Marco Ruiz", "Discovery"),
        new("5", "Analytics dashboard", "Umbrella Health", 15000, "Jan 9", "Priya Shah", "Discovery"),
        new("6", "Checkout rebuild", "Stark Outfitters", 12000, "Dec 20", "Marco Ruiz", "Qualified"),
    ];

    // Where an app saves the move.
    private void Moved(KanbanMoveEventArgs<Deal> move) => move.Item.Stage = move.ToColumn;
}

ColumnSummary puts a figure from each column's cards under its header, such as a stage's total.

AddHref puts an add button in each column's header that goes to your page for a new card. On interactive pages, OnAdd runs instead.

ItemMenu adds your own items to each card's ⋯ menu, above the moves.

For people who may look but not change anything, set ReadOnly: cards don't move, and their links stay.

Limits

To show how much work a column should hold, set its Limit. The count reads "4 / 3" and changes color past it. MinItems does the same below a minimum.

Static

Preview

Open

Cards: 2
  • Invoices show the wrong tax rate
    High priority
    Move to
  • Add a CSV export to reports
    Low priority
    Move to
Drop items here No items

In progress

Cards: 3 of 3
  • Password reset email is slow
    Medium priority
    Move to
  • Dashboard times out on large accounts
    High priority
    Move to
  • Search misses accented names
    Medium priority
    Move to
Drop items here No items

Review

Cards: 0
    Drop items here No items

    Closed

    Cards: 1
    • Update the billing address form
      Low priority
      Move to
    Drop items here No items

    Code

    Limits.razor
    @* In progress should hold three tickets at most and Review at least one: the count changes color
       when a column is outside its numbers. ItemAccent marks each ticket's priority, which its second
       line also says. *@
    <Stack Grow>
        <Kanban TItem="Ticket" @bind-Items="_tickets" ItemKey="t => t.Id" ColumnOf="t => t.Status" ItemText="t => t.Title"
                ItemDescription="@(t => $"{t.Priority} priority")" ItemAccent="t => AccentOf(t.Priority)"
                OnMove="Moved" QueryPrefix="tickets-" Label="Support tickets">
            <Columns>
                <KanbanColumn Value="Open" />
                <KanbanColumn Value="In progress" Limit="3" />
                <KanbanColumn Value="Review" MinItems="1" />
                <KanbanColumn Value="Closed" />
            </Columns>
        </Kanban>
    </Stack>
    
    @code {
        private IReadOnlyList<Ticket> _tickets =
        [
            new("1", "Invoices show the wrong tax rate", "High", "Open"),
            new("2", "Add a CSV export to reports", "Low", "Open"),
            new("3", "Password reset email is slow", "Medium", "In progress"),
            new("4", "Dashboard times out on large accounts", "High", "In progress"),
            new("5", "Search misses accented names", "Medium", "In progress"),
            new("6", "Update the billing address form", "Low", "Closed"),
        ];
    
        private static Accent? AccentOf(string priority) => priority switch
        {
            "High" => Accent.Danger,
            "Medium" => Accent.Token("warning"),
            _ => null,
        };
    
        private void Moved(KanbanMoveEventArgs<Ticket> move) => move.Item.Status = move.ToColumn;
    }

    Limits are advisory: cards still move in. To refuse a card, set the column's Accepts, or cancel the move in OnMove.

    ItemAccent draws a colored line down a card's edge. Say what it means in the card's text too.

    Collapsing columns

    To let people fold away columns they aren't working in, set Collapsible. A collapsed column keeps its title and count.

    Static

    Preview

    New

    Cards: 2
    • Order #1042
      Maria Chen
      Move to
    • Order #1043
      Daniel Okafor
      Move to
    Drop items here No items

    Packing

    Cards: 1
    • Order #1039
      Sofia Rossi
      Move to
    Drop items here No items

    Shipped

    Cards: 2
    • Order #1036
      Liam Walker
      Move to
    • Order #1035
      Aiko Tanaka
      Move to
    Drop items here No items

    Code

    Collapse.razor
    @* Collapsible gives each column a button that folds it to a strip. Shipped starts collapsed. *@
    <Stack Grow>
        <Kanban TItem="ShopOrder" @bind-Items="_orders" ItemKey="o => o.Id" ColumnOf="o => o.Status" ItemText="o => o.Number" ItemDescription="o => o.Customer"
                Collapsible OnMove="Moved" QueryPrefix="orders-" Label="Orders">
            <Columns>
                <KanbanColumn Value="New" />
                <KanbanColumn Value="Packing" />
                <KanbanColumn Value="Shipped" Collapsed />
            </Columns>
        </Kanban>
    </Stack>
    
    @code {
        private IReadOnlyList<ShopOrder> _orders =
        [
            new("1", "Order #1042", "Maria Chen", "New"),
            new("2", "Order #1043", "Daniel Okafor", "New"),
            new("3", "Order #1039", "Sofia Rossi", "Packing"),
            new("4", "Order #1036", "Liam Walker", "Shipped"),
            new("5", "Order #1035", "Aiko Tanaka", "Shipped"),
        ];
    
        private void Moved(KanbanMoveEventArgs<ShopOrder> move) => move.Item.Status = move.ToColumn;
    }

    Collapsed starts a column collapsed, and @bind-Collapsed keeps the choice on interactive pages.

    A card dropped on a collapsed column goes to its end, and the card's menu still moves it there.

    Lanes

    To split the board into rows, such as by team or priority, return each card's lane from LaneOf and put a KanbanLane in Lanes for each one.

    Static

    Preview

    To do

    Cards: 3

    In progress

    Cards: 3 of 3

    Done

    Cards: 2

    Design

    Cards: 3
    • Onboarding screens
      Move to
    Drop items here No items
    • Icon set for settings
      Move to
    Drop items here No items
    • Billing page layout
      Move to
    Drop items here No items

    Engineering

    Cards: 3
    • Rate limiting for the API
      Move to
    Drop items here No items
    • Migrate to the new queue
      Move to
    • Fix the CSV import
      Move to
    Drop items here No items
      Drop items here No items

      Marketing

      Cards: 2
      • Launch email
        Move to
      Drop items here No items
        Drop items here No items
        • Pricing page copy
          Move to
        Drop items here No items

        Code

        Lanes.razor
        @* Work by team: LaneOf says which lane a task is in, and each KanbanLane is a row across the
           columns. A task dragged to another lane changes team as well as status. *@
        <Stack Grow>
            <Kanban TItem="TeamTask" @bind-Items="_tasks" ItemKey="t => t.Id" ColumnOf="t => t.Status" LaneOf="t => t.Team" ItemText="t => t.Title"
                    Collapsible OnMove="Moved" QueryPrefix="teams-" ColumnWidth="Length.Rem(14)" Size="ControlSize.Sm" Label="Work by team">
                <Columns>
                    <KanbanColumn Value="To do" />
                    <KanbanColumn Value="In progress" Limit="3" />
                    <KanbanColumn Value="Done" />
                </Columns>
                <Lanes>
                    <KanbanLane Value="Design" />
                    <KanbanLane Value="Engineering" />
                    <KanbanLane Value="Marketing" />
                </Lanes>
            </Kanban>
        </Stack>
        
        @code {
            private IReadOnlyList<TeamTask> _tasks =
            [
                new("1", "Onboarding screens", "Design", "To do"),
                new("2", "Icon set for settings", "Design", "In progress"),
                new("3", "Billing page layout", "Design", "Done"),
                new("4", "Rate limiting for the API", "Engineering", "To do"),
                new("5", "Migrate to the new queue", "Engineering", "In progress"),
                new("6", "Fix the CSV import", "Engineering", "In progress"),
                new("7", "Launch email", "Marketing", "To do"),
                new("8", "Pricing page copy", "Marketing", "Done"),
            ];
        
            // Where an app saves the move: the task's status and, across lanes, its team.
            private void Moved(KanbanMoveEventArgs<TeamTask> move) => (move.Item.Status, move.Item.Team) = (move.ToColumn, move.ToLane!);
        }

        A card moves between lanes as it does between columns. OnMove gets FromLane and ToLane with the columns.

        Each column's header counts its cards in every lane, and its Limit is for all of them. Each lane's header counts its own.

        With Collapsible, the lanes collapse instead of the columns.

        With OnSave, the card's form has a Lane field.

        Adding, editing and deleting cards

        To let people change the cards, handle OnSave. A card then opens a form in a dialog, its ⋯ menu has Edit, and each column's header has an add button.

        Static

        Preview

        New

        Cards: 2
        • Export invoices as PDF
          Export invoices as PDF
          Asked for by three accounting teams.
          Edit
          Move to
        • Dark mode for the mobile app
          Dark mode for the mobile app
          Edit
          Move to
        Drop items here No items

        Planned

        Cards: 2
        • Single sign-on with Okta
          Single sign-on with Okta
          Needed for the enterprise plan.
          Edit
          Move to
        • Bulk edit for contacts
          Bulk edit for contacts
          Edit
          Move to
        Drop items here No items

        Shipped

        Cards: 1
        • Weekly summary email
          Weekly summary email
          Sent on Mondays at 8:00.
          Edit
          Move to
        Drop items here No items

        Code

        Editing.razor
        @* Feature requests: open a card to change or delete it, or add one from a column's header. The
           page saves what the form sends, on a static page too. *@
        <Stack Grow>
            <Kanban TItem="Request" Items="Shown()" ItemsChanged="Arranged" ItemKey="r => r.Id.ToString()" ColumnOf="r => r.Status"
                    ItemText="r => r.Title" ItemDescription="r => r.Notes" OnSave="Save" OnDelete="Delete" OnMove="Moved"
                    QueryPrefix="requests-" Label="Feature requests">
                <Columns>
                    <KanbanColumn Value="New" />
                    <KanbanColumn Value="Planned" />
                    <KanbanColumn Value="Shipped" />
                </Columns>
            </Kanban>
        </Stack>
        
        @code {
            private sealed class Request
            {
                public int Id { get; set; }
                public string Title { get; set; } = "";
                public string? Notes { get; set; }
                public string Status { get; set; } = "New";
            }
        
            // An app keeps its cards in a database; this example keeps them in memory for everyone
            // reading the page, and starts again past 30 or when the last one is deleted.
            private static readonly List<Request> Store = Seed();
        
            // A copy to draw from, as someone else's save may change the list meanwhile.
            private static List<Request> Shown()
            {
                lock (Store)
                {
                    return [.. Store];
                }
            }
        
            // What anyone types shows to everyone, so it's kept short.
            private static string? Short(string? text, int length) => text is { Length: > 0 } ? text[..Math.Min(text.Length, length)] : text;
        
            private static List<Request> Seed() =>
            [
                new() { Id = 1, Title = "Export invoices as PDF", Notes = "Asked for by three accounting teams.", Status = "New" },
                new() { Id = 2, Title = "Dark mode for the mobile app", Status = "New" },
                new() { Id = 3, Title = "Single sign-on with Okta", Notes = "Needed for the enterprise plan.", Status = "Planned" },
                new() { Id = 4, Title = "Bulk edit for contacts", Status = "Planned" },
                new() { Id = 5, Title = "Weekly summary email", Notes = "Sent on Mondays at 8:00.", Status = "Shipped" },
            ];
        
            private void Save(KanbanSave<Request> save)
            {
                lock (Store)
                {
                    if (save.IsNew && Store.Count >= 30)
                    {
                        Store.Clear();
                        Store.AddRange(Seed());
                    }
        
                    var request = save.Item ?? new Request { Id = Store.Count == 0 ? 1 : Store.Max(r => r.Id) + 1 };
                    (request.Title, request.Notes, request.Status) = (Short(save.Title, 60)!, Short(save.Description, 140), save.Column);
                    if (save.IsNew)
                    {
                        Store.Add(request);
                    }
                }
            }
        
            private void Delete(KanbanDelete<Request> delete)
            {
                lock (Store)
                {
                    Store.Remove(delete.Item);
                    if (Store.Count == 0)
                    {
                        Store.AddRange(Seed());
                    }
                }
            }
        
            private void Moved(KanbanMoveEventArgs<Request> move) => move.Item.Status = move.ToColumn;
        
            // The cards in their new order, after a move.
            private void Arranged(IReadOnlyList<Request> requests)
            {
                lock (Store)
                {
                    var order = requests.ToList();
                    Store.Clear();
                    Store.AddRange(order);
                }
            }
        }

        The form has a title, the column and, when the board has an ItemDescription, a description. OnSave gets them with the card, or with no card for a new one (IsNew). Set them on your card and save it there.

        OnDelete adds a Delete button to the form, which asks first.

        To keep the form open with a message, call save.AddError.

        For the fields your own cards have, put your form in EditDialogForm. The board still opens and closes the dialog, and the context has the card and its column.

        The form opens from an address (?card=42), so it works on static pages, where it posts.

        Searching and sorting

        To let people find a card on a busy board, set Searchable. The box above the board shows only the cards whose text or description matches.

        SearchBy returns what a card is searched by, when that's more than its text. SearchLabel names the box.

        SortBy sorts each column's cards, here by due date, and SortDescending reverses it. A card moved to a column takes its sorted place.

        Each column's count is of the cards shown.

        On static pages the search is in the page's address and applies on Enter.

        Letting people change the columns

        To let people add, rename, delete and reorder columns, keep the columns in a list of your own, render Columns from it, and handle the four column events.

        Static

        Preview

        Inbox

        Cards: 2
        Edit
        • Referral credits
          Move to
        • Annual billing discount
          Move to
        Drop items here No items

        Exploring

        Cards: 1
        Edit
        • Team workspaces
          Move to
        Drop items here No items

        Decided

        Cards: 1
        Edit
        • Public roadmap
          Move to
        Drop items here No items

        Code

        ManageColumns.razor
        @* An ideas board whose columns are the team's to change: each column's ⋯ menu edits, moves or
           deletes it, and Add column makes another. The page keeps the columns in a list of its own and
           draws the board from it. *@
        <Stack Grow>
            <Kanban TItem="Idea" Items="Shown()" ItemsChanged="Arranged" ItemKey="i => i.Id" ColumnOf="i => i.Column" ItemText="i => i.Title" OnMove="Moved"
                    OnColumnAdd="AddColumn" OnColumnRename="RenameColumn" OnColumnDelete="DeleteColumn" OnColumnMove="MoveColumn"
                    QueryPrefix="ideas-" ColumnWidth="Length.Rem(13)" Label="Ideas">
                <Columns>
                    @foreach (var column in ShownStages())
                    {
                        <KanbanColumn Value="@column.Id" Title="@column.Title" />
                    }
                </Columns>
            </Kanban>
        </Stack>
        
        @code {
            private sealed class Stage
            {
                public string Id { get; set; } = "";
                public string Title { get; set; } = "";
            }
        
            private sealed class Idea(string id, string title, string column)
            {
                public string Id { get; } = id;
                public string Title { get; } = title;
                public string Column { get; set; } = column;
            }
        
            // An app keeps its columns and cards in a database; this example keeps them in memory for
            // everyone reading the page, and starts again past 6 columns.
            private static readonly List<Stage> Stages = SeedStages();
            private static readonly List<Idea> Ideas = SeedIdeas();
        
            // Copies to draw from, as someone else's change may alter the lists meanwhile.
            private static List<Idea> Shown()
            {
                lock (Stages)
                {
                    return [.. Ideas];
                }
            }
        
            private static List<Stage> ShownStages()
            {
                lock (Stages)
                {
                    return [.. Stages];
                }
            }
        
            // What anyone types shows to everyone, so it's kept short.
            private static string Short(string text) => text[..Math.Min(text.Length, 30)];
        
            private static List<Stage> SeedStages() =>
            [
                new() { Id = "inbox", Title = "Inbox" }, new() { Id = "exploring", Title = "Exploring" }, new() { Id = "decided", Title = "Decided" },
            ];
        
            private static List<Idea> SeedIdeas() =>
            [
                new("1", "Referral credits", "inbox"),
                new("2", "Annual billing discount", "inbox"),
                new("3", "Team workspaces", "exploring"),
                new("4", "Public roadmap", "decided"),
            ];
        
            private void AddColumn(KanbanColumnChange change)
            {
                lock (Stages)
                {
                    if (Stages.Count >= 6)
                    {
                        Stages.Clear();
                        Stages.AddRange(SeedStages());
                        Ideas.Clear();
                        Ideas.AddRange(SeedIdeas());
                    }
        
                    Stages.Add(new() { Id = Guid.NewGuid().ToString("N")[..8], Title = Short(change.Title) });
                }
            }
        
            private void RenameColumn(KanbanColumnChange change)
            {
                lock (Stages)
                {
                    if (Stages.Find(s => s.Id == change.Column) is { } stage)
                    {
                        stage.Title = Short(change.Title);
                    }
                }
            }
        
            // A column with cards stays: the form says why.
            private void DeleteColumn(KanbanColumnDelete delete)
            {
                lock (Stages)
                {
                    if (Ideas.Any(i => i.Column == delete.Column))
                    {
                        delete.AddError("Move this column's cards to another column first.");
                        return;
                    }
        
                    Stages.RemoveAll(s => s.Id == delete.Column);
                    if (Stages.Count == 0)
                    {
                        Stages.AddRange(SeedStages());
                    }
                }
            }
        
            private void MoveColumn(KanbanColumnMoveEventArgs move)
            {
                lock (Stages)
                {
                    if (Stages.Find(s => s.Id == move.Column) is { } stage)
                    {
                        Stages.Remove(stage);
                        Stages.Insert(Math.Clamp(move.ToIndex, 0, Stages.Count), stage);
                    }
                }
            }
        
            private void Moved(KanbanMoveEventArgs<Idea> move) => move.Item.Column = move.ToColumn;
        
            private void Arranged(IReadOnlyList<Idea> ideas)
            {
                lock (Stages)
                {
                    var order = ideas.ToList();
                    Ideas.Clear();
                    Ideas.AddRange(order);
                }
            }
        }

        OnColumnAdd puts an Add column button after the columns. It gets the title the user typed, and the new column's Value is yours to give.

        OnColumnRename and OnColumnDelete add Edit to each column's ⋯ menu, which opens a form with the title and a Delete button. To refuse a delete, such as a column that still has cards, call delete.AddError.

        OnColumnMove adds Move left and Move right. Put the column at ToIndex in your list.

        Each works on static pages too, where the menu and the form post.

        A project board

        A card opens beside the board on a click, and its ⋯ menu assigns and archives it. Every move saves, so the card's link shows the board as it was left.

        Preview

        Code

        Project.razor
        @* A team's board. A card drags from anywhere on it (a long press on touch) and opens beside the
           board on a click (ItemHref). Its ⋯ menu has Assign to me, Archive and the moves under Move. In
           progress should hold three at most. Every move saves in OnMove, on a static page too, so a
           card's link, which loads the page again, shows the board as it was left. The menu's own items
           post a form beside the board on a static page (form="board-actions"), as the board has its own. *@
        @inject NavigationManager Navigation
        @using Microsoft.AspNetCore.Http
        <AppShell>
            <AppHeader>
                <AppBrand Icon="Lucide.SquareKanban" Label="Acme Projects" />
                <Box Grow />
                <Avatar Name="@Me" />
            </AppHeader>
        
            <AppMain>
                <Stack Gap="5" Padding="new() { Base = 4, Md = 6 }">
                    <Form Model="this" FormName="kanban-project" OnValidSubmit="Acted" id="board-actions">
                        <Row Gap="3" Align="Align.Center" Wrap>
                            <Stack Gap="0">
                                <Heading Level="1" Size="TextSize.Xl2">Spring conference</Heading>
                                <TextBlock Size="TextSize.Sm" Color="Color.Muted">@_cards.Count cards · @_cards.Count(c => c.Column == "done") done</TextBlock>
                            </Stack>
                            <Spacer />
                            @if (_archived.Count > 0)
                            {
                                @if (RendererInfo.IsInteractive)
                                {
                                    <Button Variant="ButtonVariant.Ghost" Size="ControlSize.Sm" StartIcon="Lucide.ArchiveRestore" OnClick="RestoreAll">Restore @_archived.Count archived</Button>
                                }
                                else
                                {
                                    <Button Variant="ButtonVariant.Ghost" Size="ControlSize.Sm" StartIcon="Lucide.ArchiveRestore" Submit Name="act" Value="restore">Restore @_archived.Count archived</Button>
                                }
                            }
                            <AvatarGroup Label="Team" Size="AvatarSize.Sm">
                                @foreach (var name in Team)
                                {
                                    <Avatar Name="@name" />
                                }
                            </AvatarGroup>
                        </Row>
                    </Form>
        
                    <Kanban TItem="KanbanCard" Items="_cards" ItemsChanged="Arranged" ItemKey="c => c.Id" ColumnOf="c => c.Column" OnMove="Moved"
                            ItemLabel="c => c.Title" ItemHref="c => CardHref(c)" ItemCurrent="c => c.Id == Opened"
                            EmptyText="No cards" Size="ControlSize.Sm" ColumnWidth="Length.Rem(15)" MaxHeight="Length.Rem(20)" Label="Spring conference" TitleLevel="2" Context="card">
                        <Columns>
                            @foreach (var column in Columns)
                            {
                                <KanbanColumn @key="column.Id" Value="@column.Id" Title="@column.Name" Limit="column.Limit" />
                            }
                        </Columns>
                        <CardTemplate>
                            <Stack Gap="2">
                                <Tag Label="@card.Label" Status="StatusOf(card.Label)" Size="ControlSize.Sm" />
                                <TextBlock Size="TextSize.Sm" Weight="FontWeight.Medium">@card.Title</TextBlock>
                                <Row Gap="2" Align="Align.Center">
                                    <Icon Name="Lucide.Calendar" Size="IconSize.Sm" Color="Color.Muted" />
                                    <TextBlock Size="TextSize.Xs" Color="Color.Muted">@card.Due</TextBlock>
                                    <Spacer />
                                    <Avatar Name="@card.Owner" Size="AvatarSize.Xs" />
                                </Row>
                            </Stack>
                        </CardTemplate>
                        <ItemMenu>
                            <MenuItem Icon="Lucide.ExternalLink" Href="@CardHref(card)" target="_blank">Open in a new tab</MenuItem>
                            @if (RendererInfo.IsInteractive)
                            {
                                <MenuItem Icon="Lucide.UserCheck" Disabled="card.Owner == Me" OnClick="() => card.Owner = Me">Assign to me</MenuItem>
                                <MenuDivider />
                                <MenuItem Icon="Lucide.Archive" Accent="Accent.Danger" OnClick="() => Archive(card.Id)">Archive</MenuItem>
                            }
                            else
                            {
                                <MenuItem Icon="Lucide.UserCheck" Disabled="card.Owner == Me" Submit Name="act" Value="@($"assign:{card.Id}")" form="board-actions">Assign to me</MenuItem>
                                <MenuDivider />
                                <MenuItem Icon="Lucide.Archive" Accent="Accent.Danger" Submit Name="act" Value="@($"archive:{card.Id}")" form="board-actions">Archive</MenuItem>
                            }
                        </ItemMenu>
                    </Kanban>
                </Stack>
        
                <AppAside Width="Length.Rem(20)" Breakpoint="Breakpoint.Lg" SmallScreen="AsideSmallScreen.Below" Label="Card" Padding="new() { Base = 4, Md = 5 }">
                    @if (_cards.FirstOrDefault(c => c.Id == Opened) is { } shown)
                    {
                        <Stack Gap="4">
                            <Stack Gap="2" Align="Align.Start">
                                <Tag Label="@shown.Label" Status="StatusOf(shown.Label)" Size="ControlSize.Sm" />
                                <Heading Level="2" Size="TextSize.Lg">@shown.Title</Heading>
                            </Stack>
                            <DescriptionList>
                                <DescriptionItem Term="Column">@Columns.FirstOrDefault(c => c.Id == shown.Column)?.Name</DescriptionItem>
                                <DescriptionItem Term="Owner">@shown.Owner</DescriptionItem>
                                <DescriptionItem Term="Due">@shown.Due</DescriptionItem>
                            </DescriptionList>
                            <TextBlock Size="TextSize.Sm" Color="Color.Muted">@shown.Notes</TextBlock>
                        </Stack>
                    }
                    else
                    {
                        <TextBlock Size="TextSize.Sm" Color="Color.Muted">Choose a card to see it here.</TextBlock>
                    }
                </AppAside>
            </AppMain>
        </AppShell>
        
        @code {
            [SupplyParameterFromQuery(Name = "card")] private string? Opened { get; set; }
        
            // A menu item or button that posted: assign:{id}, archive:{id} or restore.
            [SupplyParameterFromForm(FormName = "kanban-project", Name = "act")]
            private string? Act { get; set; }
        
            private const string Me = "Grace Hopper";
        
            private string CardHref(KanbanCard card) => Navigation.GetUriWithQueryParameter("card", card.Id);
        
            // The card takes its new column here, where an app would save it.
            private void Moved(KanbanMoveEventArgs<KanbanCard> move) => move.Item.Column = move.ToColumn;
        
            // The cards in their new order, after a move.
            private void Arranged(IReadOnlyList<KanbanCard> cards)
            {
                _cards = cards;
                Store();
            }
        
            // A static page: a menu item or Restore posted its act.
            private void Acted()
            {
                switch (Act?.Split(':', 2))
                {
                    case ["assign", var id] when _cards.FirstOrDefault(c => c.Id == id) is { } card:
                        card.Owner = Me;
                        break;
                    case ["archive", var id]:
                        Archive(id);
                        break;
                    case ["restore"]:
                        RestoreAll();
                        break;
                }
        
                Store();
            }
        
            private void Archive(string id)
            {
                if (_cards.FirstOrDefault(c => c.Id == id) is { } card)
                {
                    _cards = _cards.Where(c => c != card).ToList();
                    _archived = [.. _archived, card];
                }
            }
        
            // Each archived card goes back to its column.
            private void RestoreAll()
            {
                _cards = [.. _cards, .. _archived];
                _archived = [];
            }
        
            private static Status StatusOf(string label) => label switch
            {
                "Design" => Status.Info,
                "Content" => Status.Success,
                "Venue" => Status.Warning,
                _ => Status.Neutral,
            };
        }

        Details

        A card drags to another place or column from anywhere on it, and its ⋯ menu has the same moves, with every column under "Move to". OnMove runs with each move, on a static page too, where the board posts a form of its own: save the card's new column there. Don't put the board inside another form.

        CardTemplate draws a card; without it ItemText and ItemDescription do. ItemHref makes a card a link and ItemMenu adds items to its ⋯ menu. The columns share the board's width, none narrower than ColumnWidth, and the board scrolls sideways when they don't fit. On a narrow board one column shows at a time with the next one's edge beside it.

        Parts

        Written inside Kanban. The API page lists their parameters.

        • KanbanColumn<TItem>: a column of a Kanban: the cards whose ColumnOf is its Value, under a header with its Title and how many cards it holds and, with the board's ColumnSummary, a figure from them below it.
        • KanbanLane: a lane of a Kanban<T>: a row across the board's columns holding the cards whose LaneOf is its Value, such as a team's or a priority's, under a header with its title and how many cards it holds.

        Mode support

        What works in each mode, Kanban
        FeatureStaticInteractive
        Moving cards from each card's menu (with JavaScript off, each move posts the form)YesYes
        Dragging cards and announcementsYesYes
        Collapsing columnsYesYes
        Adding, editing and deleting cards in a dialogYesYes
        Adding, renaming, deleting and reordering columnsYesYes
        Searching the cards (with JavaScript off or on a static page, on Enter)YesYes
        The moves bound to C#YesYes

        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.

        • Dragging cards and announcements: waits for the script
        • Collapsing columns: waits for the script

        Accessibility

        • The board is a group named by its Label. Each column is a region named by its title, which is a heading (TitleLevel, 3 by default), holding a list of its cards.
        • A column's count is read as "Cards: 3", or "Cards: 3 of 5" with a Limit.
        • Every card's ⋯ button is named "Actions for" and the card's label, and its menu moves the card, so nothing needs dragging.
        • A move is announced from the column it lands in: "Moved Budget to Done, position 1 of 3".
        • With Searchable, how many cards match is announced as the search changes: "Cards shown: 4".
        • The button that collapses a column is named by the column, as in "Review cards", and says whether the cards are shown.

        Keyboard navigation

        Kanban keys
        Press this keyTo do this
        TabGo through a card's controls in order
        Up or DownMove to the card above or below
        Alt+Up or Alt+Down or Alt+Home or Alt+EndOn a card's link or button, move the card
        Shift+F10 or MenuOpen the card's menu
        EscapeWhile dragging, cancel

        Parameters

        Kanban parameters
        PropTypeDefault
        @bind-ItemsEvery card, in every column; each column shows its own in this order.IEnumerable<TItem>?Required
        ItemKeyEach card's key: what posts and what keeps its elements when it moves.Func<TItem, string>?Required
        ColumnOfThe column a card is in, matching a KanbanColumn<T>'s Value, such as t => t.Status.Func<TItem, string>?Required
        EditDialogFormYour own form in the card's dialog, in place of the generated one, for the fields your cards have.RenderFragment<KanbanEditFormContext<TItem>>?
        ReadOnlyShows the board without letting anyone change it, such as to someone who may only look: cards don't move, and there's no form, add button or column menu.boolfalse
        SearchablePuts a search box above the board that shows only the cards matching what's typed, in their text and description or in SearchBy.boolfalse
        SearchLabelThe search box's label and placeholder.string?"Search"
        SearchByWhat a card is searched by, such as d => $"{d.Name} {d.Company}", in place of its text and description.Func<TItem, string?>?
        SortBySorts each column's cards, such as t => t.Due, in place of the order they're given in.Func<TItem, IComparable?>?
        SortDescendingWith SortBy, sorts from last to first.boolfalse
        QueryPrefixSets this board's posts and its keys in the page's address apart, so several can share a page: QueryPrefix="orders-" uses ?orders-card=42.string""
        ColumnsThe KanbanColumn<T>s, in the order shown.RenderFragment?
        LaneOfThe lane a card is in, matching a KanbanLane's Value, such as t => t.Team.Func<TItem, string>?
        LanesThe KanbanLanes, in the order shown, on a board with a LaneOf.RenderFragment?
        CardTemplateA card's content.RenderFragment<TItem>?
        ItemTextThe default card's text.Func<TItem, string?>?computed
        ItemDescriptionThe default card's muted second line.Func<TItem, string?>?
        ItemLabelNames a card for screen readers: in its link, its ⋯ button and the announcement of a move.Func<TItem, string>?computed
        ItemHrefMakes each card a link to this address; the whole card is clickable.Func<TItem, string?>?
        ItemCurrentMarks the card the page is showing, such as the one open beside the board.Func<TItem, bool>?
        ItemDisabledDims a card and keeps it where it is: it has no link and doesn't move.Func<TItem, bool>?
        ItemAccentA colored line down a card's edge, such as its priority's.Func<TItem, Accent?>?
        ItemMenuMenuItems for each card's ⋯ menu, above its moves.RenderFragment<TItem>?
        ColumnSummaryText under each column's header, from the column's cards, such as their total: cards => cards.Sum(d => d.Value).ToString("C0").Func<IReadOnlyList<TItem>, string?>?
        ColumnWidthThe narrowest a column gets before the board scrolls sideways.Length17rem
        MaxHeightThe tallest a column's cards get before they scroll under its header, such as Length.Vh(60).Length?
        CollapsibleGives each column a button that collapses it to a strip with its title and count.boolfalse
        AddHrefPuts an add button in each column's header that goes to this address, from the column's Value, such as the page that makes a card for that column.Func<string, string?>?
        EmptyTextWhat an empty column says.string?"Drop items here"
        DragHandleGives each card a handle to drag it by, in place of dragging from anywhere on it.boolfalse
        SizeThe cards' spacing and text size.ControlSizeControlSize.Md
        LabelNames the board for screen readers.string?"Board"
        TitleLevelThe heading level of the columns' titles, 2 to 6.int3
        OnMoveRuns with each move, before the board changes, on a static page too (the board posts): set the card's column from ToColumn and save it here, or set Cancel to keep the card where it was.EventCallback<KanbanMoveEventArgs<TItem>>
        OnSaveSaves a card from the board's form, new or changed, on a static page too (the form posts).EventCallback<KanbanSave<TItem>>
        OnDeleteDeletes a card: with it, the generated form has a Delete button.EventCallback<KanbanDelete<TItem>>
        OnColumnAddRuns when the user adds a column, on a static page too: with it, an Add column button after the columns opens a form for its title.EventCallback<KanbanColumnChange>
        OnColumnRenameRuns when the user renames a column: with it, each column's ⋯ menu has Edit, which opens a form for its title.EventCallback<KanbanColumnChange>
        OnColumnDeleteRuns when the user deletes a column: with it, the column's form has a Delete button, which asks first.EventCallback<KanbanColumnDelete>
        OnColumnMoveRuns when the user moves a column: with it, each column's ⋯ menu has Move left and Move right.EventCallback<KanbanColumnMoveEventArgs>
        OnItemClickMakes each card a button that runs this, on interactive pages.EventCallback<TItem>
        OnAddPuts an add button in each column's header that runs this with the column's Value, on interactive pages.EventCallback<string>

        See also

        • DropZoneGroup: moves items between lists you lay out yourself, such as available and chosen, by dragging or from each item's menu.
        • ListView: displays a list of items users can open, select, page through and reorder.

        Connection lost

        Rejoining the server…