Skip to content

Conversation

@dlabaj
Copy link
Contributor

@dlabaj dlabaj commented Oct 28, 2025

Adds tests to ensure the CardDescription component renders correctly with PatternFly Core styles, handles className, and spreads extra props to the root element.

@dlabaj dlabaj self-assigned this Oct 28, 2025
@dlabaj dlabaj requested review from kmcfaul and mcoker October 28, 2025 20:09
@patternfly-build
Copy link
Contributor

patternfly-build commented Oct 28, 2025

@dlabaj dlabaj changed the title Adds tests for CardDescription component Adds CardDescription component Oct 30, 2025
@kmcfaul kmcfaul linked an issue Nov 4, 2025 that may be closed by this pull request
Copy link
Contributor

@kmcfaul kmcfaul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This structure seems out of date with the core implementation

### Basic cards

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.
Basic cards typically have a `<CardTitle>`, `<CardSubtitle>`, `<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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would we want to say that cards will typically have a subtitle, or should the subtitles be just somsthing that can be added but aren't usually there?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this has been removed and we have a seperate demo

Copy link
Contributor

@kmcfaul kmcfaul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To match the core structure, CardTitle needs a subtitle prop which passes the content and puts the cardSubtitle at a sibling level to the CardTitle's internal cardTitleText div. The current implementation is putting the cardSubtitle as a child of cardTitleText.

I think I would prefer making the subtitle prop represent only the ReactNode content and conditionally rendering the cardSubtitle div in CardTitle based on the prop, but I'd also be fine with keeping CardSubtitle as a component.

/** Sets the base component to render. defaults to div */
component?: keyof React.JSX.IntrinsicElements;
/** @beta Subtitle of the card title */
subtitle?: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably make this a ReactNode like the ModalHeader description

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

expect(asFragment()).toMatchSnapshot();
});

test('className is added to the root element', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CardSubtitle doesn't pass className anymore, and is only used internally so this test can be removed to fix the build.

Copy link
Contributor

@mcoker mcoker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed offline, but just to document it - we have 2 examples in core to show different uses of the subtitle element

Image
  • One is with a traditional card that has multiple actions to the right. This shows how the subtitle goes under the title, but if the title text wraps due to not having enough space from the actions to the right, the subtitle text will wrap with the title - which looks a little odd. It's ideal for shorter descriptions.
  • The other is with an image + actions at the top, and the title is shown below both. This is a really common layout used in quickstarts and catalog view I believe. In this case, the title and subtitle span the full width of the card so you can have a super long subtitle and it looks fine

Could you update the example you have now to add actions? You don't need to make the text "really really really... long" - it can just be a normal title.

Then add the card with an action below it in the same example? There should already be an example card that looks like that you can copy/paste

```ts file='./CardSubtitle.tsx'

```
### Card with subtitle and Actions
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mcoker Added subtitle and actions that is similar to what is in core.

Copy link
Contributor

@mcoker mcoker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!! Sorry but forgot one more thing - need to mark any subtitle examples/props as beta. Otherwise LGTM

@dlabaj
Copy link
Contributor Author

dlabaj commented Nov 5, 2025

@mcoker @kmcfaul All set you two. If you see anything else let me know.

@kmcfaul kmcfaul merged commit 5e8fc6c into patternfly:main Nov 5, 2025
13 checks passed
@patternfly-build
Copy link
Contributor

Your changes have been released in:

Thanks for your contribution! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Card - CardTitle description

5 participants