Card Title
Lorem ipsum dolor sit amet consectetur adipisicing elit. Autem fuga repellendus velit quasi facilis tempora id ab beatae, in a est placeat alias...
A flexible container for grouping and displaying related content or media elements.
Lorem ipsum dolor sit amet consectetur adipisicing elit. Autem fuga repellendus velit quasi facilis tempora id ab beatae, in a est placeat alias...
To create a card, you can use the New function as shown in the example at the top of this page, or alternatively, you can follow the Builder or Functional patterns. Be sure to follow the anatomy defined above.
New function
@card.New(props ...*Props)props - A pointer to the card.Props struct that defines the configuration options for the card (see here).import "github.com/indaco/hansui/components/card"
@card.New() {
@card.CardBody() {
@card.CardTitle("Card Title")
@card.CardContent() {
<p>Lorem ipsum dolor sit amet consectetur...</p>
}
}
}The Builder pattern creates an instance using method chaining. The With methods, such as WithColor or WithBorderStyle, are chainable configuration functions that allow you to customize various properties of the component:
@card.Builder().WithResponsive(true).Render() {
@card.CardImage("https://picsum.photos/seed/picsum/200/200", "Dummy Image")
@card.CardBody() {
@card.CardTitle("Card Title")
@card.CardContent() {
<p>Lorem ipsum dolor sit amet consectetur...</p>
}
}
}The Functional pattern applies configurations through individual function calls before rendering the button. Like in the Builder pattern, With methods customize the component by setting specific properties:
@card.Render(card.WithResponsive(true)) {
@card.CardImage("https://picsum.photos/seed/picsum/200/200", "Dummy Image")
@card.CardBody() {
@card.CardTitle("Card Title")
@card.CardContent() {
<p>Lorem ipsum dolor sit amet consectetur...</p>
}
}
}Below is a list of each struct field, along with its type, default value, and allowed values where applicable.
Variant Specifies the style variant of the card.
stringoutline, light, lifted, stacked, cyberpunk, brutalist, retroResponsive If true, the card will adjust its layout based on the screen size for a more responsive design.
boolfalseHoverEffects Defines the hover effects applied to the card.
card.HoverEffectsShadow
If true, a shadow effect will be applied when the card is hovered.
Translate
If true, a translate effect will be applied when the card is hovered.
Attrs Additional HTML attributes for the accordion element. Allows you to set custom attributes such as data attributes, ARIA roles or others.
templ.AttributesPlacement Specifies the placement of the actions relative to the card content (e.g., top, bottom, left, right).
stringstartstart, endShape Defines the shape of the actions' buttons or links.
stringroundedbox, roundedItems An array of actions that are available in the card.
[]card.ActionLabel The text label for the action button or link.
stringHref The URL for the action if rendered as a link.
stringAttrs Additional HTML attributes for the button. Allows you to set custom attributes such as data attributes, ARIA roles or others.
templ.Attributes