Card
Surfaces for related content.
Usage
After the one-time setup, call the helper directly from ERB. No component import is needed.
<%= lc_card class: "w-full" do |card| %>
<%= card.header title: "Project notes", description: "Keep related content together." do %>
<%= lc_button "Edit", variant: :secondary, size: :sm %>
<% end %>
<%= card.content do %>
<%= lc_text "Notes, links and files for the launch." %>
<% end %>
<%= card.footer do %>
<%= lc_button "Archive", variant: :ghost %>
<%= lc_button "Share" %>
<% end %>
<% end %>
Examples
Default
Project notes
Keep related content together.
Notes, links and files for the launch.
<%= lc_card class: "w-full" do |card| %>
<%= card.header title: "Project notes", description: "Keep related content together." do %>
<%= lc_button "Edit", variant: :secondary, size: :sm %>
<% end %>
<%= card.content do %>
<%= lc_text "Notes, links and files for the launch." %>
<% end %>
<%= card.footer do %>
<%= lc_button "Archive", variant: :ghost %>
<%= lc_button "Share" %>
<% end %>
<% end %>
Compact
Compact card
Padding and gaps tighten together.
A compact summary.
<%= lc_card padding: :sm, class: "w-full" do |card| %>
<%= card.header title: "Compact card", description: "Padding and gaps tighten together." %>
<%= lc_text "A compact summary.", size: :small %>
<% end %>
Linked card
<%= lc_card href: "/components/card.html", class: "w-full" do |card| %>
<%= card.header title: "Design system", description: "Open the project." %>
<% end %>
Custom spacing
Welcome
Padding and the gaps between parts both follow --lc-inset.
<%= lc_card class: "w-full [--lc-inset:var(--spacing-section)]" do |card| %>
<%= card.header title: "Welcome", description: "Padding and the gaps between parts both follow --lc-inset." %>
<%= card.footer do %>
<%= lc_button "Get started" %>
<% end %>
<% end %>
Edge-to-edge content
-
Design system
Active
-
Marketing site
Draft
<%= lc_card padding: :none, class: "w-full" do %>
<ul class="m-0 list-none divide-y divide-border p-0">
<% [ [ "Design system", "Active" ], [ "Marketing site", "Draft" ] ].each do |name, status| %>
<li class="flex items-center justify-between gap-content p-inset">
<%= lc_text name %>
<%= lc_text status, size: :small, tone: :muted %>
</li>
<% end %>
</ul>
<% end %>
With form controls
Project settings
<%= lc_card class: "@container w-full" do |card| %>
<%= card.header title: "Project settings" %>
<%= card.content do %>
<%= lc_field label: "Project name", id: "example-5-name" do |field| %>
<%= lc_input name: "project[name]", value: "Design system", **field %>
<% end %>
<% end %>
<%= card.footer do %>
<%= lc_button "Save changes" %>
<% end %>
<% end %>
Validation feedback
<%= lc_card class: "w-full" do |card| %>
<%= card.content do %>
<%= lc_alert "Choose a unique project name.", tone: :destructive %>
<%= lc_field label: "Project name", id: "example-6-name", error: "This name is already taken." do |field| %>
<%= lc_input name: "project[name]", value: "Design system", **field %>
<% end %>
<% end %>
<% end %>
API reference
Helpers render semantic HTML and include their interaction wiring. Pass native attributes through class:, data:, aria: and the usual Rails options. Blocks use captured ERB content.
lc_card
lc_card(href: nil, interactive: false, padding: :md, as: :div, **attributes, &block)
| Input | Default | Values |
|---|---|---|
| href | nil | — |
| interactive | false | true · false |
| padding | :md | :none · :md · :sm |
| as | :div | — |
| attributes | {} | Native HTML attributes; class:, data: and aria: merge with defaults |
| block | Captured block | Captured Rails ERB content |
lc_card yields a builder, card, with these parts. Each part carries data-slot and merges class: and native attributes.
card.header
card.header(title: nil, description: nil, level: 3, **attributes, &actions)
| Input | Default | Values |
|---|---|---|
| title | nil | — |
| description | nil | — |
| level | 3 | — |
| attributes | {} | Native HTML attributes; class:, data: and aria: merge with defaults |
| actions | Captured block | Captured Rails ERB content |
card.title
card.title(content = nil, level: 3, **attributes, &block)
| Input | Default | Values |
|---|---|---|
| content | nil | — |
| level | 3 | — |
| attributes | {} | Native HTML attributes; class:, data: and aria: merge with defaults |
| block | Captured block | Captured Rails ERB content |
card.description
card.description(content = nil, **attributes, &block)
| Input | Default | Values |
|---|---|---|
| content | nil | — |
| attributes | {} | Native HTML attributes; class:, data: and aria: merge with defaults |
| block | Captured block | Captured Rails ERB content |
card.content
card.content(**attributes, &block)
| Input | Default | Values |
|---|---|---|
| attributes | {} | Native HTML attributes; class:, data: and aria: merge with defaults |
| block | Captured block | Captured Rails ERB content |
card.footer
| Input | Default | Values |
|---|---|---|
| attributes | {} | Native HTML attributes; class:, data: and aria: merge with defaults |
| block | Captured block | Captured Rails ERB content |
The examples also use lc_button, lc_text, lc_field, lc_input, and lc_alert. Each is documented on its own page.
Styling and extension
Use class: to merge utilities, native attributes for application behavior, and the theming guide for the shared palette. For custom markup, the advanced class helpers expose the same styles, including glass surfaces and class merging.