Add new outline style, color, width and offset utilities #5887
+69
−43
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR replaces the existing
outline
utilities with newoutline-style
,outline-color
,outline-width
andoutline-offset
utilities. This approach is more inline with how the existing ring and border utilities work.outline-style
The outline-style utilities both enable (or disable) the outline styles, and also determine what type of outline should be drawn. Note that for now this only includes the same values as are available for border styles.
The
outline
class here is a shorthand foroutline-solid
, since it's the most common style to use.Note also that when you don't specify an outline width or color, you'll just get the browser defaults, which is a
black
outline that's3px
wide..outline
outline-style: solid
.outline-dashed
outline-style: dashed
.outline-dotted
outline-style: dotted
.outline-double
outline-style: double
.outline-hidden
outline-style: hidden
.outline-none
outline-style: none
outline-color
The outline-color utilities set the color for the outline. The color values are taken from the
outlineColor
key in the Tailwind config, which extends the default color palette by default.The outline color utilities support both the alpha shorthand, such as
outline-red-600/50
, as well as arbitrary values, such asoutline-[#FF0000]
.If an outline color is not set it falls back to the browser default, which is
black
..outline-inherit
outline-color: inherit
.outline-current
outline-color: currentColor
.outline-transparent
outline-color: transparent
.outline-black
outline-color: #000
.outline-white
outline-color: #fff
.outline-slate-100
outline-color: #f1f5f9
.outline-slate-200
outline-color: #e2e8f0
.outline-slate-300
outline-color: #cbd5e1
outline-width
The outline-width utilities set the width of the outline. The width values are taken from the
outlineWidth
key in the Tailwind config.The outline width utilities also support arbitrary values, such as
outline-[10px]
.If an outline width is not set it falls back to the browser default, which is
3px
..outline-0
outline-width: 0px
.outline-1
outline-width: 1px
.outline-2
outline-width: 2px
.outline-4
outline-width: 4px
.outline-8
outline-width: 8px
outline-offset
The outline-offset utilities set the offset of the outline (the distance from the element). The offset values are taken from the
outlineOffset
key in the Tailwind config.The outline offset utilities also support arbitrary values, such as
outline-offset-[10px]
..outline-offset-0
outline-offset: 0px
.outline-offset-1
outline-offset: 1px
.outline-offset-2
outline-offset: 2px
.outline-offset-4
outline-offset: 4px
.outline-offset-8
outline-offset: 8px
Breaking changes
These new outline utilities replace the previous versions, which were based on the
outline
shorthand property. If you haven't customized these values or used any arbitrary values, no changes are required, as the default utilities (outline-none
,outline-white
andoutline-black
) all still exist in this update.That said, please be aware that the
outline-white
andoutline-black
styles have changed slightly — they are no longer dotted (but now solid), and they are also no longer offset by2px
.