
交互
用于控制用户是否可以在元素中选择文本的工具。
使用 select-none 可以防止选择元素及其子元素中的文本。
🌐 Use select-none to prevent selecting text in an element and its children.
Try selecting the text to see the expected behaviour
<div class="select-none ...">
The quick brown fox jumps over the lazy dog.
</div>
使用 select-text 允许在元素及其子元素中选择文本。
🌐 Use select-text to allow selecting text in an element and its children.
Try selecting the text to see the expected behaviour
<div class="select-text ...">
The quick brown fox jumps over the lazy dog.
</div>
使用 select-all 可以在用户点击时自动选择元素中的所有文本。
🌐 Use select-all to automatically select all the text in an element when a user clicks.
Try selecting the text to see the expected behaviour
<div class="select-all ...">
The quick brown fox jumps over the lazy dog.
</div>
使用 select-auto 来使用默认的浏览器文本选择行为。对于在不同断点撤销其他类如 select-none 很有用。
🌐 Use select-auto to use the default browser behavior for selecting text. Useful for undoing other classes like select-none at different breakpoints.
Try selecting the text to see the expected behaviour
<div class="select-auto ...">
The quick brown fox jumps over the lazy dog.
</div>
Tailwind 允许你使用变体修饰符在不同状态下有条件地应用工具类。例如,使用hover:select-all 仅在 hover 时应用 select-all 工具。
<div class="hover:select-all">
<!-- ... -->
</div>
有关所有可用状态修饰符的完整列表,请查看悬停、聚焦、以及其他状态 文档。
你还可以使用变体修饰符来定位媒体查询,例如响应式断点、暗黑模式、首选减少运动等。例如,使用 md:select-all 仅在中等屏幕尺寸及以上时应用 select-all 工具。
<div class="md:select-all">
<!-- ... -->
</div>