Replies: 1 comment
-
|
This is an excellent observation. The "friction" comes from the fact that shadcn/ui is designed with a highly specific aesthetic that favors 14px ( While we wait for potential core changes, a robust way to solve this at the project level (and avoid the The CSS Solution (Global)Instead of forcing every element to be @layer base {
html {
font-size: 14px; /* Sets 1rem to 14px */
}
}The Tailwind Config SolutionIf you want to keep the root at 16px but make "base" text 14px (effectively swapping theme: {
extend: {
fontSize: {
base: ['0.875rem', { lineHeight: '1.25rem' }], // 14px
lg: ['1rem', { lineHeight: '1.5rem' }], // 16px
},
},
}Why
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
First of all, thank you for this incredible project. It has significantly improved how we build modern interfaces.
I'd like to open a discussion about a Developer Experience (DX) friction point regarding typography. Specifically, the heavy reliance on the
text-smutility class to maintain the default shadcn aesthetic.I have attached an image where I analyzed the typography sizes across various UI elements:
text-sm(14px).text-xs,text-base,text-lg, etc.).As seen in the visual, the vast majority of the UI (inputs, labels, descriptions, badges, list items) is built around the
text-smsize.The Problem:
Because standard web projects default to 16px (
text-base), whenever we developers build custom layouts, text blocks, or wrappers alongside shadcn components, we are constantly forced to manually addclassName="text-sm"to our own elements just to achieve visual consistency with the library.Having to constantly type
text-smeverywhere:text-smto a standard<p>or<div>, making it look awkwardly large next to a shadcnInputorLabel.Proposed Solution:
Instead of treating
text-smas a utility class that needs to be applied everywhere, we should make 14px the actual default and clean up the component code.1. Remove
text-smfrom components:Strip out the hardcoded
text-smclasses from all component files (Input, Label, Button, Card, etc.). Let them inherit the font size naturally.2. Update the default base font to 14px:
During the
shadcn-ui initprocess, the library could modify thetailwind.config.jsto override the defaulttext-baseWhy this is better:
text-smon every single custom element we create.classNamestrings.text-xsortext-lg, as seen in the green outlines) when we actually want to deviate from the standard look.Would love to hear the maintainers' and community's thoughts on this approach!
Beta Was this translation helpful? Give feedback.
All reactions