- Accordion
- Alert
- Avatar PRO
- Avatar Group PRO
- Badge
- Blank Slate PRO
- Breadcrumb
- Breakpoint Debug PRO
- Button
- Button Group
- Callout PRO
- Card
- Carousel
- Close Button
- Container
- Copy to Clipboard PRO
- Divider PRO
- Dropdown
- Errors PRO
- Feed PRO
- Flash PRO
- Form Field PRO
- Header PRO
- Heading
- Heading with Anchor PRO
- List Group
- Modal
- Nav
- Navbar
- Offcanvas
- Pagination
- Pricing Panel PRO
- Progress
- Progress Circular PRO
- Rating Group PRO
- Ribbon PRO
- Spinner
- Stat PRO
- Stepper PRO
- Table
- Table of Contents PRO
- Team Member PRO
- Testimonial PRO
- Toast
Card
Description
The Card component provides a flexible container for organizing and displaying various types of content.
Arguments
Name | Default | Type | Description |
---|---|---|---|
html_attributes
|
{}
|
Hash
|
Any attributes for the used html wrapper tag |
Examples
Default
<%= render Railsboot::CardComponent.new do |card| %>
<% card.with_body.with_content("This is the card body") %>
<% end %>
<div class="card">
<div class="card-body">This is the card body</div>
</div>
With header
<%= render Railsboot::CardComponent.new do |card| %>
<% card.with_header.with_content("This is the card header") %>
<% card.with_body.with_content("This is the card body") %>
<% end %>
<div class="card">
<div class="card-header">This is the card header</div>
<div class="card-body">This is the card body</div>
</div>
With footer
With list groups
<%= render Railsboot::CardComponent.new do |card| %>
<% card.with_header.with_content("This is the card with a list group") %>
<% card.with_list_group do |list_group| %>
<% list_group.with_item.with_content("List Group Item 1") %>
<% list_group.with_item.with_content("List Group Item 2") %>
<% list_group.with_item.with_content("List Group Item 3") %>
<% end %>
<% end %>
<div class="card">
<div class="card-header">This is the card with a list group</div>
<ul class="list-group list-group-flush">
<li class="list-group-item">List Group Item 1</li>
<li class="list-group-item">List Group Item 2</li>
<li class="list-group-item">List Group Item 3</li>
</ul>
</div>
Slots
Railsboot::Card::HeaderComponent
A header slot defines the header area of the card with any arbitrary content inside.
Name | Default | Type | Description |
---|---|---|---|
html_attributes
|
{}
|
Hash
|
Any attributes for the used html wrapper tag |
Railsboot::Card::BodyComponent
A body slot defines the body area of the card with any arbitrary content inside.
Name | Default | Type | Description |
---|---|---|---|
html_attributes
|
{}
|
Hash
|
Any attributes for the used html wrapper tag |
Railsboot::ListGroupComponent
A list_group slot displays list data with an auto-flush of the parent element.
Name | Default | Type | Description |
---|---|---|---|
html_attributes
|
{}
|
Hash
|
Any attributes for the used html wrapper tag |
Railsboot::Card::FooterComponent
A footer slot defines the footer area of the card with any arbitrary content inside.
Name | Default | Type | Description |
---|---|---|---|
html_attributes
|
{}
|
Hash
|
Any attributes for the used html wrapper tag |
Installation
Simply download this component with all its related files and assets. Unpackage the downloaded ZIP-file, copy all relevant files into your app and adapt the things you need. The ZIP-folder contains:
- A parent component class (
app/components/railsboot/component.rb
) of which all components inherit from. - A base component class (
app/components/railsboot/base_component.rb
) which is used for rendering internally. - The desired component itself (
app/components/railsboot/card_component.rb
). - A view template (
app/components/railsboot/card_component.html.erb
) for the component unless it's rendered inline. - Any other dependent components such as Slots (just if the component needs those)
- Any dependent assets (JS-Files, CSS-Files) (just if the component needs those)
- A test file for the components (
test/components/railsboot/card_component_test.rb
) including potential slot or dependency tests.
For more information please refer to the installation section.