Class: Panda::Core::UI::Card

Inherits:
Base
  • Object
show all
Defined in:
app/components/panda/core/UI/card.rb

Overview

Card component for containing related content.

Cards are flexible containers that can hold any content, with optional padding, shadows, and border variations.

Examples:

Basic card

render Panda::Core::UI::Card.new do
  "Card content here"
end

Card with header and footer

render Panda::Core::UI::Card.new(padding: :large) do |card|
  card.with_header { h3 { "Card Title" } }
  card.with_body { p { "Main content" } }
  card.with_footer { "Footer content" }
end

Elevated card with no padding

render Panda::Core::UI::Card.new(
  elevation: :high,
  padding: :none
) do
  img(src: "/image.jpg", alt: "Card image")
end

Constant Summary

Constants inherited from Base

Base::TAILWIND_MERGER

Instance Method Summary collapse

Methods inherited from Base

#after_template, #attrs, #before_template, #merge_attrs, #tailwind_merge_attrs

Instance Method Details

#default_attrsObject



40
41
42
43
44
# File 'app/components/panda/core/UI/card.rb', line 40

def default_attrs
  {
    class: card_classes
  }
end

#view_template(&block) ⇒ Object



36
37
38
# File 'app/components/panda/core/UI/card.rb', line 36

def view_template(&block)
  div(**@attrs, &block)
end