User Select

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

@include('_partials.class-table', [ 'rows' => [ [ '.select-none', 'user-select: none;', "Disable selecting text in an element.", ], [ '.select-text', 'user-select: text;', "Allow selecting text in an element.", ], [ '.select-all', 'user-select: all;', "Allow clicking to select all text in an element.", ], [ '.select-auto', 'user-select: auto;', "Default browser behavior", ], ] ])

Disable selecting text

Use .select-none to prevent selecting text in an element and its children.

@component('_partials.code-sample', ['class' => 'text-center'])

This text is not selectable
@slot('code')
This text is not selectable
@endslot @endcomponent

Allow selecting text

Use .select-text to allow selecting text in an element and its children.

@component('_partials.code-sample', ['class' => 'text-center'])

This text is selectable
@slot('code')
This text is selectable
@endslot @endcomponent

Select all text in one click

Use .select-all to automatically select all the text in an element when a user clicks.

@component('_partials.code-sample', ['class' => 'text-center'])

Click anywhere in this text to select it all
@slot('code')
Click anywhere in this text to select it all
@endslot @endcomponent

Auto

Use .select-auto to use the default browser behavior for selecting text. Useful for undoing other classes like .select-none at different breakpoints.

@component('_partials.code-sample', ['class' => 'text-center'])

This text is selectable
@slot('code')
This text is selectable
@endslot @endcomponent

Customizing

@include('_partials.variants-and-disabling', [ 'utility' => [ 'name' => 'user-select', 'property' => 'userSelect', ], 'variants' => [ 'responsive', ], ])

Tailwind UI is now in early access!