You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Support vertical layout
* Make horizontal layout more robust
* Remove redundant styles
* Add horizontal examples
* Add changeset
* Fix horizontal media card layout
* Make right aligned Media clickable
* Add example
* Update example texts
* Make example outlined
* FIx Badge radius in horizontal Media
Copy file name to clipboardExpand all lines: packages/react/src/card/card.tsx
+59-4
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ const cardVariants = cva({
10
10
base: [
11
11
'group/card',
12
12
'rounded-2xl border p-3',
13
-
'flex flex-col gap-y-4',
13
+
'flex gap-y-4',// y-gap ensures a vertical spacing for both verical layout and responsive horizontal layout
14
14
'relative',// Needed for positiong of the clickable pseudo-element (and can also be used for other absolute positioned elements the consumer might add)
15
15
16
16
// **** Heading ****
@@ -28,9 +28,9 @@ const cardVariants = cva({
28
28
// **** Media ****
29
29
'[&_[data-slot="media"]]:overflow-hidden',// Prevent content from overflowing the rounded corners
30
30
'[&_[data-slot="media"]]:relative',// Needed for positioning the <Badge> component (if present)
31
-
'[&_[data-slot="media"]]:rounded-t-2xl',// Top corners are always rounded
32
31
// Position media at the edges of the card (because of these negative margins the media-element must be a wrapper around the actual image or other media content)
'[&:has(>[data-slot="media"]:last-child)]:flex-col-reverse',// Always display the media at the top of the card
114
+
'[&:has(>[data-slot="media"])]:md:!flex-row',// When need !important to override the specificity (first-/last-child) of the flex-col-reverse and flex-col classes
115
+
116
+
'[&:has(>[data-slot="media"])>*]:md:basis-1/2',// Ensures a 50/50 split of the media and content on medium screens
// Make the layout responsive: when the Content reaches a minimum width of 18rem, the layout switches to vertical. Also makes sure Content takes up the remaining space available.
// Some rounded corners are removed when the card is outlined
146
+
'[&_[data-slot="media"]]:rounded-t-2xl',// On small screens, the top corners are rounded
147
+
'[&_[data-slot="media"]:first-child]:md:rounded-tr-none [&_[data-slot="media"]:first-child]:md:rounded-bl-2xl',// Both left corners are rounded when media is on the left side
148
+
'[&_[data-slot="media"]:last-child]:md:rounded-tl-none [&_[data-slot="media"]:last-child]:md:rounded-br-2xl',// Both right corners are rounded when media is on the right side
149
+
// **** Badge ****
150
+
// Override default corner radius of the badge to match the media border radius
0 commit comments