It is not possible at this moment in Tailwind, see pseudo class reference for a list possible variants.
In your specific case you might want to use first
(or first-of-type
) modifier like that:
<div>
<div class="first:bg-blue-500 bg-red-500">First</div>
<div class="first:bg-blue-500 bg-red-500">Second</div>
<div class="first:bg-blue-500 bg-red-500">Third</div>
</div>
Alternatively what you can do is to apply needed styles through js by looking at the index of the element, for example if you have list of elements in React:
<div>
{list.map((item, index) => (
<div
key={index}
className={index === 0 ? 'bg-blue-500' : 'bg-red-500'}
>
{
// ...
}
</div>
))}
</div>