@dnb/eufemia
Version:
DNB Eufemia Design System UI Library
180 lines (138 loc) • 4.45 kB
Markdown
---
title: 'SASS mixins'
version: 10.104.0
generatedAt: 2026-04-17T18:46:12.752Z
checksum: 090b7d977ba4be5e2c4c04d199a30a4048416c59f443a56985df2f80629d9c40
---
# SASS and mixins
All CSS helper classes are to be found in `src/style/core/helper-classes/helper-classes.scss`
Most helper classes are SCSS _mixins_ which are then applied to the class when invoked.
You can import Eufemia _mixins_ directly into your SCSS styles:
```scss
'/eufemia/style/core/utilities.scss';
/** State handling */
hover {
}
focus {
}
active {
}
/**
* Media Queries and Breakpoints
* More info can be found in the sections below
*/
allBelow(large) {
}
allAbove(small) {
}
allBetween(small) {
}
/** Screen Reader Only */
srOnly() {
} // .dnb-sr-only
/** Browser Checks */
IS_EDGE {
}
IS_FF {
}
IS_CHROME {
}
IS_SAFARI_MOBILE {
}
IS_SAFARI_DESKTOP {
}
/** Eufemia DropShadow */
defaultDropShadow();
/** Eufemia Border helpers */
focusRing(
/* $whatinput: 'keyboard', $color: var(--color-emerald-green), $inset: inset */
);
extendFocusRing(
/* $first-color: null, $second-color: null, width: 0.0625rem */
);
fakeBorder(
/* $color: var(--color-emerald-green), $width: 0.0625rem, $inset: inset */
);
/** Scroll behavior */
scrollY(/* $mode: scroll */);
scrollX(/* $mode: scroll */);
hideScrollbar();
scrollbarAppearance();
/** Reset fieldset styles */
fieldsetReset();
```
## Media queries and Breakpoints
Use the `allAbove`, `allBelow` and `allBetween` mixins to add media queries to your CSS.
To prevent overlapping media queries, `0.00625em` gets added to the minimum width. This results in an increment of approximately `0.1px` when using `em` units. If you're using a unit other than `em`, you may need to adjust this value accordingly, as `0.00625px` is typically too small to effectively prevent overlaps.
| mixin | actual interval (em) | actual interval (px) |
| ----------------------- | ---------------------- | -------------------- |
| `allBelow(40em)` | 0 to 40em | 0 to 640px |
| `allBetween(40em,60em)` | 40.00625em to 60em | 640.1px to 960px |
| `allAbove(60em)` | 60.00625em to infinity | 960.1px to infinity |
```scss
'/eufemia/style/core/utilities.scss';
allBelow(small) {
// from 0px to 'small' (640px)
}
allBetween(small, medium) {
// from 640.1px ('small' + 0.1px) to 960px ('medium')
}
allAbove(medium) {
// from 960.1px ('medium' + 0.1px) and wider
}
```
`$breakpoints` is a key-value map containing all the available sizes for media queries
```scss
'/eufemia/style/core/utilities.scss';
// getting a size from $breakpoints
div {
max-width: map-get($breakpoints, medium);
}
```
### Custom offset
You can either change the default value `$breakpoint-offset` (default: 0) from `utilities.scss`, or send in a custom offset to the mixin.
```scss
'/eufemia/style/core/utilities.scss';
// Change the default offset (default: 0)
$breakpoint-offset: 10em;
// Will use the new default offset, adding 10em to the size
allBelow(large) {
}
// You can also simply send in a custom offset
allBelow(large, -5em) {
}
```
### Custom size
You can either change the default values in the `$breakpoints` array from `utilities.scss`, or send in a custom size to the mixin.
```scss
'/eufemia/style/core/utilities.scss';
// Change default sizes
$breakpoints: map-merge(
$breakpoints,
(
// redefine a size
'medium': 40em,
// add an offset to the original value
'large': map-get($breakpoints, large) + 5em
)
);
// Will use the new default 'large' size of 90em
allBelow(large) {
}
// You can also simply send in a custom size
allBelow(90em) {
}
```
## `<fieldset>` CSS reset
Removes default styling on a `fieldset` element.
` fieldsetReset($checkSpaceProps: boolean)`
If true is given, it will handle margin gracefully by checking for e.g. `dnb-space__top--` and not reset if this class exists.
```tsx
render(
<Wrapper className={fieldsetReset}>
<ComponentBox hideCode data-visual-test="helper-fieldset-reset">
<fieldset>I'm a fieldset without styling.</fieldset>
</ComponentBox>
</Wrapper>
)
```