交互
用于抑制原生表单控件样式的工具类。
| Class | Styles |
|---|---|
appearance-none | appearance: none; |
appearance-auto | appearance: auto; |
使用 appearance-none 重置元素上的任何浏览器特定样式:
<select> <option>Yes</option> <option>No</option> <option>Maybe</option></select><div class="grid"> <select class="col-start-1 row-start-1 appearance-none bg-gray-50 dark:bg-gray-800 ..."> <option>Yes</option> <option>No</option> <option>Maybe</option> </select> <svg class="pointer-events-none col-start-1 row-start-1 ..."> <!-- ... --> </svg></div>这个工具类通常在创建自定义表单组件时使用。
使用 appearance-auto 恢复元素上的默认浏览器特定样式:
在开发者工具中尝试模拟 `forced-colors: active` 以查看差异
<label> <div> <input type="checkbox" class="appearance-none forced-colors:appearance-auto ..." /> <svg class="invisible peer-checked:visible forced-colors:hidden ..."> <!-- ... --> </svg> </div> Falls back to default appearance</label><label> <div> <input type="checkbox" class="appearance-none ..." /> <svg class="invisible peer-checked:visible ..."> <!-- ... --> </svg> </div> Keeps custom appearance</label>这对于在特定的无障碍模式下恢复到标准浏览器控件非常有用。
Prefix an appearance utility with a breakpoint variant like md: to only apply the utility at medium screen sizes and above:
<select class="appearance-auto md:appearance-none ..."> <!-- ... --></select>Learn more about using variants in the variants documentation.