Card

Card is a container for text, photos, and actions in the context of a single subject.


Installation

nextui add card
No need to install this package if @nextui-org/react is already installed globally.

Import

NextUI exports 4 card-related components:

  • Card: The main component to display a card.
  • CardHeader: Commonly used for the title of a card.
  • CardBody: The content of the card.
  • CardFooter: Commonly used for actions.

Usage

With Divider

See the Divider component for more details.

With Image

You can pass the isFooterBlurred prop to the card to blur the footer.

Composition

You can use other NextUI components inside the card to compose a more complex card.

Blurred Card

You can pass the isBlurred prop to the card to blur the card.

Primary Action

If you pass the isPressable prop to the card, it will be rendered as a button.

Note: that the used callback function is onPress instead of onClick. Please see the usePress component for more details.

Cover Image

You can use Image component as the cover of the card by taking it out of the CardBody component.

Data Attributes

Card has the following attributes on the base element:

  • data-hover: When the card is being hovered. Based on useHover
  • data-focus: When the card is being focused. Based on useFocusRing.
  • data-focus-visible: When the card is being focused with the keyboard. Based on useFocusRing.
  • data-disabled: When the card is disabled. Based on isDisabled prop.
  • data-pressed: When the card is pressed. Based on usePress

API

Card Props

AttributeTypeDescriptionDefault
childrenReactNode | ReactNode[]Usually the Card parts, CardHeader, CardBody and CardFooter.-
shadownone | sm | md | lgThe card shadow.md
radiusnone | sm | md | lgThe card border radius.lg
fullWidthbooleanWhether the card should take the full width of its parent.false
isHoverablebooleanWhether the card should change the background on hover.false
isPressablebooleanWhether the card should allow to be pressed.false
isBlurredbooleanWhether the card background should be blurred.false
isFooterBlurredbooleanWhether the card footer background should be blurred.false
isDisabledbooleanWhether the card should be disabled. The press events will be ignored.false
disableAnimationbooleanWhether to disable the animation.false
disableRipplebooleanWhether to disable ripple effect. Only when isPressable is true.false
allowTextSelectionOnPressbooleanWhether to allow text selection on pressing. Only when isPressable is true.false
classNamesRecord<"base"| "header"| "body"| "footer", string>Allows to set custom class names for the card slots.-

Card Events

AttributeTypeDescription
onPress(e: PressEvent) => voidHandler that is called when the press is released over the target.
onPressStart(e: PressEvent) => voidHandler that is called when a press interaction starts.
onPressEnd(e: PressEvent) => voidHandler that is called when a press interaction ends, either over the target or when the pointer leaves the target.
onPressChange(isPressed: boolean) => voidHandler that is called when the press state changes.
onPressUp(e: PressEvent) => voidHandler that is called when a press is released over the target, regardless of whether it started on the target or not.