Custom Bootstrap Button with Sass/Scss

sass

Bootstrap 4 Sass module provides mixin parameterized button-variant, which can be used to create customized coloured buttons.

The mixin declaration is as:

@mixin button-variant(
  $background,
  $border,
  $hover-background,
  $hover-border,
  $active-background,
  $active-border
);

$background and $border parameters must be provided, and rest are optional parameters. It automatically generates button text color in contrast to the provided background color

In action

@import node_modules/bootstrap/scss/mixin;

$feature-bg: #ffd803;

.btn-feature {
  @include button-variant($feature-bg, darken($feature-bg, 3%));

  // optitional
  // color: #fff; #uncomment and add your color
}
<button class="btn btn-feature">Feature</button>

Subscribe button that you see on this site has been made using the above technique.

This site uses third-party cookies to gather website usage and performance data.