-
if I understand correctly I have to use the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 8 replies
-
Because Tailwind doesn't support <!-- works for the host element, but not parts -->
<sl-button class="…"> I recommend using /* parts can be targeted using @apply */
sl-button::part(base) {
@apply py-2 px-4 bg-blue-500 text-white font-semibold rounded-lg shadow-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-400 focus:ring-opacity-75;
} EDIT by @KonnorRogers 4/20/2024 : Tailwind supports I don't recall if Tailwind supported JIT at the time of the original answer, but Tailwind technically supports <sl-card class="[&::part(base)]:px-4 [&::part(base)]:py-2">
</sl-card> I have a plugin I wrote here to make it slightly less worse: https://github.com/KonnorRogers/tailwindcss-plugin-custom-elements there is also a discussion here about adding it to Tailwind "Core" |
Beta Was this translation helpful? Give feedback.
Because Tailwind doesn't support
::part()
, you won't be able to use utility classes on the host element to target parts:I recommend using
@apply
for this, which lets you do things like:EDIT by @KonnorRogers 4/20/2024 :
Tailwind supports
::part()
using the arbitrary property syntax in their JIT compiler, so technically you can target parts like this:I don't recall if Tailwind suppor…