互动性
appearance
用于抑制原生表单控制样式的工具。
类 | 样式 |
---|---|
appearance-none | appearance: none; |
appearance-auto | appearance: auto; |
示例(Examples)
¥Examples
删除默认外观(Removing default appearance)
¥Removing default appearance
使用 appearance-none
重置元素上的任何浏览器特定样式:
¥Use appearance-none
to reset any browser specific styling on an element:
Default browser styles applied
Remove default browser styles
<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>
此工具通常在创建自定义表单组件时使用。
¥This utility is often used when creating custom form components.
恢复默认外观(Restoring default appearance)
¥Restoring default appearance
使用 appearance-auto
恢复元素上默认的浏览器特定样式:
¥Use appearance-auto
to restore the default browser specific styling on an element:
尝试在你的开发者工具中模拟 `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>
这对于在某些辅助功能模式下恢复到标准浏览器控件非常有用。
¥This is useful for reverting to the standard browser controls in certain accessibility modes.
响应式设计(Responsive design)
¥Responsive design
在 appearance
工具前面使用断点变体如 md:
仅在 medium 屏幕尺寸及以上时应用工具:
<select class="appearance-auto md:appearance-none ..."> <!-- ... --></select>
请参阅 变体文档 详细了解如何使用变体。