defmodule PyrauiWeb.DocsLive.TableDocs do use PyrauiWeb, :html def render(assigns) do team_rows = [ %{ name: "Lena Moore", title: "Product Manager", location: "Berlin, DE", status: "Active", email: "lena@pyraui.dev" }, %{ name: "Marcus Reed", title: "Design Lead", location: "Austin, US", status: "Onboarding", email: "marcus@pyraui.dev" }, %{ name: "Aiko Fujita", title: "Senior Engineer", location: "Tokyo, JP", status: "Active", email: "aiko@pyraui.dev" }, %{ name: "Gabriel Khan", title: "Data Scientist", location: "Singapore", status: "Out of office", email: "gabriel@pyraui.dev" } ] metrics_rows = [ %{service: "Realtime", sla: "99.95%", incidents: 1, trend: "+0.3%"}, %{service: "Auth", sla: "99.99%", incidents: 0, trend: "+0.1%"}, %{service: "Billing", sla: "99.70%", incidents: 3, trend: "-0.4%"}, %{service: "Storage", sla: "99.80%", incidents: 2, trend: "-0.2%"} ] billing_rows = [ %{ customer: %{name: "Zeno Analytics", avatar: "ZA"}, plan: "Enterprise", mrr: "$12,400", renewal: "Apr 18", health: :good }, %{ customer: %{name: "Northwind Labs", avatar: "NL"}, plan: "Growth", mrr: "$4,120", renewal: "May 3", health: :watch }, %{ customer: %{name: "Arcade", avatar: "AR"}, plan: "Startup", mrr: "$1,640", renewal: "Jun 12", health: :risk } ] assigns = assigns |> assign(:team_rows, team_rows) |> assign(:metrics_rows, metrics_rows) |> assign(:billing_rows, billing_rows) ~H"""
Table Data Grids

Table

Responsive data tables with density, striping, and variant options. Use slots to compose rich cells with avatars, badges, and inline actions.

Elevated Directory

An elevated table with relaxed spacing—ideal for team directories and account overviews.

Variant: elevated
<:col :let={row} label="Member">
{row.name} {row.title}
<:col label="Location" field={:location} /> <:col :let={row} label="Status"> {row.status} <:col label="Email" align={:right} field={:email} />

Outlined + Striped

Outlined variant with compact density and zebra striping—great for operational metrics.

Variant: outlined · Striping on
<:col label="Service" field={:service} /> <:col label="SLA" align={:center} field={:sla} /> <:col :let={row} label="Incidents" align={:center}> {row.incidents} <:col :let={row} label="Trend" align={:right}> {row.trend}

Minimal with Rich Cells

Compose cells with avatars, badges, and CTA buttons while keeping the layout minimal.

Variant: minimal · Density: normal
<:col :let={row} label="Customer">
{row.customer.avatar}
{row.customer.name} {row.plan} plan
<:col label="MRR" align={:center} field={:mrr} /> <:col label="Renewal" align={:center} field={:renewal} /> <:col :let={row} label="Health" align={:right}> {health_label(row.health)}
    
    <.table rows={@rows} variant={:outlined} density={:compact} striped>
      <:col label="Service" field={:service} />
      <:col label="Trend" align={:right} :let={row}>
        <span class={trend_class(row.trend)}>{row.trend}</span>
      </:col>
    </.table>
    
            
""" end defp badge_variant(status) do case String.downcase(status) do "active" -> :success "onboarding" -> :info "out of office" -> :warning _ -> :neutral end end defp trend_class(trend) do if String.starts_with?(trend, "+") do "font-semibold text-emerald-600" else "font-semibold text-rose-600" end end defp health_variant(:good), do: :success defp health_variant(:watch), do: :warning defp health_variant(:risk), do: :error defp health_variant(_), do: :neutral defp health_label(:good), do: "Healthy" defp health_label(:watch), do: "Monitor" defp health_label(:risk), do: "At risk" defp health_label(_), do: "Unknown" end