To customize all cards in shadcn/ui so that the top part of the card content has a non-white background using semantic colors, you can extend the default styles using Tailwind CSS utility classes.
Here's a general approach to achieve this:
✅ Goal:
Make the top part of every card use a non-white semantic background color (e.g., bg-muted).
Keep the rest of the card content white or default.
Use shadcn/ui conventions and Tailwind semantic colors (bg-muted, bg-accent, etc.).
✅ Solution: Customize the Card Component
If you're using the Card component from shadcn/ui, you can either:
Option 1: Wrap the Card with a Custom Component (Recommended)
If you're not modifying the original shadcn/ui components directly, you can create a wrapper component that applies the styles.
This way, every card header will have a bg-muted background.
✅ Semantic Tailwind Colors You Can Use:
bg-muted
bg-accent
bg-primary/10
bg-secondary/10
bg-destructive/10
You can also add padding or adjust spacing as needed.
✅ Final Output (Visual)
tsx
<Card>
<CardHeader className="bg-muted">
<CardTitle>Card Title</CardTitle>
<CardDescription>This is the header with a semantic background</CardDescription>
</CardHeader>
<CardContent>
<p>This is the body of the card. It remains white or neutral.</p>
</CardContent>
</Card>
Let me know if you want to apply this to all cards globally using CSS or tailwind.config.js overrides!