Table

Compound component for structured tabular data with semantic HTML.

Overview

The Table component is a compound component that renders semantic HTML tables. Each sub-component (TableHeader, TableBody, TableRow, TableHead, TableCell) accepts ChildContent and an optional Class parameter merged via Shell.Cn().

Installation

bash
shellui add table

Usage

Basic Table

Name Email Role
John Doe john@example.com Admin
Jane Smith jane@example.com User
<Table>
  <TableHeader>
    <TableRow>
      <TableHead>Name</TableHead>
      <TableHead>Email</TableHead>
      <TableHead>Role</TableHead>
    </TableRow>
  </TableHeader>
  <TableBody>
    <TableRow>
      <TableCell>John Doe</TableCell>
      <TableCell>john@example.com</TableCell>
      <TableCell>Admin</TableCell>
    </TableRow>
    <TableRow>
      <TableCell>Jane Smith</TableCell>
      <TableCell>jane@example.com</TableCell>
      <TableCell>User</TableCell>
    </TableRow>
  </TableBody>
</Table>

Dynamic Data

Name Email Role
Alice Johnson alice@example.com
Admin
Bob Wilson bob@example.com
User
<Table>
  <TableHeader>
    <TableRow>
      <TableHead>Name</TableHead>
      <TableHead>Email</TableHead>
      <TableHead>Role</TableHead>
    </TableRow>
  </TableHeader>
  <TableBody>
    @foreach (var user in users)
    {
      <TableRow>
        <TableCell>@user.Name</TableCell>
        <TableCell>@user.Email</TableCell>
        <TableCell>
          <Badge Variant="BadgeVariant.Secondary">@user.Role</Badge>
        </TableCell>
      </TableRow>
    }
  </TableBody>
</Table>

@code {
    private List<UserModel> users = new()
    {
        new() { Name = "Alice Johnson", Email = "alice@example.com", Role = "Admin" },
        new() { Name = "Bob Wilson",    Email = "bob@example.com",   Role = "User" }
    };

    private class UserModel
    {
        public string Name { get; set; } = "";
        public string Email { get; set; } = "";
        public string Role { get; set; } = "";
    }
}

Table with Actions

Name Status Actions
Alice Johnson
Active
<Table Class="w-full">
  <TableHeader>
    <TableRow>
      <TableHead>Name</TableHead>
      <TableHead>Status</TableHead>
      <TableHead Class="text-right">Actions</TableHead>
    </TableRow>
  </TableHeader>
  <TableBody>
    <TableRow>
      <TableCell>Alice Johnson</TableCell>
      <TableCell><Badge>Active</Badge></TableCell>
      <TableCell Class="text-right">
        <Button Variant="ButtonVariant.Outline" Size="ButtonSize.Sm">Edit</Button>
      </TableCell>
    </TableRow>
  </TableBody>
</Table>

Responsive Wrapper

<div class="overflow-x-auto">
  <Table>
    <!-- wide table content -->
  </Table>
</div>

API Reference

Table

Parameter Type Default Description
ChildContent RenderFragment — Table header and body
Class string? null Additional CSS classes

TableHeader

Parameter Type Default Description
ChildContent RenderFragment — Header rows
Class string? null Additional CSS classes

TableBody

Parameter Type Default Description
ChildContent RenderFragment — Data rows
Class string? null Additional CSS classes

TableRow

Parameter Type Default Description
ChildContent RenderFragment — Cells within the row
Class string? null Additional CSS classes

TableHead

Parameter Type Default Description
ChildContent RenderFragment — Header cell content
Class string? null Additional CSS classes

TableCell

Parameter Type Default Description
ChildContent RenderFragment — Data cell content
Class string? null Additional CSS classes

Accessibility

  • Renders semantic <table>, <thead>, <tbody>, <tr>, <th>, and <td> elements.
  • Screen readers can navigate by row and column.
  • Use <TableHead> for column headers so assistive technology identifies them correctly.

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.