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

Tailwind classes in Components #2626

Closed
sebilasse opened this issue Aug 22, 2024 · 2 comments · Fixed by #2646
Closed

Tailwind classes in Components #2626

sebilasse opened this issue Aug 22, 2024 · 2 comments · Fixed by #2646
Labels
docs good first issue Good for newcomers

Comments

@sebilasse
Copy link

sebilasse commented Aug 22, 2024

Hello,
changed everything from twind to tailwind.

Maybe it could be documented that currently all classes in components need to be named explicitly.

Let's say I have an encoded link component for mailto: or tel: links and it has

interface {
  type?: 'mail'|'phone'
}

This will not work:

  <a class={`redaktor-link-${type}`}></a>

but this would

  <a class={type === 'phone' ? `redaktor-link-phone` : `redaktor-link-mail`}></a>

Not sure if this could be done with the reflection API or if there are better ideas :)

@marvinhagemeister
Copy link
Collaborator

Good point, compared to twind, tailwind analyses the source code instead of running it. It cannot detect split up tailwind class names. We should add a note for that in our docs.

@sebilasse
Copy link
Author

If we have more class-choices than just two, one can also create a plugin, see
https://tailwindcss.com/docs/plugins#dynamic-utilities

Done that a lot, works fine, got e.g.: baseline solid typo and ui variants and all the colors and ActivityPub stuff.
Will keep you updated :)

marvinhagemeister added a commit that referenced this issue Sep 9, 2024
close #2626

---------

Co-authored-by: Marvin Hagemeister <marvin@deno.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants