Skip to content
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

Bad DX: [object Object] appearing in CSS when customizing typography #330

Open
carbontwelve opened this issue Dec 6, 2023 · 0 comments
Open

Comments

@carbontwelve
Copy link

What version of @tailwindcss/typography are you using?

0.5.10

What version of Node.js are you using?

v20

What browser are you using?

Chrome

What operating system are you using?

macOS

Reproduction repository

https://play.tailwindcss.com/gujEeAoZXy

Describe your issue

This is an issue that has previously been described in #189 and elsewhere. It's known to be caused due to the Tailwind theme helpers return value sometimes being an array. For example theme('fontSize.base') returns ["1rem", {lineHeight: "1.5rem"}]

Given my understanding of Tailwind v3, the following would result in both the font size and line height being set from the theme return value:

h2: {
    fontSize: theme('fontSize.base')
},

Based upon the documentation available at https://tailwindcss.com/docs/typography-plugin#customizing-the-css given that color: theme('colors.gray.800') sets the text colour, it can be assumed that fontSize: theme('fontSize.base') works the same; it not doing so and resulting in [object object] in the css output is to my mind incorect and buggy behaviour and at the very least poor DX.

The [object object] behaviour was considered a bug in Tailwind v2, I consider this a bug in the typography plugin and the current solution of "just use theme('fontSize.base')[0]" to be problematic.

Documentation on "customising the css" needs clarification and the addition of a working example setting the font size and an additional example optionally merging in the additional styles attached to the theme helpers response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant