Card is a component for grouping similar content in a container.

Importing

The component can be imported via:

import { 
	Card, 
	CardHeader, 
	CardTitle,
	CardActions, 
	CardSection, 
} from '@customerio/pluma-components/react';

A Card component can be composed with the following child components:

  • CardHeader
    • a container component for the Card's header section
  • CardTitle
    • the Card's title, must be nested within a CardHeader
  • CardActions
    • a container for actions, such as links or buttons. Must be nested within a CardHeader. By default, buttons inside this section render as sm subtle buttons
  • CardSection
    • a container component for content in the Card. CardHeader is a CardSection internally
    • CardSection components are separated by a small gap

Usage

A complete example, using all the available child components, looks like:

Title

The Card's content

<Card>
	<CardHeader>
		<CardTitle>Title</CardTitle>

		<CardActions>
      <DropdownMenu placement="bottom-end">
        <DropdownMenuTriggerButton icon="more-vertical" isIconOnly={true} />

        <DropdownMenuContent>
          <DropdownMenuItem onClick={() => console.log('Option 1')}>
            Option 1
          </DropdownMenuItem>
          <DropdownMenuItem onClick={() => console.log('Option 2')}>
            Option 2
          </DropdownMenuItem>
        </DropdownMenuContent>
      </DropdownMenu>
		</CardActions>
	</CardHeader>

	<CardSection>
		<Paragraph>The Card's content</Paragraph>
	</CardSection>
</Card>

Section Padding

By default, a CardSection will render with:

  • a top padding, if it's the first child of the Card
  • a bottom padding, if it's the last child of the Card
  • left and right paddings

By setting withPadding={false}, the CardSection component will stretch to the edges of the Card instead, which is useful for adding full-width content, like dividers or images.

Card title
Content section

More content
<Card>
  <CardHeader>
    <CardTitle>Card title</CardTitle>
  </CardHeader>
  
  <CardSection>
    <Text>Content section</Text>
  </CardSection>
  
  
  <CardSection withPadding={false}>
    <Divider />
  </CardSection>
  
  <CardSection>
    <Text>More content</Text>
  </CardSection>
</Card>
Placeholder
Card title
Card content
<Card>
  <CardSection withPadding={false} overflow="hidden">
    <Image src="https://images.unsplash.com/photo-1630187256004-c49331a0831e?q=80&w=700&h=400&fit=crop&crop=focalpoint&fp-x=.45&fp-y=.34&fp-z=1.4" alt="Placeholder" w="full" />
  </CardSection>

  <CardHeader>
    <CardTitle>Card title</CardTitle>

    <CardActions>
      <DropdownMenu placement="bottom-end">
        <DropdownMenuTriggerButton icon="more-vertical" isIconOnly={true} />

        <DropdownMenuContent>
          <DropdownMenuItem onClick={() => console.log('Option 1')}>
            Option 1
          </DropdownMenuItem>
          <DropdownMenuItem onClick={() => console.log('Option 2')}>
            Option 2
          </DropdownMenuItem>
        </DropdownMenuContent>
      </DropdownMenu>
		</CardActions>
  </CardHeader>
  
  <CardSection>
    <Text>Card content</Text>
  </CardSection>
</Card>

API

PlumaCard extends Box

Default:true

Whether the section should render with padding. If false, the section will stretch like a CardInset, but with a gap between other sections. When true (default), the section includes standard Card padding.

Default:segmented

Whether the buttons should be rendered as a connected group (segmented) or equally spaced apart (spaced).

Disables all buttons in the group.

Default:md

The size of the buttons. medium and small are deprecated, use md and sm instead.

Change the color of the icon. By default, the icon inherits the button's text color. Use with care, as it can cause inconsistencies in the UI.

Overrides the icon size used within the button. Should only be used deliberately, as it can cause inconsistencies in the UI. For example, this is used in Pagination to increase the icon size.

Default:secondary

The variants of buttons to render.

On this page