User select

Utilities for controlling whether the user can select text in an element.

In this article

Class Properties
.select-none user-select: none;
.select-text user-select: text;

Usage

Use .select-none to prevent text from being selected in an element (and its children).

<div class="select-none bg-gray-100 p-4">
  This text is not selectable
</div>

Use .select-text to allow text to be selected in an element (and its children).

<div class="select-text bg-gray-100 p-4">
  This text is selectable
</div>

Variants

By default, no responsive or hover-state variants are generated for user select utilities.

Responsive

To include responsive variants like .md:select-none, add "user-select" to the $responsive-variants variable in your theme’s _variables.scss file when recompiling your CSS:

$responsive-variants: (
  // ...
  "user-select",
);

Hover-state

To include hover-state variants like .hover:select-none, add "user-select" to the $hover-variants variable:

$hover-variants: (
  // ...
  "user-select",
);

Questions or feedback about this article? Let us know