
交互
用于抑制原生表单控件样式的工具。
使用 appearance-none 重置元素上的任何浏览器特定样式。这个工具通常在创建自定义表单组件时使用。
🌐 Use appearance-none to reset any browser specific styling on an element. This utility is often used when creating custom form components.
<select>
<option>Yes</option>
<option>No</option>
<option>Maybe</option>
</select>
<div class="grid">
<select class="appearance-none row-start-1 col-start-1 bg-slate-50 dark:bg-slate-800 ...">
<option>Yes</option>
<option>No</option>
<option>Maybe</option>
</select>
<svg class="pointer-events-none row-start-1 col-start-1 ...">
<!-- ... -->
</svg>
</div>
使用 appearance-auto 可以恢复元素的默认浏览器特定样式。这在某些无障碍模式下恢复标准浏览器控件时非常有用。
🌐 Use appearance-auto to restore the default browser specific styling on an element. This is useful for reverting to the standard browser controls in certain accessibility modes.
Try emulating `forced-colors: active` in your developer tools to see the difference
<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>
Tailwind 允许你使用变体修饰符在不同状态下有条件地应用工具类。例如,使用hover:appearance-none 仅在 hover 时应用 appearance-none 工具。
<div class="appearance-auto hover:appearance-none">
<!-- ... -->
</div>
有关所有可用状态修饰符的完整列表,请查看悬停、聚焦、以及其他状态 文档。
你还可以使用变体修饰符来定位媒体查询,例如响应式断点、暗黑模式、首选减少运动等。例如,使用 md:appearance-none 仅在中等屏幕尺寸及以上时应用 appearance-none 工具。
<div class="appearance-auto md:appearance-none">
<!-- ... -->
</div>