Implementing capitalize-first
#1745
-
Hello ! .capitalize-first::first-letter {
text-transform: uppercase;
} <p class="capitalize-first">welcome to my website</p> What do you think ? |
Beta Was this translation helpful? Give feedback.
Replies: 10 comments 16 replies
-
@matschik There is already a |
Beta Was this translation helpful? Give feedback.
-
@benface <p class="capitalize">welcome to my website</p> actually displays "Welcome to my website" |
Beta Was this translation helpful? Give feedback.
-
Hey! As mentioned in this thread - there is a |
Beta Was this translation helpful? Give feedback.
-
Here's a Tailwind Play example how you could integrate this as a plugin. In this specific scenario, I have enabled https://play.tailwindcss.com/6Fz3f8mHpO?file=config I'll copy the code here as well for reference: // Tailwind config
const plugin = require('tailwindcss/plugin')
// Let's create a plugin that adds utilities!
const capitalizeFirst = plugin(function ({ addUtilities }) {
const newUtilities = {
'.capitalize-first:first-letter': {
textTransform: 'uppercase',
},
}
addUtilities(newUtilities, ['responsive', 'hover'])
})
module.exports = {
theme: {},
variants: {},
// Let's register the plugin we created on line 3
plugins: [capitalizeFirst],
} <!-- index.html -->
<p class="capitalize-first">the first letter will always be uppercased!</p>
<p class="md:capitalize-first">the first letter will be uppercased on <code>md</code> screens and up.</p>
<p class="hover:capitalize-first">the first letter will be uppercased on hover.</p> Hope it helps 👍 |
Beta Was this translation helpful? Give feedback.
-
In JIT mode you can use |
Beta Was this translation helpful? Give feedback.
-
you can use |
Beta Was this translation helpful? Give feedback.
-
<div className="flex justify-between gap-7">
<h3 className="capitalize md:first-letter:capitalize">
text here
</h3>
</div> I want to capitalize the first letter of the first word on every screen size except mobile on mobile I want to capitalize the full heading but it's not working, why? |
Beta Was this translation helpful? Give feedback.
-
try it |
Beta Was this translation helpful? Give feedback.
Here's a Tailwind Play example how you could integrate this as a plugin.
In this specific scenario, I have enabled
responsive
andhover
variants for it, and made an example for all three in the HTML.https://play.tailwindcss.com/6Fz3f8mHpO?file=config
I'll copy the code here as well for reference: