View Source PetalComponents.Table (petal_components v1.9.2)

Summary

Functions

Renders a table with generic styling.

Attributes

  • class (:string) - CSS class. Defaults to "".
  • Global attributes are accepted. Supports all globals plus: ["colspan", "headers", "rowspan"].

Slots

  • inner_block

Attributes

  • class (:string) - CSS class. Defaults to "".
  • Global attributes are accepted. Supports all globals plus: ["colspan", "rowspan"].

Slots

  • inner_block

Attributes

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

Slots

  • inner_block

Attributes

  • class (:any) - CSS class. Defaults to "".
  • label (:string) - Adds a label your user, e.g name. Defaults to nil.
  • sub_label (:string) - Adds a sub-label your to your user, e.g title. Defaults to nil.
  • avatar_assigns (:map) - if using an avatar, this map will be passed to the avatar component as props. Defaults to nil.
  • Global attributes are accepted.

Functions

Renders a table with generic styling.

Examples

<.table id="users" rows={@users}>
  <:col :let={user} label="id"><%= user.id %></:col>
  <:col :let={user} label="username"><%= user.username %></:col>
  <:empty_state>No data here yet</:empty_state>
</.table>

Attributes

  • id (:string)
  • class (:string) - CSS class. Defaults to "".
  • rows (:list) - the list of rows to render. Defaults to [].
  • row_id (:any) - the function for generating the row id. Defaults to nil.
  • row_click (:any) - the function for handling phx-click on each row. Defaults to nil.
  • row_item (:any) - the function for mapping each row before calling the :col slot. Defaults to &Function.identity/1.
  • Global attributes are accepted. Supports all globals plus: ["colspan", "rowspan"].

Slots

  • col - Accepts attributes:
    • label (:string)
    • class (:string)
    • row_class (:string)
  • empty_state - A message to show when the table is empty, to be used together with :col. Accepts attributes:
    • row_class (:string)

Attributes

  • class (:string) - CSS class. Defaults to "".
  • Global attributes are accepted. Supports all globals plus: ["colspan", "headers", "rowspan"].

Slots

  • inner_block

Attributes

  • class (:string) - CSS class. Defaults to "".
  • Global attributes are accepted. Supports all globals plus: ["colspan", "rowspan"].

Slots

  • inner_block

Attributes

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

Slots

  • inner_block

Attributes

  • class (:any) - CSS class. Defaults to "".
  • label (:string) - Adds a label your user, e.g name. Defaults to nil.
  • sub_label (:string) - Adds a sub-label your to your user, e.g title. Defaults to nil.
  • avatar_assigns (:map) - if using an avatar, this map will be passed to the avatar component as props. Defaults to nil.
  • Global attributes are accepted.