tailwind utility to capitalise only first letter of string

  • By Martin DONADIEU
  • Last update: Feb 2, 2022
  • Comments: 0

Tailwind Capitalize first letter

tailwind utility to capitalize only first letter of string

Install the plugin from npm:

$ npm install tailwind-capitalize-first-letter

Then add the plugin to your tailwind.config.js file:

// tailwind.config.js
module.exports = {
  // ...
  plugins: [
    // ...
    require('tailwind-capitalize-first-letter'),
    // ...
  ],
};

This plugin will generate following CSS:

/* ... */
.capitalize-first:first-letter {
  texttransform: uppercase;
}
/* ... */

Usage

<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>

License

Capitalize first letter is licensed under the MIT License.

Credits

Created with create-tailwind-plugin. Inspired by simonswiss

Github

https://github.com/riderx/capitalize-first-tailwind