For Bootstrap 4, I needed circular buttons and their size had to match the height of the default buttons, or the height of inputs - for inline forms.
I've used the following code:
SCSS
$btn-height-border: $btn-border-width * 2;
$btn-circular-height: add(
$btn-line-height * 1em,
add($btn-padding-y * 2, $btn-height-border, false)
);
$btn-circular-height-sm: add(
$btn-line-height-sm * 1em,
add($btn-padding-y-sm * 2, $btn-height-border, false)
);
$btn-circular-height-lg: add(
$btn-line-height-lg * 1em,
add($btn-padding-y-lg * 2, $btn-height-border, false)
);
.btn-circular {
width: $btn-circular-height;
height: $btn-circular-height;
padding-right: 0;
padding-left: 0;
text-align: center;
border-radius: 50% !important;
line-height: 1;
&.btn-sm {
width: $btn-circular-height-sm;
height: $btn-circular-height-sm;
}
&.btn-lg {
width: $btn-circular-height-lg;
height: $btn-circular-height-lg;
}
}
Codepen:
https://codepen.io/andreivictor/pen/vYvBJKB