Packages
mishka_chelekom
0.0.9
0.0.10-alpha.5
0.0.10-alpha.4
0.0.10-alpha.3
0.0.10-alpha.2
0.0.10-alpha.1
0.0.9
0.0.9-rc.2
0.0.9-rc.1
0.0.9-beta.5
0.0.9-beta.4
0.0.9-beta.3
0.0.9-beta.2
0.0.9-beta.1
0.0.9-alpha.20
0.0.9-alpha.18
0.0.9-alpha.17
0.0.9-alpha.16
0.0.9-alpha.15
0.0.9-alpha.14
0.0.9-alpha.13
0.0.9-alpha.12
0.0.9-alpha.11
0.0.9-alpha.10
0.0.9-alpha.9
0.0.9-alpha.8
0.0.9-alpha.7
0.0.9-alpha.6
0.0.9-alpha.5
0.0.9-alpha.4
0.0.9-alpha.3
0.0.9-alpha.2
0.0.9-alpha.1
0.0.8
0.0.8-rc.2
0.0.8-rc.1
0.0.8-beta.5
0.0.8-beta.4
0.0.8-beta.3
0.0.8-beta.2
0.0.8-beta.1
0.0.8-alpha.4
0.0.8-alpha.3
0.0.8-alpha.2
0.0.8-alpha.1
0.0.7
0.0.6
0.0.6-alpha.2
0.0.6-alpha.1
0.0.5
0.0.5-beta.2
0.0.5-beta.1
0.0.5-alpha.12
0.0.5-alpha.11
0.0.5-alpha.10
0.0.5-alpha.9
0.0.5-alpha.8
0.0.5-alpha.7
0.0.5-alpha.6
0.0.5-alpha.5
0.0.5-alpha.4
0.0.5-alpha.3
0.0.5-alpha.2
0.0.5-alpha.1
0.0.4
0.0.4-beta.3
0.0.4-beta.2
0.0.4-beta.1
0.0.4-alpha.9
0.0.4-alpha.8
0.0.4-alpha.7
0.0.4-alpha.6
0.0.4-alpha.5
0.0.4-alpha.4
0.0.4-alpha.3
0.0.4-alpha.2
0.0.4-alpha.1
0.0.3
0.0.3-alpha.3
0.0.3-alpha.2
0.0.3-alpha.1
0.0.2
0.0.2-rc.2
0.0.2-rc.1
0.0.2-beta.4
0.0.2-beta.3
0.0.2-beta.2
0.0.2-beta.1
0.0.2-alpha.3
0.0.2-alpha.2
0.0.2-alpha.1
0.0.1
Mishka Chelekom is a fully featured components and UI kit library for Phoenix & Phoenix LiveView
Current section
Files
Jump to
Current section
Files
usage-rules/components/table.md
# Table Component
Customizable data table with headers, rows, and cells.
**Documentation**: https://mishka.tools/chelekom/docs/table
> **For LLM Agents**: If you need more details, examples, or edge cases not covered here, fetch the full documentation from the URL above.
## Generate
```bash
mix mishka.ui.gen.component table
```
## Dependencies
| Type | Components |
|------|------------|
| **Necessary** | `icon` |
| **Optional** | None |
| **JavaScript** | None |
## Component Types
| Component | Description |
|-----------|-------------|
| `table/1` | Table container |
| `th/1` | Table header cell |
| `tr/1` | Table row |
| `td/1` | Table data cell |
## `table/1` Attributes
| Attribute | Type | Default | Description |
|-----------|------|---------|-------------|
| `variant` | `:string` | `"base"` | Style variant — see options below |
| `color` | `:string` | `"base"` | Color theme — see options below |
| `padding` | `:string` | `"small"` | Cell padding — see options below |
| `rounded` | `:string` | `"medium"` | Border radius |
| `text_position` | `:string` | `"left"` | Text alignment |
| `border` | `:string` | `nil` | Border style |
| `fixed` | `:boolean` | `false` | Fixed table layout |
## Slots
| Slot | Description |
|------|-------------|
| `header` | Table header cells |
| `footer` | Table footer content |
## Available Options
- **Variants**: `base`, `outline`, `default`, `shadow`, `bordered`, `transparent`, `hoverable`, `stripped`, `separated`
- **Colors**: `base`, `natural`, `white`, `primary`, `secondary`, `dark`, `success`, `warning`, `danger`, `info`, `misc`, `dawn`, `silver`
- **Padding**: `extra_small`, `small`, `medium`, `large`, `extra_large`
## Usage Examples
### Basic Table
```heex
<.table>
<:header>Name</:header>
<:header>Email</:header>
<:header>Role</:header>
<.tr :for={user <- @users}>
<.td>{user.name}</.td>
<.td>{user.email}</.td>
<.td>{user.role}</.td>
</.tr>
</.table>
```
### Variant, Color & Padding
```heex
<.table variant="stripped">
<:header>Product</:header>
<:header>Price</:header>
<.tr :for={product <- @products}>
<.td>{product.name}</.td>
<.td>${product.price}</.td>
</.tr>
</.table>
<.table variant="hoverable">
<:header>Name</:header>
<:header>Status</:header>
<.tr :for={user <- @users}>
<.td>{user.name}</.td>
<.td><.badge color={status_color(user.status)}>{user.status}</.badge></.td>
</.tr>
</.table>
<.table variant="bordered" color="natural" padding="large">
<:header>Column 1</:header>
<:header>Column 2</:header>
<.tr>
<.td>Cell 1</.td>
<.td>Cell 2</.td>
</.tr>
</.table>
```
### With Footer
```heex
<.table>
<:header>Item</:header>
<:header>Qty</:header>
<:header>Price</:header>
<.tr :for={item <- @items}>
<.td>{item.name}</.td>
<.td>{item.qty}</.td>
<.td>${item.price}</.td>
</.tr>
<:footer>
<.tr>
<.td colspan="2" class="font-bold">Total</.td>
<.td class="font-bold">${@total}</.td>
</.tr>
</:footer>
</.table>
```
### Fixed Layout
```heex
<.table fixed class="w-full">
<:header>Name</:header>
<:header>Description</:header>
<:header>Actions</:header>
<.tr :for={item <- @items}>
<.td class="w-1/4">{item.name}</.td>
<.td class="w-2/4 truncate">{item.description}</.td>
<.td class="w-1/4">
<.button size="small">Edit</.button>
</.td>
</.tr>
</.table>
```
## Common Patterns
### Data Table with Actions
```heex
<.table variant="hoverable">
<:header>Name</:header>
<:header>Email</:header>
<:header>Status</:header>
<:header>Actions</:header>
<.tr :for={user <- @users}>
<.td>
<div class="flex items-center gap-2">
<.avatar src={user.avatar} size="small" />
<span>{user.name}</span>
</div>
</.td>
<.td>{user.email}</.td>
<.td><.badge color={status_color(user.status)}>{user.status}</.badge></.td>
<.td>
<div class="flex gap-2">
<.button size="small" variant="outline">Edit</.button>
<.button size="small" variant="outline" color="danger">Delete</.button>
</div>
</.td>
</.tr>
</.table>
```
### Sortable Headers
```heex
<.table>
<:header>
<button phx-click="sort" phx-value-field="name" class="flex items-center gap-1">
Name
<.icon name="hero-chevron-up-down" class="size-4" />
</button>
</:header>
<:header>
<button phx-click="sort" phx-value-field="date" class="flex items-center gap-1">
Date
<.icon name="hero-chevron-up-down" class="size-4" />
</button>
</:header>
<.tr :for={item <- @sorted_items}>
<.td>{item.name}</.td>
<.td>{item.date}</.td>
</.tr>
</.table>
```
### Empty State
```heex
<.table>
<:header>Name</:header>
<:header>Email</:header>
<.tr :if={@users == []}>
<.td colspan="2" class="text-center py-8 text-gray-500">
No users found
</.td>
</.tr>
<.tr :for={user <- @users}>
<.td>{user.name}</.td>
<.td>{user.email}</.td>
</.tr>
</.table>
```