Topic: Generating custom button colors with the updated theme system

Lily Foster free asked 2 weeks ago


We previously added colors through a Sass theme map. After upgrading, the expected button classes are missing from compiled CSS.

How should custom variants be defined now?


Arkadiusz Idzikowski staff answered 2 weeks ago


First check whether your expected selector exists in the compiled stylesheet. A Sass map entry only affects selectors that the theme actually generates; changing variables cannot style a selector that was never emitted.

Please share the custom Sass map, the order of your MDB imports, and one expected button class. We can then trace how that variant should be generated. Keep the base button styling and its interaction states together rather than adding only a background override, which leaves hover and focus behavior incomplete.

https://mdbootstrap.com/docs/angular/components/buttons/


Lily Foster free commented 2 weeks ago

There is no .btn-workspace selector in the compiled CSS. This is the map we import after the MDB styles, and the button uses class="btn btn-workspace". I assumed adding the entry would generate that class. We only need this one custom color.

$workspace-colors: (
  "workspace": #123a52
);

Arkadiusz Idzikowski staff commented 2 weeks ago

A Sass map stores values but does not emit CSS by itself. That explains why the class is missing. For a single application variant, keep the btn class and define btn-workspace explicitly in the stylesheet loaded after MDB.

This supplies the color and interaction states together. Check the button with the keyboard as well as the mouse so that the focus indicator remains visible.

.btn-workspace {
  color: #fff;
  background-color: #123a52;
  border-color: #123a52;
}
.btn-workspace:hover { color: #fff; background-color: #0d2d40; }
.btn-workspace:focus-visible { outline: 2px solid #287fa8; outline-offset: 2px; }
.btn-workspace:disabled { opacity: 0.65; }


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB Angular
  • MDB Version: MDB5 9.1.0
  • Device: Desktop
  • Browser: Chrome
  • OS: macOS
  • Provided sample code: No
  • Provided link: No