--- title: Borders path: utilities/borders status: Stable status_issue: 'https://github.com/github/design-systems/issues/72' source: 'https://github.com/primer/css/tree/master/src/utilities/borders.scss' bundle: utilities --- import {palettes, borders} from '../../src/color-variables' import {PaletteTable, PaletteCell, PaletteValue} from '../../src/color-system' Utilities for borders, and border radius. ## Default border The default border utility applies a solid, 1px border, with a default gray color. ```html live
.border
``` Borders can be applied to a specific edge or to the X and Y axes individually: ```html live
.border-left
.border-top
.border-bottom
.border-right
.border-x
.border-y
``` Remove borders from all sides or a single side with `.border-0`, `.border-top-0`, `.border-right-0`, `.border-bottom-0`, `.border-left-0`. ```html live
.border-top-0
``` ## Border colors Override default border colors with blue, green, red, purple, yellow, and gray border color utilities. ```html live
.border-blue
.border-blue-light
.border-green
.border-green-light
.border-red
.border-red-light
.border-purple
.border-yellow
.border-gray-light
.border-gray-dark
``` ### Borders with alpha transparency Use `border-black-fade` to add an rgba black border with an alpha transparency of `0.15`. This is useful when you want a border that tints the background color. The shade of black we use matches the hue of the GitHub dark header and our gray color palette: `rgba(27,31,35, 0.15)`. ```html live
.border-black-fade .bg-blue-light
.border-black-fade .bg-red-light
``` On dark backgrounds use `border-white-fade` instead. It adds an rgba white border with an alpha transparency of `0.15`. ```html live
.border-white-fade
``` Use `.border-white-fade-xx` to add a white border with various levels of alpha transparency. ```html live
.border-white-fade-15
.border-white-fade-30
.border-white-fade-50
.border-white-fade-70
.border-white-fade-85
.border-white-fade-15
.border-white-fade-30
.border-white-fade-50
.border-white-fade-70
.border-white-fade-85
``` ## Border style Use `border-dashed` to give an element a dashed border. ```html live
.border-dashed
``` ## Rounded corners Use the following utilities to add or remove rounded corners: `rounded-0` removes rounded corners, `rounded-1` applies a border radius of 3px, `rounded-2` applies a border radius of 6px. `.circle` applies a border radius of 50%, which turns square elements into perfect circles. ```html live
.rounded-0
.rounded-1
.rounded-2
.circle
``` You can also add rounded corners to each edge (top, right, bottom, left) with the following utilities: ```html live
.rounded-top-1
.rounded-right-1
.rounded-bottom-1
.rounded-left-1
``` ## Responsive borders You can adjust border widths on all sides or each side individually with responsive border utilities: - `border-(sm|md|lg|xl)` adds borders on all sides at and above the breakpoint. The `border-(sm|md|lg|xl)` shorthand is also supported. - `border-(sm|md|lg|xl)-0` removes borders from all sides at and above the breakpoint. - `border-(sm|md|lg|xl)-(top|right|bottom|left)` adds a border on the given side at and above the breakpoint. - `border-(sm|md|lg|xl)-(top|right|bottom|left)-0` the border from the given side at and above the breakpoint. ```html live
.border-top .border-sm-right .border-md-bottom .border-md-top-0
``` ## Border color utilities `.${props.aliases.border}`}, 'variable', 'value' ]} style={{borderSpacing: '0 4px'}} />