tailwindlabs/tailwindcss-typography

Bottom margin is not reset for last child when redefined in lg prose

zipper opened this issue ยท 2 comments

What version of @tailwindcss/typography are you using?

0.5.9

What version of Node.js are you using?

v18.13.0

What browser are you using?

Chrome

What operating system are you using?

Windows

Reproduction repository

https://play.tailwindcss.com/6NBZwfb7oE

Describe your issue

When I redefine bottom margin in lg prose, the margin is not reset for :last-child. In the example above, I have changed to margin for p and table in one selector. Because of that, :last-child doesn't have correctly reset bottom margin. If you separate it to two selectors (objects), than the reset works as expected.

Is this expected behaviour and should I change the margin for each element separately, or is this considered a bug?

Hey! This is annoying but expected โ€” when you customize the typography plugin your customizations are just added after the CSS generated by the plugin by default unless you target a selector that the plugin has already defined, in which case the rule stays in the same place in the CSS file but gets the new value.

You can see we define the p spacing here:

https://github.com/tailwindlabs/tailwindcss-typography/blob/master/src/styles.js#L195

...and the table spacing here:

https://github.com/tailwindlabs/tailwindcss-typography/blob/master/src/styles.js#L1413-L1419

Since we target p and table separately rather than as p, table, you'll have the best results doing the same.

Sorry, this plugin sucks to customize ๐Ÿ˜• Personally not satisfied with it at all. In the future I'm hoping to move to a setup where we literally just give you some CSS to throw into your own project, and you customize it by opening the CSS and editing it rather than trying to deal with all this fancy CSS-in-JS weird complex merging garbage.

But yeah right now the behavior you're seeing is effectively intended for the reasons I explained ๐Ÿ‘

Ok, I guess that also explains, why it doesn't help, when I insert > :last-child into the css array at last position - since the key already exists, it is still before the new selector. Thank you for clarification ๐Ÿ™‚

I agree with the CSS-in-JS part you write. I'm trying to change the behaviour of lg prose to modify just the margins and this and the sibling issue are a bit pitta.