Skip to main content
Neighborhood Design System v5.1.0

Card

Ready

A card displays related information in a concise, visually grouped container.

Preview

Open in Storybook (opens in new tab)

Code

Install
npm install @fbin-web/neighborhood-core
Import
import { NbhdCard } from '@fbin-web/neighborhood-core';
Usage
<nbhd-card surface="secondary">
  <nbhd-image
    slot="media"
    loading="lazy"
    provider="widen"
    crop=""
    src="https://placehold.co/498x280"
    css-class="media-css-class-card-1"
    image-focus="center"
    alt="Fun ALT Card 1 for images">
  </nbhd-image>

  <nbhd-text
    tag="h4"
    slot="title">
    Card Title
  </nbhd-text>

  <nbhd-text
    slot="content"
    tag="div">
    Donec ullamcorper nulla non metus auctor fringilla.
  </nbhd-text>

  <nbhd-cta
    slot="cta"
    variant="tertiary"
    href="fun-test-link">
    Some Random Link
  </nbhd-cta>
</nbhd-card>

Properties

PropertyAttributeTypeDefaultDescription
cssClasscss-classstring—Additional CSS class names to apply to the card.
shadowshadowbooleanfalseIf true, the card will have a shadow.
alignmentalignmentstartcenterendcenterThe alignment of the card content.
surfacesurfacenoneprimarysecondaryinverseinverse-secondaryprimaryThe surface theme of the card.
reversereversebooleanfalseIf true, the card layout will be reversed. This only changes the visual order: keyboard and screen reader order still follow the markup, so don’t reverse content whose order matters (e.g. focusable media before its text) (WCAG 1.3.2).
aspectRatioaspect-ratiosquarelandscapeportraitlandscapeThe aspect ratio of the card media.
zoomzoombooleanfalseIf true, the card media will zoom on hover.
mediaInsetmedia-insetbooleanfalseIf true, the card media will have an inset style.
layoutlayoutstackedinlinefeaturedstackedThe layout of the card.
ariaLabelaria-labelstring—Overrides the accessible name of a clickable card. The card is otherwise named by its visible title, so only set this when needed, and start it with the visible title text (WCAG 2.5.3 Label in Name). Without it, a card with `action` is named by its title, or else its content, or else its media (such as an image alt).
clickableclickablebooleanfalseIf true, the card will be rendered as a link or button.
hrefhrefstring—The URL for the card link when clickable is true.
externalexternalbooleanundefined—If true, the card link will open externally when href is provided.
action—functionundefined—The action to execute when the card is clicked. Requires clickable to be true. A transparent button stretched over the card takes the click, so the card’s title keeps its heading semantics; the button is named by the title.

Slots

NameDescription
titleContent for the card title area, typically text or heading elements.
mediaContent for the card visual area, typically images or other media elements.
contentContent for the main card body area, typically descriptive text or other content.
ctaContent for the call-to-action area. Only rendered when clickable is false.

CSS Parts

NameDescription
baseThe main card wrapper element: a link for link cards, otherwise a div.
actionThe transparent button stretched over an action card (clickable with action).
visualThe visual container that wraps the media content at the top of the card.
mediaThe media slot container for images, videos, or other rich media content.
detailThe detail container that wraps the text content (title, content, and CTA) below the visual area.
titleThe title slot container for the card's primary heading text.
contentThe content slot container for the card's descriptive text or body content.
ctaThe CTA slot container for call-to-action buttons. Only rendered when clickable is false.
nbhd-card::part(base) {
  /* your styles */
}

CSS Properties

Set these on nbhd-card or an ancestor to override the defaults. Token is the design token a default comes from and Value is what it resolves to in core Neighborhood; brands may override them. Properties that adapt to surface follow the light or inverse surface they sit on until you set them.

Card

PropertyTokenValue Copy
--nbhd-card-alignment-center—center
--nbhd-card-alignment-end—end
--nbhd-card-alignment-start—start
--nbhd-card-blockSize—100%
--nbhd-card-borderColor—transparent
--nbhd-card-borderRadius--nbhd-border-radius-none0
--nbhd-card-borderStyle—solid
--nbhd-card-borderWidth--nbhd-border-width-none0
--nbhd-card-boxShadow--nbhd-shadow-nonenone
--nbhd-card-clickable-action-alignItems—stretch
--nbhd-card-clickable-action-display—flex
--nbhd-card-clickable-action-whiteSpace—normal
--nbhd-card-clickable-content-marginBlock--nbhd-space-00px
--nbhd-card-clickable-link-display—flex
--nbhd-card-clickable-link-host-display—block
--nbhd-card-clickable-link-textDecoration—none
--nbhd-card-detail-alignItems—start
--nbhd-card-detail-blockSize—auto
--nbhd-card-detail-display—flex
--nbhd-card-detail-flexDirection—column
--nbhd-card-detail-inlineSize—auto
--nbhd-card-detail-justifyContent—end
--nbhd-card-detail-paddingBlock--nbhd-space-624px
--nbhd-card-detail-paddingInline--nbhd-space-624px
--nbhd-card-detail-position—static
--nbhd-card-detail-textAlign—start
--nbhd-card-detail-zIndex--nbhd-z-autoauto
--nbhd-card-display—flex
--nbhd-card-flexDirection—column
--nbhd-card-host-display—block
--nbhd-card-justifyContent—start
--nbhd-card-maxInlineSize—100%
--nbhd-card-overflow—hidden
--nbhd-card-paddingBlock--nbhd-space-00px
--nbhd-card-paddingInline--nbhd-space-00px
--nbhd-card-position—relative
--nbhd-card-shadow-boxShadow--nbhd-shadow-sm-4px 2px 16px 3px rgb(from #000000 r g b / 0.15)
--nbhd-card-title-color--nbhd-context-color-text-primaryAdapts to surface
--nbhd-card-title-fontSize--nbhd-typography-subheading-fontSize1.125rem
--nbhd-card-title-fontWeight--nbhd-typography-subheading-fontWeight700
--nbhd-card-title-lineHeight--nbhd-typography-subheading-lineHeight1.3
--nbhd-card-title-marginBlock--nbhd-space-0 --nbhd-space-40px 16px
--nbhd-card-title-marginInline--nbhd-space-00px
--nbhd-card-title-paddingBlock--nbhd-space-00px
--nbhd-card-title-paddingInline--nbhd-space-00px
--nbhd-card-title-textTransform—inherit
--nbhd-card-visual-alignSelf—auto
--nbhd-card-visual-aspectRatio--nbhd-card-visual-landscape-aspectRatio498 / 280
--nbhd-card-visual-blockSize—auto
--nbhd-card-visual-image-blockSize—100%
--nbhd-card-visual-image-host-blockSize—100%
--nbhd-card-visual-image-host-inlineSize—100%
--nbhd-card-visual-image-objectFit—cover
--nbhd-card-visual-image-transitionDuration—0.5s
--nbhd-card-visual-image-transitionProperty—transform
--nbhd-card-visual-inlineSize—auto
--nbhd-card-visual-landscape-aspectRatio—498 / 280
--nbhd-card-visual-marginBlock--nbhd-space-00px
--nbhd-card-visual-marginInline--nbhd-space-00px
--nbhd-card-visual-mediaInset-inline-marginBlock--nbhd-card-visual-mediaInset-space24px
--nbhd-card-visual-mediaInset-inline-marginInline--nbhd-card-visual-mediaInset-space --nbhd-space-024px 0px
--nbhd-card-visual-mediaInset-inline-reverse-marginBlock--nbhd-card-visual-mediaInset-space24px
--nbhd-card-visual-mediaInset-inline-reverse-marginInline--nbhd-space-0 --nbhd-card-visual-mediaInset-space0px 24px
--nbhd-card-visual-mediaInset-stacked-marginBlock--nbhd-card-visual-mediaInset-space --nbhd-space-024px 0px
--nbhd-card-visual-mediaInset-stacked-marginInline--nbhd-card-visual-mediaInset-space24px
--nbhd-card-visual-mediaInset-stacked-reverse-marginBlock--nbhd-space-0 --nbhd-card-visual-mediaInset-space0px 24px
--nbhd-card-visual-overflow—hidden
--nbhd-card-visual-portrait-aspectRatio—280 / 373
--nbhd-card-visual-position—static
--nbhd-card-visual-square-aspectRatio—1 / 1
--nbhd-card-visual-zIndex--nbhd-z-autoauto
--nbhd-card-zoom-hover-transform—scale(1.1)

Media overlay

PropertyTokenValueDescription Copy
--nbhd-mediaOverlay-color--nbhd-color-overlay#000000—
--nbhd-mediaOverlay-opacity--nbhd-opacity-overlay-media0.35—
--nbhd-mediaOverlay-opacity-end—0.85—
--nbhd-mediaOverlay-opacity-middle—0.5Strong enough that a title wrapping up into the middle of a featured card stays legible over light images.
--nbhd-mediaOverlay-opacity-start—0—

Dependencies

Child components <nbhd-card> renders internally. Import them too when you tree-shake.

Used by

Esc
↑ ↓ to move↵ to open