PureAdmin.Components.Table (PureAdmin v1.1.0)

Copy Markdown View Source

Table components for Pure Admin.

Provides table/1, table_responsive/1, table_container/1, and table_card/1.

Summary

Functions

Renders a data table with Pure Admin BEM classes.

Renders a card wrapper for tables with header, footer, and color variants.

Wraps a table in a bordered container with scroll support.

Wraps a table in a responsive scrolling container.

Functions

table(assigns)

Renders a data table with Pure Admin BEM classes.

Accepts rows and column definitions via slots, following Phoenix conventions.

Examples

<.table rows={@users} is_striped is_hover>
  <:col :let={user} label="Name"><%= user.name %></:col>
  <:col :let={user} label="Email"><%= user.email %></:col>
  <:action :let={user}>
    <.button variant="primary" size="xs">Edit</.button>
  </:action>
</.table>

Attributes

  • id (:string) - Defaults to nil.
  • rows (:list) (required) - List of row data.
  • row_id (:any) - Function to generate row id from row data. Defaults to nil.
  • row_click (:any) - JS command for row click. Defaults to nil.
  • is_striped (:boolean) - Alternating row colors. Defaults to false.
  • is_hover (:boolean) - Hover effect on rows. Defaults to false.
  • is_bordered (:boolean) - Full cell borders on all sides. Defaults to false.
  • is_borderless (:boolean) - Remove all cell borders. Defaults to false.
  • is_compact (:boolean) - Compact table (reduced padding). Defaults to false.
  • is_responsive (:boolean) - Wrap in responsive scrolling container. Defaults to false.
  • is_responsive_grid (:boolean) - CSS Grid responsive collapse on mobile. Defaults to false.
  • size (:string) - Defaults to nil.Must be one of nil, "xs", "sm", "lg", or "xl".
  • class (:string) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • col (required) - Column definitions. Accepts attributes:
    • label (:string) (required)
    • class (:string)
    • col_class (:string) - Class for th/td (e.g. col-auto).
    • align (:string) - Text alignment (start, center, end).
  • action - Action column. Accepts attributes:
    • label (:string)
    • class (:string)
  • foot - Table footer rows (tfoot content).

table_card(assigns)

Renders a card wrapper for tables with header, footer, and color variants.

Examples

<.table_card title_text="Recent Orders">
  <.table rows={@orders}>
    <:col :let={o} label="Order"><%= o.id %></:col>
    <:col :let={o} label="Total"><%= o.total %></:col>
  </.table>
</.table_card>

<.table_card title_text="Sales" variant="primary" is_scrollable>
  <:actions><.button size="sm">Export</.button></:actions>
  <.table rows={@data}>...</.table>
  <:footer><.pager page={@page} total_pages={@total_pages} /></:footer>
</.table_card>

Attributes

  • title_text (:string) - Card title. Defaults to nil.
  • variant (:string) - Semantic color variant for header accent. Defaults to nil. Must be one of nil, "primary", "success", "warning", or "danger".
  • color (:string) - Theme color 1-9. Defaults to nil. Must be one of nil, "1", "2", "3", "4", "5", "6", "7", "8", or "9".
  • is_scrollable (:boolean) - Horizontal scrolling for wide tables. Defaults to false.
  • is_plain (:boolean) - Remove card styling (border, shadow, background). Defaults to false.
  • class (:string) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • header - Custom header content (overrides title_text).
  • actions - Header action buttons.
  • inner_block (required)
  • footer - Footer content (e.g. pagination).

table_container(assigns)

Wraps a table in a bordered container with scroll support.

Examples

<.table_container>
  <.table rows={@data}>...</.table>
</.table_container>

<.table_container is_panel title_text="Users">
  <:actions><.button size="sm">Export</.button></:actions>
  <.table rows={@data}>...</.table>
</.table_container>

Attributes

  • is_panel (:boolean) - Card-like panel styling with shadow. Defaults to false.
  • title_text (:string) - Header title (panel mode only). Defaults to nil.
  • class (:string) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • header - Custom header content (overrides title_text).
  • actions - Header action buttons (panel mode only).
  • inner_block (required)

table_responsive(assigns)

Wraps a table in a responsive scrolling container.

Examples

<.table_responsive>
  <.table rows={@data}>...</.table>
</.table_responsive>

Attributes

  • class (:string) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • inner_block (required)