Cards ​

The card component provides a set of classes to group related content, such as an image, title, and description, in one place.

Base classes ​

Inside a .card, use .card-image for the image and .card-content for the text and actions. Inside .card-content, put the main text in .card-body. You can add a .card-header above it for a title styled with .card-title, and a .card-footer below it for a follow-up action or extra details.

Layouts ​

By default, the image sits above the content. Add .bottom to put it below, or use .top to explicitly place it above.

Add .horizontal to put the image to the left of the content. You can also use .left or .right alongside .horizontal to choose a side. The .inverse modifier puts the image below the content on a vertical card or to the right on a horizontal card.

Horizontal cards in narrow containers ​

Use .container-type-inline on a wrapper to let the card respond to the space inside it. By default, horizontal cards stack vertically in containers up to 767px wide. The image moves above the content unless you add .bottom or .inverse.

Variants ​

By default, no theme variants are generated.

If you are compiling your own version of Graupl, you can set the card module’s $themeable variable to true to generate the .primary, .secondary, and .tertiary variants.

Custom Properties ​

The following custom properties can be used to customize the card component:

PropertyDescriptionDefault Value
--graupl-card-padding-xThe horizontal padding of the card.var(--graupl-spacer-0)
--graupl-card-padding-yThe vertical padding of the card.var(--graupl-spacer-0)
--graupl-card-paddingThe padding of the card.var(--graupl-card-padding-y) var(--graupl-card-padding-x)
--graupl-card-transitionThe transition of the card.transform var(--graupl-transition-duration-fast) var(--graupl-transition-timing-function)
--graupl-card-transition-reduced-motionThe card transition when reduced motion is enabled.none
--graupl-card-transformThe transform of the card.none
--graupl-card-hover-transformThe hover transform of the card.none
--graupl-card-column-gapThe column gap of the card.var(--graupl-spacer-0)
--graupl-card-row-gapThe row gap of the card.var(--graupl-spacer-0)
--graupl-card-gapThe gap between rows and columns in the card.var(--graupl-card-row-gap) var(--graupl-card-column-gap)
--graupl-card-backgroundThe background of the card.var(--graupl-background)
--graupl-card-colorThe text color of the card. Typography inside the card inherits it by default.var(--graupl-color)
--graupl-card-border-colorThe border color of the card.var(--graupl-card-color)
--graupl-card-border-top-left-radiusThe border top left radius of the card.var(--graupl-border-top-left-radius)
--graupl-card-border-top-right-radiusThe border top right radius of the card.var(--graupl-border-top-right-radius)
--graupl-card-border-bottom-right-radiusThe border bottom right radius of the card.var(--graupl-border-bottom-right-radius)
--graupl-card-border-bottom-left-radiusThe border bottom left radius of the card.var(--graupl-border-bottom-left-radius)
--graupl-card-border-radiusThe border radius of the card.var(--graupl-card-border-top-left-radius) var(--graupl-card-border-top-right-radius) var(--graupl-card-border-bottom-right-radius) var(--graupl-card-border-bottom-left-radius)
--graupl-card-border-top-widthThe border top width of the card.var(--graupl-border-top-width)
--graupl-card-border-right-widthThe border right width of the card.var(--graupl-border-right-width)
--graupl-card-border-bottom-widthThe border bottom width of the card.var(--graupl-border-bottom-width)
--graupl-card-border-left-widthThe border left width of the card.var(--graupl-border-left-width)
--graupl-card-border-widthThe border width of the card.var(--graupl-card-border-top-width) var(--graupl-card-border-right-width) var(--graupl-card-border-bottom-width) var(--graupl-card-border-left-width)
--graupl-card-border-top-styleThe border top style of the card.var(--graupl-border-top-style)
--graupl-card-border-right-styleThe border right style of the card.var(--graupl-border-right-style)
--graupl-card-border-bottom-styleThe border bottom style of the card.var(--graupl-border-bottom-style)
--graupl-card-border-left-styleThe border left style of the card.var(--graupl-border-left-style)
--graupl-card-border-styleThe border style of the card.var(--graupl-card-border-top-style) var(--graupl-card-border-right-style) var(--graupl-card-border-bottom-style) var(--graupl-card-border-left-style)
--graupl-card-image-ratioThe size of the image track in a vertical card.auto
--graupl-horizontal-card-image-ratioThe size of the image track in a horizontal card.2fr
--graupl-card-image-padding-xThe horizontal padding of the card image.var(--graupl-spacer-0)
--graupl-card-image-padding-yThe vertical padding of the card image.var(--graupl-spacer-0)
--graupl-card-image-paddingThe padding of the card image.var(--graupl-card-image-padding-y) var(--graupl-card-image-padding-x)
--graupl-card-content-ratioThe size of the content track in a vertical card.1fr
--graupl-horizontal-card-content-ratioThe size of the content track in a horizontal card.3fr
--graupl-card-content-padding-xThe horizontal padding of the card content.var(--graupl-spacer-5)
--graupl-card-content-padding-yThe vertical padding of the card content.var(--graupl-spacer-3)
--graupl-card-content-paddingThe padding of the card content.var(--graupl-card-content-padding-y) var(--graupl-card-content-padding-x)
--graupl-card-content-column-gapThe column gap of the card content.var(--graupl-spacer-0)
--graupl-card-content-row-gapThe row gap of the card content.var(--graupl-spacer-3)
--graupl-card-content-gapThe gap between rows and columns in the card content.var(--graupl-card-content-row-gap) var(--graupl-card-content-column-gap)
--graupl-card-header-padding-xThe horizontal padding of the card header.0
--graupl-card-header-padding-yThe vertical padding of the card header.0
--graupl-card-header-paddingThe padding of the card header.var(--graupl-card-header-padding-y) var(--graupl-card-header-padding-x)
--graupl-card-body-padding-xThe horizontal padding of the card body.0
--graupl-card-body-padding-yThe vertical padding of the card body.0
--graupl-card-body-paddingThe padding of the card body.var(--graupl-card-body-padding-y) var(--graupl-card-body-padding-x)
--graupl-card-footer-padding-xThe horizontal padding of the card footer.0
--graupl-card-footer-padding-yThe vertical padding of the card footer.0
--graupl-card-footer-paddingThe padding of the card footer.var(--graupl-card-footer-padding-y) var(--graupl-card-footer-padding-x)
--graupl-card-title-colorThe color of the card title.var(--graupl-card-color)
--graupl-card-title-font-sizeThe font size of the card title.var(--graupl-h4-font-size)
--graupl-card-title-font-weightThe font weight of the card title.var(--graupl-h4-font-weight)
--graupl-card-title-font-familyThe font family of the card title.var(--graupl-h4-font-family)
--graupl-card-title-line-heightThe line height of the card title.var(--graupl-h4-line-height)

Sass variables ​

The following Sass variables can be used to customize the generation of the card component:

VariableDescriptionDefault Value
$selector-baseThe selector base for the component."."
$modifier-selector-baseThe selector base for component modifiers."."
$generate-base-theme-mapWhether to include the default card theme mappings.true
$themeableWhether to generate theme variants for cards.false
$force-vertical-cardsWhether to stack horizontal cards in narrow containers.true
$card-selector-baseThe selector base for the card."."
$card-selectorThe selector for the card."card"
$card-theme-selector-baseThe selector base for card theme variants."."
$card-theme-selector-prefixThe selector prefix for card theme variants.""
$card-image-selector-baseThe selector base for the card image."."
$card-image-selectorThe selector for the card image."card-image"
$card-image-element-selector-baseThe selector base for the image inside the card image wrapper.""
$card-image-element-selectorThe selector for the image inside the card image wrapper."img"
$card-content-selector-baseThe selector base for the card content."."
$card-content-selectorThe selector for the card content."card-content"
$card-body-selector-baseThe selector base for the card body."."
$card-body-selectorThe selector for the card body."card-body"
$card-header-selector-baseThe selector base for the card header."."
$card-header-selectorThe selector for the card header."card-header"
$card-footer-selector-baseThe selector base for the card footer."."
$card-footer-selectorThe selector for the card footer."card-footer"
$card-title-selector-baseThe selector base for the card title."."
$card-title-selectorThe selector for the card title."card-title"
$horizontal-card-selector-baseThe selector base for the horizontal card."."
$horizontal-card-selectorThe selector for the horizontal card."horizontal"
$horizontal-card-left-selector-baseThe selector base for the horizontal card left."."
$horizontal-card-left-selectorThe selector for the horizontal card left."left"
$horizontal-card-right-selector-baseThe selector base for the horizontal card right."."
$horizontal-card-right-selectorThe selector for the horizontal card right."right"
$vertical-card-top-selector-baseThe selector base for the vertical card top."."
$vertical-card-top-selectorThe selector for the vertical card top."top"
$vertical-card-bottom-selector-baseThe selector base for the vertical card bottom."."
$vertical-card-bottom-selectorThe selector for the vertical card bottom."bottom"
$inverse-card-selector-baseThe selector base for the inverse card."."
$inverse-card-selectorThe selector for the inverse card."inverse"
$card-transformThe default transform of the card.none
$card-hover-transformThe transform of the card on hover.none
$card-content-ratioThe default size of the content track in a vertical card.1fr
$card-image-ratioThe default size of the image track in a vertical card.auto
$horizontal-card-content-ratioThe default size of the content track in a horizontal card.3fr
$horizontal-card-image-ratioThe default size of the image track in a horizontal card.2fr
$card-theme-mappingsMap of card properties and their theme shades.map.merge($-card-theme-mappings, $card-theme-mappings)
$card-theme-mapMap of CSS custom property values for each card variant.map.deep-merge($-card-theme-map, $card-theme-map)