El Klo's avatar
Level 11

Tailwind classes not loading from variable in blade

I have a simple blade component. It is only responsible for showing a span. The view looks like this:

<span class="inline-flex items-center rounded-md {{ $bgClass }} px-2 py-1 text-xs font-medium {{$textClass}} ring-1 ring-inset {{$ringClass}}">
    {{$project->showAvailableSpots()}} spots open
</span>

The class looks like this:

I made sure to include the whole tailwind class name in the component, since injecting a part of a tailwind class is not allowed. When I inspect the element with devtools, the classnames on the span are there but the colors are not loading. When i hardcode the colors on the component, they do show.

Here's the code from devtools that gets rendered:

<span class="inline-flex items-center rounded-md bg-success-50 px-2 py-1 text-xs font-medium text-success-700 ring-1 ring-inset ring-success-600/20">
    16 spots open
</span>
0 likes
2 replies
Snapey's avatar
Snapey
Best Answer
Level 122

is your view component folder in the list of tailwind scanned folders?

1 like
El Klo's avatar
Level 11

@Snapey Dang. Only my view was, i never thought about including the component class as well. Thanks.

Please or to participate in this conversation.