Skip to content

Commit 3c8460f

Browse files
committed
feat: Added card description component to card.
1 parent 20fb229 commit 3c8460f

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { css } from '@patternfly/react-styles';
2+
import styles from '@patternfly/react-styles/css/components/Card/card';
3+
4+
export interface CardDescriptionProps {
5+
/** Content rendered inside the description. */
6+
children?: React.ReactNode;
7+
/** Additional classes added to the description. */
8+
className?: string;
9+
/** Id of the description. */
10+
id?: string;
11+
}
12+
13+
export const CardDescription: React.FunctionComponent<CardDescriptionProps> = ({
14+
children = null,
15+
className = '',
16+
id = '',
17+
...props
18+
}: ModalBoxDescriptionProps) => (
19+
<div {...props} id={id} className={css(styles.cardDescription, className)}>
20+
{children}
21+
</div>
22+
);
23+
CardDescription.displayName = 'CardDescription';

packages/react-core/src/components/Card/examples/Card.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ propComponents:
99
'CardHeaderActionsObject',
1010
'CardHeaderSelectableActionsObject',
1111
'CardTitle',
12+
'CardDescription',
1213
'CardBody',
1314
'CardFooter',
1415
'CardExpandableContent'
@@ -26,7 +27,7 @@ import PlusIcon from '@patternfly/react-icons/dist/esm/icons/plus-icon';
2627

2728
### Basic cards
2829

29-
Basic cards typically have a `<CardTitle>`, `<CardBody>` and `<CardFooter>`. You may omit these components as needed, but it is recommended to at least include a `<CardBody>` to provide details about the card item.
30+
Basic cards typically have a `<CardTitle>`, `<CardDescription>`, `<CardBody>` and `<CardFooter>`. You may omit these components as needed, but it is recommended to at least include a `<CardBody>` to provide details about the card item.
3031

3132
```ts file='./CardBasic.tsx'
3233

packages/react-core/src/components/Card/examples/CardBasic.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { Card, CardTitle, CardBody, CardFooter } from '@patternfly/react-core';
1+
import { Card, CardTitle, CardDescription, CardBody, CardFooter } from '@patternfly/react-core';
22

33
export const CardBasic: React.FunctionComponent = () => (
44
<Card ouiaId="BasicCard">
55
<CardTitle>Title</CardTitle>
6+
<CardDescription>Description</CardDescription>
67
<CardBody>Body</CardBody>
78
<CardFooter>Footer</CardFooter>
89
</Card>

0 commit comments

Comments
 (0)