边框
用于控制元素轮廓颜色的工具。
¥Basic usage
¥Setting the outline color
使用 outline-*
工具更改元素轮廓的颜色。
¥Use the outline-*
utilities to change the color of an element’s outline.
outline-blue-500
outline-cyan-500
outline-pink-500
<button class="outline outline-offset-2 outline-blue-500 ...">Button A</button>
<button class="outline outline-offset-2 outline-cyan-500 ...">Button B</button>
<button class="outline outline-offset-2 outline-pink-500 ...">Button C</button>
¥Changing the opacity
使用颜色透明度修饰符来控制元素轮廓颜色的透明度。
¥Use the color opacity modifier to control the opacity of an element’s outline color.
outline-blue-500/50
<button class="outline-2 outline-blue-500/50 ...">Save Changes</button>
你可以使用 透明度比例 中定义的任何值,或者如果你需要偏离你的设计令牌,则可以使用任意值。
¥You can use any value defined in your opacity scale, or use arbitrary values if you need to deviate from your design tokens.
<button class="outline-4 outline-pink-400/[.55] ..."></button>
Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:outline-blue-400
to only apply the outline-blue-400
utility on hover.
<button class="outline hover:outline-blue-400">
<!-- ... -->
</button>
For a complete list of all available state modifiers, check out the Hover, Focus, & Other States documentation.
You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. For example, use md:outline-blue-400
to apply the outline-blue-400
utility at only medium screen sizes and above.
<button class="outline md:outline-blue-400">
<!-- ... -->
</button>
To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.
¥Using custom values
¥Customizing your theme
By default, Tailwind makes the entire default color palette available as outline colors. You can customize your color palette by editing theme.colors
or theme.extend.colors
in your tailwind.config.js
file.
module.exports = {
theme: {
extend: {
colors: {
'regal-blue': '#243c5a',
},
}
}
}
Alternatively, you can customize just your outline colors by editing theme.outlineColor
or theme.extend.outlineColor
in your tailwind.config.js
file.
Learn more about customizing the default theme in the theme customization documentation.
¥Arbitrary values
If you need to use a one-off outline-color
value that doesn’t make sense to include in your theme, use square brackets to generate a property on the fly using any arbitrary value.
<button class="outline-[#243c5a]">
<!-- ... -->
</button>
Learn more about arbitrary value support in the arbitrary values documentation.