1. 交互
  2. 外观

交互

外观

用于抑制原生表单控件样式的工具。

ClassStyles
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.