Shadwire

Search the documentation

Search the documentation and component pages by title and by content.

Get started
Introduction
Installation
shadwire.json
Theming
Dark mode
Tools
CLI
Agent skill
Registry
llms.txt
Guides
Composition
Styling
Forms
Icons
Accessibility
Localisation
Blocks
Overview
Components
Overview
Accordion
Alert
Alert Dialog
Aspect Ratio
Avatar
Badge
Breadcrumb
Button
Button Group
Calendar
Card
Carousel
Chart
Checkbox
Collapsible
Combobox
Command
Context Menu
Data Table
Date Picker
Dialog
Drawer
Dropdown Menu
Empty
Field
Hover Card
Icon
Input
Input Group
Input OTP
Item
Kbd
Label
Menubar
Native Select
Navigation Menu
Pagination
Popover
Progress
Radio Group
Resizable
Scroll Area
Select
Separator
Sheet
Sidebar
Skeleton
Slider
Sonner
Spinner
Switch
Table
Tabs
Textarea
Toggle
Toggle Group
Tooltip

Card

A bordered surface for grouping related content.

Installation

Shadwire follows shadcn/ui's open code model: the component's source is copied into your application and becomes yours. Install it with the CLI:

shadwire add card --yes

The card registry item installs these files:

  • app/components/ui_component.rb
  • app/components/ui/card_component.rb
  • app/components/ui/card/header_component.rb
  • app/components/ui/card/title_component.rb
  • app/components/ui/card/description_component.rb
  • app/components/ui/card/content_component.rb
  • app/components/ui/card/footer_component.rb
  • app/helpers/ui/card_helper.rb
  • vendor/shadwire/shadwire.css

Haven't installed the CLI yet? gem install shadwire, then shadwire init.

Usage

<%= ui_card do %>
  <%= ui_card_header do %>
    <%= ui_card_title { "Create project" } %>
    <%= ui_card_description { "Deploy your new project in one click." } %>
  <% end %>
  <%= ui_card_content { "Card content." } %>
<% end %>

Or render the components directly:

<%= render Ui::CardComponent.new do %>
  <%= render Ui::Card::HeaderComponent.new do %>
    <%= render Ui::Card::TitleComponent.new do %>
      Create project
    <% end %>
  <% end %>
<% end %>

Composition

Card
|-- Card::Header
|   |-- Card::Title
|   `-- Card::Description
|-- Card::Content
`-- Card::Footer

Examples

Default

Compose header, title, description, content and footer inside the card.

Create project

Set the name, the visibility, and who joins at the start.

Use cards to group related content and actions.

<%= ui_card(class: "max-w-sm", data: { slot: "card" }) do %>
  <%= ui_card_header(data: { slot: "card-header" }) do %>
    <%= ui_card_title(data: { slot: "card-title" }) { "Create project" } %>
    <%= ui_card_description(data: { slot: "card-description" }) do %>
      Set the name, the visibility, and who joins at the start.
    <% end %>
  <% end %>
  <%= ui_card_content(data: { slot: "card-content" }) do %>

API reference

Available helpers: ui_card, ui_card_header, ui_card_title, ui_card_description, ui_card_content and ui_card_footer.

API Element Description
ui_carddivThe container: border, card surface and shadow.
ui_card_headerdivThe top area, with vertical spacing.
ui_card_titleh3The title; tag: picks the heading level (tag_name:, its old name, still works).
ui_card_descriptionpSupporting text in muted foreground.
ui_card_contentdivThe main content.
ui_card_footerdivBottom actions or metadata.