Add new outline style, color, width and offset utilities #5887
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
outlineutilities with newoutline-style,outline-color,outline-widthandoutline-offsetutilities. 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
outlineclass 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
blackoutline that's3pxwide..outlineoutline-style: solid.outline-dashedoutline-style: dashed.outline-dottedoutline-style: dotted.outline-doubleoutline-style: double.outline-hiddenoutline-style: hidden.outline-noneoutline-style: noneoutline-color
The outline-color utilities set the color for the outline. The color values are taken from the
outlineColorkey 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-inheritoutline-color: inherit.outline-currentoutline-color: currentColor.outline-transparentoutline-color: transparent.outline-blackoutline-color: #000.outline-whiteoutline-color: #fff.outline-slate-100outline-color: #f1f5f9.outline-slate-200outline-color: #e2e8f0.outline-slate-300outline-color: #cbd5e1outline-width
The outline-width utilities set the width of the outline. The width values are taken from the
outlineWidthkey 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-0outline-width: 0px.outline-1outline-width: 1px.outline-2outline-width: 2px.outline-4outline-width: 4px.outline-8outline-width: 8pxoutline-offset
The outline-offset utilities set the offset of the outline (the distance from the element). The offset values are taken from the
outlineOffsetkey in the Tailwind config.The outline offset utilities also support arbitrary values, such as
outline-offset-[10px]..outline-offset-0outline-offset: 0px.outline-offset-1outline-offset: 1px.outline-offset-2outline-offset: 2px.outline-offset-4outline-offset: 4px.outline-offset-8outline-offset: 8pxBreaking changes
These new outline utilities replace the previous versions, which were based on the
outlineshorthand property. If you haven't customized these values or used any arbitrary values, no changes are required, as the default utilities (outline-none,outline-whiteandoutline-black) all still exist in this update.That said, please be aware that the
outline-whiteandoutline-blackstyles have changed slightly — they are no longer dotted (but now solid), and they are also no longer offset by2px..outline-black { + outline-color: #000; - outline: 2px dotted black; - outline-offset: 2px; } .outline-white { + outline-color: #fff; - outline: 2px dotted white; - outline-offset: 2px; }