Card

Card component for displaying grouped content.

Card Title Card subtitle

This is the body content of the card.

Usage

<%= ui.card do %>
  <%= ui.card_body do %>
    Simple card content
  <% end %>
<% end %>

<%= ui.card do %>
  <%= ui.card_header do %>
    <%= ui.card_title "Title" %>
  <% end %>
  <%= ui.card_body do %>
    Card with header and body
  <% end %>
<% end %>
SubcomponentsUse subcomponents below or any HTML.
NameHelperDescription
card_headerui.card_headerHeader section of the card with flexible layout options.
card_titleui.card_titleStyled title element for the card header.
card_subtitleui.card_subtitleSecondary text with muted styling for the card header.
card_bodyui.card_bodyMain content area of the card.
card_footerui.card_footerFooter section of the card with flexible layout options.

Examples

Basic Card

Card Title Card Subtitle

This is the body content of the card.

<%= ui.card do %>
  <%= ui.card_header do %>
    <%= ui.card_title "Card Title" %>
    <%= ui.card_subtitle "Card Subtitle" %>
  <% end %>
  <%= ui.card_body do %>
    <p>This is the body content of the card.</p>
  <% end %>
  <%= ui.card_footer do %>
    <%= ui.btn "Action" %>
  <% end %>
<% end %>

Card without borders

Centered Title

Card content goes here...

<%= ui.card do %>
  <%= ui.card_header align: :center, bordered: false do %>
    <%= ui.card_title "Centered Title" %>
  <% end %>
  <%= ui.card_body do %>
    <p>Card content goes here...</p>
  <% end %>
  <%= ui.card_footer justify: :end, bordered: false do %>
    <%= ui.btn "Action", variant: :secondary %>
  <% end %>
<% end %>

Header with Row Direction

Title

Card content goes here...

<%= ui.card do %>
  <%= ui.card_header direction: :row, justify: :between do %>
    <%= ui.card_title "Title" %>
    <%= ui.btn "Action", size: :sm %>
  <% end %>
  <%= ui.card_body do %>
    <p>Card content goes here...</p>
  <% end %>
<% end %>

Body Only Card

Welcome!

Thank you for joining our community.

<%= ui.card do %>
  <%= ui.card_body class: "flex flex-col gap-3 text-center" do %>
    <%= ui.icon "information-circle", class: "mx-auto text-primary size-12" %>
    <h3 class="text-lg font-semibold">Welcome!</h3>
    <p class="text-muted-foreground">Thank you for joining our community.</p>
    <%= ui.btn "Get Started", block: true, size: :lg %>
  <% end %>
<% end %>