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 Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(padding: :medium, elevation: :low, border: true, **attrs) ⇒ Card

Returns a new instance of Card.



32
33
34
35
36
37
# File 'app/components/panda/core/UI/card.rb', line 32

def initialize(padding: :medium, elevation: :low, border: true, **attrs)
  @padding = padding
  @elevation = elevation
  @border = border
  super(**attrs)
end

Instance Attribute Details

#borderObject (readonly)

Returns the value of attribute border.



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

def border
  @border
end

#elevationObject (readonly)

Returns the value of attribute elevation.



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

def elevation
  @elevation
end

#paddingObject (readonly)

Returns the value of attribute padding.



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

def padding
  @padding
end

Instance Method Details

#default_attrsObject



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

def default_attrs
  {
    class: card_classes
  }
end