# SbTable
A simple table component for displaying data with `TItem` and `Items`, without the advanced features of SbDataGrid.
## Parameters
| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| TItem | (generic) | - | Item type for data and row template |
| Items | IEnumerable<TItem>? | null | Data items to render |
| Striped | bool | false | Whether to show striped rows |
| Hover | bool | true | Whether rows highlight on hover |
| Bordered | bool | false | Whether to show borders |
| Compact | bool | false | Whether to use compact spacing |
| OnRowClick | EventCallback<TItem> | - | Callback when a row is clicked |
| Class | string? | null | Additional CSS classes |
## Templates / Slots (RenderFragments)
| Slot | Type | Description |
|------|------|-------------|
| HeaderContent | RenderFragment | Table header (e.g. `
| ... |
`) |
| RowTemplate | RenderFragment<TItem> | Row content; receives the item as `context` |
| FooterContent | RenderFragment? | Optional table footer |
| EmptyContent | RenderFragment? | Content when `Items` is null or empty |
## Usage
Bind a list and define the header and row template:
```razor
| Name |
Category |
Price |
@context.Name |
@context.Category |
$@context.Price.ToString("N2") |
```
## CSS Classes
- `sb-table` - Base class
- `sb-table--striped` - Striped rows
- `sb-table--hover` - Hoverable rows
- `sb-table--bordered` - Bordered style
- `sb-table--compact` - Compact spacing
## Examples
### Basic Table
```razor
| Name |
Category |
Price |
Stock |
@context.Name |
@context.Category |
$@context.Price.ToString("N2") |
@context.Stock |
```
### Striped Table
```razor
| Name |
Category |
Price |
@context.Name |
@context.Category |
$@context.Price.ToString("N2") |
```
### Bordered Table
```razor
| Name |
Category |
Price |
@context.Name |
@context.Category |
$@context.Price.ToString("N2") |
```
### Compact Table
```razor
| Name |
Category |
Price |
@context.Name |
@context.Category |
$@context.Price.ToString("N2") |
```
### Empty State
When `Items` is null or empty, use `EmptyContent` to show a message:
```razor
| Name |
Category |
Price |
@context.Name |
@context.Category |
$@context.Price.ToString("N2") |
```
### Clickable Rows
Use `OnRowClick` to handle row clicks:
```razor
| Name |
Category |
Price |
@context.Name |
@context.Category |
$@context.Price.ToString("N2") |
Clicked: @(_clickedProduct?.Name ?? "(none)")
```
### With Footer
Use `FooterContent` for a footer row (e.g. totals):
```razor
| Name |
Price |
@context.Name |
$@context.Price.ToString("N2") |
| Total |
@_products.Sum(p => p.Price).ToString("N2") |
```