Tailwind CSS: How to Disable Text Selection

Last updated on June 16, 2022 Pennywise Loading... Post a comment

In Tailwind CSS, you can prevent text from being selected by using the select-none utility class.

Example:

The code:

<body class="bg-green-200 p-20 space-y-3">
    <p class="text-xl text-blue-500">This text is selectable</p>
    <p class="select-none text-xl italic text-red-500">This text is unselectable</p>
</body>

Further reading:

You can also check out our CSS category page for the latest tutorials and examples.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

You May Also Like