Table

Renders a table with generic styling.

Read more Read less

Examples

<.table id="users" rows={@users}>
  <:col :let={user} label="id">{user.id}</:col>
  <:col :let={user} label="username">{user.username}</:col>
</.table>
IDFirst nameLast nameCity
1
Jean
Dupont
Paris
2
Sam
Smith
NY
Attribute Type Documentation Default Value
Required id * :string
Required rows * :list
row_id :any

the function for generating the row id

row_click :any

the function for handling phx-click on each row

row_item :any

the function for mapping each row before calling the :col and :action slots

&Function.identity/1
Required col * :slot
Show slot attributes Hide slot attributes
label :string

the column header label

<:col :let={user} label="ID">
  <%= user.id %>
</:col>
<:col :let={user} label="First name">
  <%= user.first_name %>
</:col>
<:col :let={user} label="Last name">
  <%= user.last_name %>
</:col>
<:col :let={user} label="City">
  <%= user.city %>
</:col>
action :slot

the slot for showing user actions in the last table column