Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabling box shadows on buttons still renders box-shadows #32032

Closed
wvandenhaak opened this issue Oct 31, 2020 · 4 comments
Closed

Disabling box shadows on buttons still renders box-shadows #32032

wvandenhaak opened this issue Oct 31, 2020 · 4 comments

Comments

@wvandenhaak
Copy link

I found the following issue while customizing Bootstrap (version 4.5.3)

When disabling shadows using the following settings, buttons still have a box shadow:
$enable-shadows: false;
$btn-focus-box-shadow: none;
$btn-active-box-shadow: none;

The button mixin has the following code (lines 23-28, 54-59 and 93-98):

@if $enable-shadows {
  @include box-shadow($btn-box-shadow, 0 0 0 $btn-focus-width rgba(mix(color-yiq($background), $border, 15%), .5));
} @else {
  // Avoid using mixin so we can pass custom focus shadow properly
  box-shadow: 0 0 0 $btn-focus-width rgba(mix(color-yiq($background), $border, 15%), .5);
}

As shown in the else-statement a box shadow is still generated.

Suggested change:
Move the box shadow settings to the _variables.scss file and apply the variables in the mixin.
The forms mixins already has this setup, see example below.

Example from the forms mixin (line 19-24)

@if $enable-shadows {
  @include box-shadow($input-box-shadow, $input-focus-box-shadow);
} @else {
  // Avoid using mixin so we can pass custom focus shadow properly
  box-shadow: $input-focus-box-shadow;
}
@wvandenhaak wvandenhaak changed the title Disabling box shadows on buttons is not possible Disabling box shadows on buttons still renders box-shadows Oct 31, 2020
@mdo
Copy link
Member

mdo commented Oct 31, 2020

We don't use the $input-focus-box-shadow variable there as buttons and inputs get colored focus states with their validation states and modifier classes (e.g., :invalid and .btn-danger). We always want there to be a focus state, which is why we've coded it the way we have.

@wvandenhaak
Copy link
Author

So the only way to disable the box shadows on buttons when they get :focus (for example) is to override them in custom CSS or set $btn-focus-width to 0?

With the following settings:

$enable-shadows: false;

$input-box-shadow: none;
$input-btn-focus-box-shadow: none;

$btn-box-shadow: none;
$btn-active-box-shadow: none;
$btn-focus-box-shadow: none;

Inputs don't have box-shadows when focussed but buttons do (input on top, button below, both in focus state, primary color pink):
image

@rexwebmedia
Copy link

Just use simple class (.shadow-none), like this

<button class="btn btn-dark shadow-none fw-bold>Click Here</button>

@wvandenhaak
Copy link
Author

Just use simple class (.shadow-none), like this

<button class="btn btn-dark shadow-none fw-bold>Click Here</button>

I was hoping Bootstraps was able to disable box-shadow on buttons when customizing in sass.
Adding this class is a fine workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants