Theme

npm_versionnpm Paragon package page

Card is a box of related content usually describing a single object. It can be composed of several subcomponents, we give full overview of those subcomponents below.

Card supports vertical and horizontal orientation which is controlled by CardContext, see examples below.

This component uses a Card from react-bootstrap as a base component and extends it with additional subcomponents.
See React-Bootstrap for additional documentation.

Basic Usage

Any Paragon component or export may be added to the code example.

Card variants

Use variant prop to use Card specific style variant.

Any Paragon component or export may be added to the code example.

Clickable card

You use isClickable prop to add additional hover and focus styling to the Card.

Any Paragon component or export may be added to the code example.

You can also use Card as a link by passing the value HyperLink (or a, Link) to the as property, note that Card will override the default link styling to make its content appear as regular text.

Any Paragon component or export may be added to the code example.

You may add a header by adding a Card.Header component. This header displays a title, subtitle, and may contain actions.

Any Paragon component or export may be added to the code example.

Actions

The Card.Header supports custom actions via the actions prop and renders them on the top right of the header.

Any Paragon component or export may be added to the code example.

Sizes

The Card.Header supports two size variants, "sm" and "md". Add size="sm" for smaller header content and actions.

Any Paragon component or export may be added to the code example.

Section

Card.Section is the main block to display card content. Can include its own title and actions separate from other card components. Multiple sections have a Card.Divider between them.

Any Paragon component or export may be added to the code example.

Card.Footer is the bottom part of the card. Usually used to outline actions that can be taken on the card object. Note that Card.Footer has a separate orientation prop which will override the value from CardContext, this was implemented because there are some use cases where you would want to display Card with horizontal orientation containing footer with vertical orientation.

Any Paragon component or export may be added to the code example.

Any Paragon component or export may be added to the code example.

With Image Cap

ImageCap is an image that sits on the top or the left edge of a Card. Can contain an optional logo image.

Any Paragon component or export may be added to the code example.

Horizontal variant

When using horizontal variant Paragon provides additional component Card.Body which acts as a wrapper for content you want to display between ImageCap and Footer. Use it if content contains multiple components.

Any Paragon component or export may be added to the code example.

Card status

Note that in the example below, the content of Card is wrapped inside Card.Body. The d-flex class is added for the horizontal orientation to achieve horizontal variant. The flex-column class is added for the main Card component.

An optional actions prop may be passed to include call-to-action button(s).

Any Paragon component or export may be added to the code example.

Card Content Block Empty

With image

Any Paragon component or export may be added to the code example.

Without image

Any Paragon component or export may be added to the code example.

Horizontal variant with image

Any Paragon component or export may be added to the code example.

Horizontal variant without image

Any Paragon component or export may be added to the code example.

Fallback Image

With Fallback custom Image

You can specify fallbackSrc image to show in case your main src fails to load. A fallback source is available for both the main ImageCap component image and the logo.

Any Paragon component or export may be added to the code example.

With default Fallback Image

The default fallback image will be displayed if fallbackSrc is not specified.

Any Paragon component or export may be added to the code example.

With loading state

Vertical variant

Any Paragon component or export may be added to the code example.

Horizontal variant

Any Paragon component or export may be added to the code example.

CardGrid

This component displays a collection of Cards as a grid (with customizable responsive behavior), where all cards in a given row have equal height. Try shrinking the width of your browser to view the responsive behavior.

Any Paragon component or export may be added to the code example.

CardDeck

Displays child Card components in a horizontal row with equal height and width, with an appropriate gutter between cards. The width of each child Card component is determined by the (optional) columnSizes prop. If any child Card components overflow beyond the parent's width, they will be hidden but accessible via scrolling horizontally or keyboard navigation.

For accessibility, if the child Card components are interactive (e.g., isClickable), pass the hasInteractiveChildren prop so the CardDeck itself isn't focusable.

Any Paragon component or export may be added to the code example.

CardDeck.Deprecated

Gives any child Card components equal height with an appropriate gutter between cards. Each child Card component's width will be adjusted (e.g., become more narrow) to ensure all Card components fit within its parent's width.

Note: This component is a pass-thru from react-bootstrap.

Any Paragon component or export may be added to the code example.

CardCarousel

Extends CardDeck to support navigating between any overflow Card components via left and right IconButton components as a scrollable carousel.

Includes support for an optional title and subtitle. You may rely on the default styles for the titles (e.g., if passing strings) or alternatively you may also pass custom HTML and JSX.

Any Paragon component or export may be added to the code example.

Theme Variables (SCSS)#

$card-spacer-y: .75rem !default;
$card-spacer-x: 1.25rem !default;
$card-border-width: $border-width !default;
$card-border-radius: $border-radius !default;
$card-border-color: rgba($black, .125) !default;
$card-border-focus-color: $primary-500 !default;
$card-border-focus-color-dark: theme-color("primary", "focus") !default;
$card-inner-border-radius: subtract($card-border-radius, $card-border-width) !default;
$card-cap-bg: rgba($black, .03) !default;
$card-cap-color: null !default;
$card-height: null !default;
$card-color: null !default;
$card-bg: $white !default;
$card-bg-dark: $primary-500 !default;
$card-bg-muted: $light-200 !default;
$card-img-overlay-padding: 1.25rem !default;
$card-group-margin: calc($grid-gutter-width / 2) !default;
$card-deck-margin: $card-group-margin !default;
$card-grid-margin: $card-group-margin !default;
$card-deck-margin-bottom: map_get($spacers, 3) !default;
$card-grid-margin-bottom: map_get($spacers, 3) !default;
$card-columns-count: 3 !default;
$card-columns-gap: 1.25rem !default;
$card-columns-margin: $card-spacer-y !default;
$card-divider-bg: $light-400 !default;
$card-divider-margin-y: $card-spacer-y !default;
$card-footer-actions-gap: .5rem !default;
$card-logo-left-offset: 1.5rem !default;
$card-logo-bottom-offset: 1rem !default;
$card-logo-left-offset-horizontal: .4375rem !default;
$card-logo-bottom-offset-horizontal: .4375rem !default;
$card-logo-width: 7.25rem !default;
$card-logo-height: 4.125rem !default;
$card-image-border-radius: $card-border-radius !default;
$card-logo-border-radius: .25rem !default;
$card-footer-text-font-size: $x-small-font-size;
$card-image-horizontal-max-width: 240px !default;
$card-image-horizontal-min-width: $card-image-horizontal-max-width !default;
$card-image-vertical-max-height: 140px !default;
$loading-skeleton-spacer: .313rem !default;
$card-focus-border-offset: 5px !default;
$card-focus-border-width: 2px !default;
$card-focus-border-radius: calc($card-focus-border-offset + $card-border-radius) !default;

Props API#

Card Props API
This component does not receive any props.
CardHeader Props API
  • actions node

    Optional node to render on the top right of the card header, i.e. ActionRow or a DropdownMenu.

    Defaultnull
  • className string

    The class name for the CardHeader component

    Defaultnull
  • title node

    The title for the CardHeader component

    Defaultnull
  • size enum'sm' | 'md'

    The size of the CardHeader component

    Default'md'
  • subtitle node

    The subtitle of the CardHeader component

    Defaultnull
  • skeletonHeight number

    Specifies height of skeleton in loading state.

    Default20
  • skeletonWidth number

    Specifies width of skeleton in loading state.

    Defaultnull
CardGrid Props API
  • className string

    The class name for the CardGrid component

  • children node Required

    The Card components to organize into a responsive grid

  • columnSizes shape {
    xs: number,
    sm: number,
    md: number,
    lg: number,
    xl: number,
    }

    An object containing the desired column size at each breakpoint, following a similar props API as react-bootstrap/Col

    Default{ sm: 12, lg: 6, xl: 4, }
  • hasEqualColumnHeights bool

    Whether to disable the default equal height cards across rows in the card grid

    Defaulttrue
CardSection Props API
  • className string

    Specifies class name to append to the base element.

  • children node

    Specifies contents of the component.

    Defaultnull
  • title node

    Specifies title of the Section.

  • actions node

    Specifies node to render on the bottom right of the Section (i.e. ActionRow).

  • muted bool

    Specifies whether to display Section with muted styling.

    Defaultfalse
  • skeletonHeight number

    Specifies height of skeleton in loading state.

    Default100
  • skeletonWidth number

    Specifies width of skeleton in loading state.

CardDivider Props API
  • className string

    Specifies class name to append to the base element.

CardFooter Props API
  • children node

    Specifies contents of the component.

    Defaultnull
  • className string

    Specifies class name to append to the base element.

  • textElement node

    Optional node to display near actions. Should be either a plain text or an element containing text (e.g. link).

  • isStacked bool

    Specifies whether to use stacked variant.

    Defaultfalse
  • orientation enum'horizontal' | 'vertical'

    Specifies which orientation to use. This prop will override context value if provided.

  • skeletonHeight number

    Specifies height of skeleton in loading state.

    Default18
  • skeletonWidth number

    Specifies width of skeleton in loading state.

CardBody Props API
  • children node

    Specifies the content of the component.

  • className string

    The class to append to the base element.

CardImageCap Props API
  • className string

    Specifies class name to append to the base element.

  • src string

    Specifies image src.

  • fallbackSrc string

    Specifies fallback image src.

    DefaultcardSrcFallbackImg
  • srcAlt string

    Specifies image alt text.

  • logoSrc string

    Specifies logo src to put on top of the image.

  • fallbackLogoSrc string

    Specifies fallback image logo src.

  • logoAlt string

    Specifies logo image alt text.

  • skeletonHeight number

    Specifies height of Image skeleton in loading state.

    Default140
  • skeletonWidth number

    Specifies width of Image skeleton in loading state.

  • logoSkeleton bool

    Specifies whether the cap should be displayed during loading.

    Defaultfalse
  • logoSkeletonHeight number

    Specifies height of Logo skeleton in loading state.

    Default41
  • logoSkeletonWidth number

    Specifies width of Logo skeleton in loading state.

  • imageLoadingType enum'eager' | 'lazy'

    Specifies loading type for images

    Default'eager'
CardStatus Props API
  • children node Required

    Specifies the content of the component.

  • className string

    The class to append to the base element.

  • icon func

    Icon that will be shown in the top-left corner.

  • variant enum'primary' | 'success' | 'danger' | 'warning'

    Specifies variant to use.

    Default'warning'
  • title element | string

    Specifies title for the Card.Status.

  • actions node

    Specifies any optional actions, e.g. button(s).

CardDeck Props API
  • className string

    The class name for the CardDeck component

  • children node Required

    The Card components to organize

  • columnSizes shape {
    xs: number,
    sm: number,
    md: number,
    lg: number,
    xl: number,
    }

    An object containing the desired column size at each breakpoint, following a similar props API as react-bootstrap/Col

    Default{ sm: 12, lg: 6, xl: 4, }
  • hasInteractiveChildren bool

    Whether the child Card components are interactive/focusable. If not, a tabindex="0" is added to be a11y-compliant

    Defaultfalse
  • canScrollHorizontal bool

    Whether the CardDeck supports horizontal scrolling when there are overflow children

    Defaulttrue
  • hasOverflowScrollItems bool

    Whether the children of CardDeck should be processed by useOverflowScrollItems to give each child a known/stable CSS classname

    Defaultfalse
  • hasEqualColumnHeights bool

    Whether to disable the default equal height cards

    Defaulttrue
CardCarousel Props API
  • children node Required

    The Card items for the CardCarousel.

  • ariaLabel string Required

    Text describing the CardCarousel for screen readers

  • title node

    An optional title.

  • subtitle node

    An optional subtitle.

  • columnSizes shape {
    xs: number,
    sm: number,
    md: number,
    lg: number,
    xl: number,
    }

    Customize the responsive columnSizes used by the carousel.

    Default{ sm: 12, lg: 6, xl: 4, }
  • hasInteractiveChildren bool

    Whether the carousel has interactive children (e.g., clickable cards).

    Defaultfalse
  • canScrollHorizontal bool

    Whether the carousel can be scrolled manually by users.

    Defaulttrue
  • disableOpacityMasks bool

    Whether the default opacity masks should be shown at the start/end, if applicable.

    Defaultfalse
  • onScrollPrevious func

    Callback function for when the user scrolls to the previous element.

  • onScrollNext func

    Callback function for when the user scrolls to the next element.

  • CardCarouselControls elementType

    Optional override for the default CardCarouselControls

Usage Insights#

Card

Project NameParagon VersionInstance Count
frontend-app-admin-portal20.46.331
frontend-app-authn20.46.21
frontend-app-course-authoring20.46.222
frontend-app-discussions20.44.01
frontend-app-ecommerce20.46.21
frontend-app-enterprise-public-catalog20.46.32
frontend-app-learner-dashboard20.46.25
frontend-app-learner-portal-enterprise20.45.423
frontend-app-learning20.46.04
frontend-app-library-authoring21.5.611
frontend-app-ora-grading20.46.34
frontend-app-support-tools20.46.03
frontend-lib-content-components21.5.63
prospectus20.46.26

CardBody

Project NameParagon VersionInstance Count
frontend-app-admin-portal20.46.34
frontend-app-course-authoring20.46.211
frontend-app-learner-dashboard20.46.23
frontend-app-learner-portal-enterprise20.45.43
frontend-app-library-authoring21.5.61
frontend-lib-content-components21.5.61
prospectus20.46.22

CardCarousel

Project NameParagon VersionInstance Count
frontend-app-learner-portal-enterprise20.45.41

CardDeck

Project NameParagon VersionInstance Count
frontend-app-learner-portal-enterprise20.45.41

CardDivider

Project NameParagon VersionInstance Count
frontend-app-course-authoring20.46.28
prospectus20.46.21

CardFooter

Project NameParagon VersionInstance Count
frontend-app-admin-portal20.46.311
frontend-app-course-authoring20.46.29
frontend-app-learner-dashboard20.46.21
frontend-app-learner-portal-enterprise20.45.45
frontend-app-learning20.46.03
frontend-app-library-authoring21.5.63
frontend-app-ora-grading20.46.31
frontend-app-support-tools20.46.01
frontend-lib-content-components21.5.61

CardGrid

Project NameParagon VersionInstance Count
frontend-app-admin-portal20.46.39
frontend-app-course-authoring20.46.22
frontend-app-learner-portal-enterprise20.45.416
prospectus20.46.23

CardHeader

Project NameParagon VersionInstance Count
frontend-app-admin-portal20.46.38
frontend-app-authn20.46.21
frontend-app-course-authoring20.46.213
frontend-app-enterprise-public-catalog20.46.32
frontend-app-learner-dashboard20.46.23
frontend-app-learner-portal-enterprise20.45.414
frontend-app-learning20.46.04
frontend-app-library-authoring21.5.65
frontend-app-support-tools20.46.05
frontend-lib-content-components21.5.61

CardImageCap

Project NameParagon VersionInstance Count
frontend-app-admin-portal20.46.39
frontend-app-authn20.46.21
frontend-app-enterprise-public-catalog20.46.32
frontend-app-learner-dashboard20.46.24
frontend-app-learner-portal-enterprise20.45.410
frontend-app-learning20.46.01

CardSection

Project NameParagon VersionInstance Count
frontend-app-admin-portal20.46.329
frontend-app-authn20.46.21
frontend-app-course-authoring20.46.216
frontend-app-discussions20.44.01
frontend-app-enterprise-public-catalog20.46.32
frontend-app-learner-dashboard20.46.23
frontend-app-learner-portal-enterprise20.45.430
frontend-app-learning20.46.04
frontend-app-library-authoring21.5.68
frontend-app-ora-grading20.46.32
frontend-app-support-tools20.46.05
frontend-lib-content-components21.5.63
prospectus20.46.23

CardStatus

Project NameParagon VersionInstance Count
frontend-app-admin-portal20.46.32
frontend-app-course-authoring20.46.21
frontend-app-learner-portal-enterprise20.45.41