交互
用于抑制原生表单控件样式的工具。
Class | Styles |
---|---|
appearance-none | appearance: none; |
appearance-auto | appearance: auto; |
使用 appearance-none
重置元素上的任何浏览器特定样式:
<select> <option>是</option> <option>否</option> <option>也许</option></select><div class="grid"> <select class="col-start-1 row-start-1 appearance-none bg-gray-50 dark:bg-gray-800 ..."> <option>是</option> <option>否</option> <option>也许</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> 回退至默认外观</label><label> <div> <input type="checkbox" class="appearance-none ..." /> <svg class="invisible peer-checked:visible ..."> <!-- ... --> </svg> </div> 保持自定义外观</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.