Utility
Atomic classes that specialize in setting single style properties.
Atomic classes that specialize in setting single style properties.
npm install @vrembem/utility@use "@vrembem/utility";Utility comes with the following Sass configuration options that can be set using either the config module or Sass with clause methods.
@use "@vrembem/utility" with (
$config: (
// Controls whether module styles are output. This can be overridden on a per
// module basis using the `utility-output-exceptions` config option.
// @type boolean
"output": true,
// Modules to exclude from the output rule set in `utility-output`
// @type list
"output-exceptions": (),
// A map containing module names as keys and their preferred class selectors
// @type map
"classes": (),
// A prefix to apply to utility class selectors. Provided value is
// automatically suffixed with a "-" character when applied.
// @type string
"prefix": "",
// Whether or not utility styles should be output with the !important flag
// @type boolean
"important": false,
// A map of border-radius utilities to output
// @type map
"border-radius": (
"": tokens.get("border-radius"),
"lg": tokens.get("border-radius-lg"),
"circle": tokens.get("border-radius-circle"),
"square": 0
),
// A list of display value properties to output
// @type list
"display": (
"breakpoints": true,
"inline": inline,
"flex": flex,
"inline-flex": inline-flex,
"grid": grid,
"inline-grid": inline-grid,
"block": block,
"inline-block": inline-block,
"none": none
),
// A spacing scale used to output margin, padding, and spacing utilities
// @type map
"spacing": (
"0": 0,
"xs": tokens.get("spacing"),
"sm": calc(tokens.get("spacing") * 2),
"": calc(tokens.get("spacing") * 4),
"lg": calc(tokens.get("spacing") * 8),
"xl": calc(tokens.get("spacing") * 12)
),
// A map of gap utilities to output
// @type map
"gap": (
"0": 0,
"xs": tokens.get("spacing"),
"sm": tokens.get("spacing-sm"),
"": tokens.get("spacing-md"),
"lg": tokens.get("spacing-lg"),
"xl": tokens.get("spacing-xl")
),
// A map of max-width utilities to output
// @type map
"max-width": (
"none": none,
"xs": 45rem,
"sm": 60rem,
"": 70rem,
"lg": 80rem,
"xl": 90rem,
"full": 100%
),
// A map of font-weight keys and values to output
// @type map
"font-weight": (
"thin": 100,
"extra-light": 200,
"light": 300,
"regular": 400,
"medium": 500,
"semi-bold": 600,
"bold": 700,
"extra-bold": 800,
"black": 900,
"lighter": lighter,
"bolder": bolder
),
// The range of flex-grow and flex-shrink utilities to output
// @type number
"flex-range": 6
)
);Utility modules each have their own output styles. These are all output by default when the utility package is loaded. There are two ways to control which modules are output using the utility-output and utility-output-exceptions configuration options.
utility-outputbooleanControls whether module styles are output. Specify exceptions using the utility-output-exceptions config option.
@include config.set("utility-output", false);@defaulttrue
utility-output-exceptionslistModules listed in this configuration are exceptions to the value set in utility-output. If utility-output is true, modules listed will not be output. If utility-output is false, modules listed will be output.
@include config.set("utility-output-exceptions", (
"background", "foreground"
));@default()
Use the utility-output configuration to toggle output for all modules. Add exceptions to the utility-output-exceptions list to override the output option for specific modules.
// Import the config module
@use "@vrembem/core/config";
// Disable the output of specific modules
@include config.set("utility-output-exceptions", (
"gap",
"margin",
"padding"
));
// Disable the output of all modules except for "margin" and "padding"
@include config.set((
"utility-output": false
"utility-output-exceptions": (
"margin",
"padding"
)
));Once loaded, the utility package provides a number of classes that can be used independently or to supplement other loaded components.
<!-- Using utility classes independently -->
<div class="padding background-shade border border-radius">
<p class="text-bold text-align-center">...</p>
</div>
<!-- Using utility classes with other components -->
<div class="grid justify-content-center">
<div class="grid__item row-full">...</div>
<div class="grid__item row-auto">...</div>
</div>To customize utility class selectors used by modules, map the module name to your preferred class selector in the utility-classes config option.
utility-classesmapA map containing module names as keys and their preferred class selectors as values. For example, to use the class .radius instead of .border-radius, set the following value:
@include config.set("utility-classes", (
"border-radius": "radius"
));@default()
It's also possible to provide a prefix to all utility classes using the utility-prefix config option.
utility-prefixstringA prefix to apply to utility class selectors. Provided value is automatically suffixed with a "-" character when applied.
@include config.set("utility-prefix", "u");
// Result: .display-none > .u-display-none@default""
Below is a list of each utility module, their available variants and intended usage. Some modules also have configuration options that can be used to configure their output.
Utilities for setting the background-color property of an element. Variants are built from both the core palette as well as the palette-variants configuration options.
| Class | Styles |
|---|---|
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
There are no variables that match your search.
<button class="background-primary ...">Button 1</button>
<button class="background-secondary-100 ...">Button 2</button>
<button class="background-neutral-600 ...">Button 3</button>The background utility module also includes options for setting the background-clip property.
There are no variables that match your search.
Utilities for setting the color property of an element. Variants are built from both the core palette as well as the palette-variants configuration options.
| Class | Styles |
|---|---|
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
There are no variables that match your search.
<button class="foreground-primary ...">Button 1</button>
<button class="foreground-secondary ...">Button 2</button>
<button class="foreground-neutral ...">Button 3</button>
<button class="foreground-important ...">Button 4</button>Utilities for setting the border property with optional sides variants of an element. Also includes utilities for setting variants of the border-color and border-style properties.
| Class | Styles |
|---|---|
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
There are no variables that match your search.
Utilities for setting the border-radius property of an element with optional corner variants. The value and variants used by the border-radius utility is built from the utility-border-radius configuration option.
| Class | Styles |
|---|---|
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
There are no variables that match your search.
Utilities for setting the box-shadow property on an element with depth variants.
<div class="box-shadow-outline"></div>
<div class="box-shadow-xs"></div>
<div class="box-shadow-sm"></div>
<div class="box-shadow-md"></div>
<div class="box-shadow-lg"></div>
<div class="box-shadow-xl"></div>| Class | Styles |
|---|---|
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
There are no variables that match your search.
Utilities for setting the drop-shadow filter on an element with depth variants.
<div class="drop-shadow-outline"></div>
<div class="drop-shadow-xs"></div>
<div class="drop-shadow-sm"></div>
<div class="drop-shadow-md"></div>
<div class="drop-shadow-lg"></div>
<div class="drop-shadow-xl"></div>| Class | Styles |
|---|---|
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
There are no variables that match your search.
Utilities for setting the display property of an element with optional breakpoint modifiers. Display variants are built using the values set in the utility-display configuration option.
There are no variables that match your search.
Display utilities also come with breakpoint modifiers. These can be used by prefixing a breakpoint key to any of the above listed utilities. Breakpoint modifiers are built from the core breakpoints configuration option.
This is only visible for mobile users
This is only visible for desktop users
<div class="display-block md:display-none">
<p>This is only visible for mobile users</p>
</div>
<div class="display-none md:display-block">
<p>This is only visible for desktop users</p>
</div>Utilities for setting the margin property of an element. Margin variants are built using the values set in the utility-gap configuration option.
| Class | Styles |
|---|---|
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
There are no variables that match your search.
Utilities for setting the padding property of an element. Padding variants are built using the values set in the utility-gap configuration option.
| Class | Styles |
|---|---|
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
There are no variables that match your search.
Utilities for setting the margin-top property of all direct children of an element. Spacing variants are built using the values set in the utility-gap configuration option.
| Class | Styles |
|---|---|
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
There are no variables that match your search.
Utilities for setting the gap property of an element. Gap variants are built using the values set in the utility-gap configuration option.
| Class | Styles |
|---|---|
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
There are no variables that match your search.
Utilities for setting the justify-content, justify-items and justify-self properties of an element.
There are no variables that match your search.
Utilities for setting the align-content, align-items and align-self properties of an element.
There are no variables that match your search.
Utilities for setting the place-content, place-items and place-self properties of an element.
There are no variables that match your search.
Utilities for setting the order property of an element.
There are no variables that match your search.
Utilities for setting the flex specific properties of an element. These pair well with the flex component to provide more granular control of flex items.
There are no variables that match your search.
Utilities for controlling the flex-grow property. These utilities are generated using the value set in utility-flex-range config options map.
<div class="flex">
<div class="flex-grow-3">...</div>
<div>...</div>
<div>...</div>
</div>Utilities for controlling the flex-shrink property. These utilities are generated using the value set in utility-flex-range config options map.
<div class="flex flex-nowrap">
<div class="flex-shrink-3">...</div>
<div>...</div>
</div>Utilities for controlling the flex-basis property which sets the initial main size of a flex item.
<div class="flex">
<div class="flex-basis-auto">...</div>
<div>...</div>
<div>...</div>
</div>Utilities for setting the position property of an element.
There are no variables that match your search.
Utilities for setting the overflow, overflow-x and overflow-y properties of an element.
There are no variables that match your search.
Utilities for setting the max-width property of an element. Max-width variants are built using the values set in the utility-max-width configuration option.
There are no variables that match your search.
Utilities for setting various font based properties of an element. This includes font-family, font-size, line-height, font-weight and font-style. Font-weight variants are built using the values set in the utility-font-weight configuration option.
| Class | Styles |
|---|---|
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
There are no variables that match your search.
Utilities for setting various text properties of an element. This includes things like text-transform, text-align, text-decoration, and text-wrap.
There are no variables that match your search.
Utilities for setting transition and transition-duration properties of an element.
| Class | Styles |
|---|---|
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
Copied! | Copied! |
There are no variables that match your search.