Replies: 2 comments 1 reply
-
Hi, I think, you can achieve that, by adding custom variants And then you can use |
Beta Was this translation helpful? Give feedback.
-
Hey @damikun 👋 As mentioned above, this is a good use case for a plugin that adds a Here's an example to define the plugin: const plugin = require('tailwindcss/plugin')
module.exports = {
purge: [],
theme: {},
variants: {},
plugins: [
plugin(function ({ addVariant, e }) {
addVariant('first-letter', ({ modifySelectors, separator }) => {
modifySelectors(({ className }) => {
return `.${e(`first-letter${separator}${className}`)}:first-letter`
})
})
}),
],
} This alone won't do anything, as you would need to enable the variant on specific core plugins. Here, I will add it to the variants: {
textTransform: ({ after }) => after(['first-letter']),
}, Together, here's the config file: const plugin = require('tailwindcss/plugin')
module.exports = {
purge: [],
theme: {},
variants: {
textTransform: ({ after }) => after(['first-letter']),
},
plugins: [
plugin(function ({ addVariant, e }) {
addVariant('first-letter', ({ modifySelectors, separator }) => {
modifySelectors(({ className }) => {
return `.${e(`first-letter${separator}${className}`)}:first-letter`
})
})
}),
],
} With this, you are now able to <p class="first-letter:uppercase">hello, how cool is that!</p> Hope it helps! 👍 |
Beta Was this translation helpful? Give feedback.
-
It can be nice to have build-in "first letter uppercase class", under text-transform..
Provide ability to use CSS selector
:first-letter
https://www.w3schools.com/cssref/sel_firstletter.asp
Beta Was this translation helpful? Give feedback.
All reactions