Using Sass
BUX ships its Sass source alongside the compiled CSS, for projects that build their own styles with Sass.
Getting the Sass files
The Sass source is in the npm and Composer packages and the download.
dist/scss/scss/global.scssloads all global styles and forwards the BUX Sass variables.dist/scss/components/<name>/<name>.scssholds each component's styles.
Load them with Sass's @use rule:
@use "path/to/bux/dist/scss/scss/global" as bux;
@use "path/to/bux/dist/scss/components/button/button";
.my-callout {
@include bux.breakpoint(lg) {
padding: var(--spacing-32);
}
}
Colors and spacing
Use BUX's CSS custom properties for colors and spacing, even in Sass. The color properties switch automatically between light and dark mode; the Sass color variables do not. See Dark Mode for the color tokens and how to choose between them.
.my-callout {
padding: var(--spacing-16);
color: var(--color-content-primary);
background-color: var(--color-background-secondary);
border: 1px solid var(--color-border-primary);
}
Breakpoints
BUX layouts are mobile first and use min-width queries. In Sass, use the breakpoint($name)
mixin or the $bp-sm to $bp-xxl variables. In plain CSS, use the values directly.
| Name | Min width |
|---|---|
sm | 0 |
md | 640px |
lg | 960px |
xl | 1216px |
xxl | 1440px |
Mixins
Mixins with class replacements
These mixins still work but print a warning when compiled. Use the classes below instead.
| Mixin | Replacement |
|---|---|
link-base($background, $hasVisited) | Add bux-link to the link. Use bux-link--alt or bux-link--scarlet for other backgrounds. |
form-element() | Add bux-form-element to the field's root element. |
form-input() | Add bux-form-element__control to the input or textarea. |
form-input-disabled() | Use the BUX form components, such as Text Field and Text Area, which apply disabled styling for you. |
form-input-error() | Use the BUX form components, which apply error styling for you. |
form-error-message() | Use the BUX form components, which include a styled error message. |
theme-image-toggle() | Not needed for the default .logo-light and .logo-dark classes, which BUX now toggles globally. |
Removed mixins
These mixins are no longer included in BUX: button-reset, clearfix, link-reset,
visually-hidden, visually-hidden-reset, heading, bux-list-ul-base, bux-list-ol-base and
dark-theme. For visually hidden text, use the visually-hidden class. For dark mode, use the
color tokens described in Dark Mode.