-
Notifications
You must be signed in to change notification settings - Fork 287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tailwind 4: first-child
resets for margin-top
missing when type scale is added with a breakpoint prefix
#383
Comments
Note - this may be related to #361 but that issue involves some overrides etc, and my issue is just straight-up |
My current workaround until this gets resolved looks like this: @plugin "@tailwindcss/typography";
/* Override until https://github.com/tailwindlabs/tailwindcss-typography/issues/383 is fixed */
@layer utilities {
.prose > :first-child {
margin-top: 0 !important;
}
.prose > :last-child {
margin-bottom: 0 !important;
}
} |
@adamwathan found it - in the generated CSS, inside the .sm\:prose-sm {
@media (width >= 40rem) {
:where(.prose-sm > :first-child):not(
:where([class~='not-prose'], [class~='not-prose'] *)
) {
margin-top: 0;
}
}
} This needs to be adjusted to .sm\:prose-sm {
@media (width >= 40rem) {
- :where(.prose-sm > :first-child):not(
+ :where(.sm\:prose-sm > :first-child):not(
:where([class~='not-prose'], [class~='not-prose'] *)
) {
margin-top: 0;
}
}
} This affects several other pseudo-classes inside the modifier+media queries. Looks like any of the keys that start with tailwindcss-typography/src/styles.js Lines 127 to 142 in 1a6972e
|
@danieltott Thanks for the detailed bug report! This was indeed an issue in our compatibility layer that didn't properly replace class names with the utility names in these cases. I pushed a fix onto |
@philipp-spiess awesome! Glad I could help and glad it wasn't a huge pain to fix 😂 Keep up the good work 🤜🏼 |
Thanks for this fix, it is the only thing I need before upgrading to V4. Is there any date decided for when the next patch is released with this fix, or could you simply release it now? :) |
@michaelrazmgah Will do a release this week for sure, just trying to get as many fixes in as we can to avoid unnecessary churn. |
@philipp-spiess thanks again for the quick fix - I confirmed this is fixed up in @michaelrazmgah note that the fix is in |
@danieltott Are you sure? It doesn't seem to work for me 🤔 I still need your workaround for margins top and bottom for first and last elements to be removed. |
@michaelrazmgah yeah, it's definitely fixed. You can see the result here: https://play.tailwindcss.com/FbG6fLD0eT - the ones with the red borders had the issue in |
What version of @tailwindcss/typography are you using?
v0.5.16
What version of Node.js are you using?
22.13 locally, also happening on Tailwind Play
What browser are you using?
Chrome, Firefox
What operating system are you using?
mac
Reproduction repository
https://play.tailwindcss.com/FbG6fLD0eT
Describe your issue
In
.prose
, non-h1 headings by default have amargin-top
applied. If the heading is the first child, then there is css that resetsmargin-top
to0
.When you add a size modifier (
prose-lg
etc), there is an updatedmargin-top
value, and an additional updatedmargin-top:0
for:first-child
for each heading.When you add a type scale with a breakpoint prefix (ie
lg:prose-lg
), there is an adjustedmargin-top
value in a media query, but they are missing the relatedmargin-top:0
for:first-child
situations.I created a Tailwind Play link that describes this: https://play.tailwindcss.com/FbG6fLD0eT
Here are some screenshots
Just
.prose
(good):Size modifier:
.prose.prose-sm
(good):Size modifier + breakpoint prefix (bad):
The text was updated successfully, but these errors were encountered: