Reputation: 2871
I want to have an input text box that has only the placeholder as italics but not the text content.
I know we can do this using normal css like so:
::-webkit-input-placeholder {
font-style: italic;
}
But how to do it in tailwind way?
Upvotes: 11
Views: 15873
Reputation: 6931
Placeholder state is built-in as of Tailwind CSS v. 3.0. Check the docs here
<input type="text" class="placeholder:italic" />
See a working example: Tailwind Play
@layer utilities {
.placeholder-italic::placeholder{
@apply italic
}
}
<input type="text" class="placeholder-italic" />
See a working example: Tailwind Play
Upvotes: 18
Reputation: 653
In Tailwind v3.0
If you want to make it bold.
<input type="text" class="placeholder:font-bold" />
Upvotes: 1
Reputation: 75
This should do the trick
<input class="placeholder:italic placeholder:text-gray-400" />
Upvotes: 0
Reputation: 682
I'm not found an existing Tailwind utility to change the font-style property, but in Tailwind you can create your custom utilities.
@layer utilities {
.italic-plc::placeholder {
font-style: italic;
}
}
TailwindCSS related doc page: https://tailwindcss.com/docs/adding-new-utilities
Upvotes: 1