mlut documentation

9 #settings Settings

Most of the settings are stored in large maps, which are called depending on the area: utils, at-aules etc. Such settings are divided into two types, depending on the contents: data and configurations. Next, we will call their databases and configures, accordingly.

For user settings, separate maps are provided, which differ in the suffix. It is in them that you add changes in the configuration and they also merge into the original maps.

  • maps with data: source suffix - db, user's - data
  • maps with configs: source suffix - cfg, user's - config
@use 'mlut/tools' with (
	$utils-config: (
		'states': (
			'custom': (
				'are': '[aria-expanded=“true”]',
			),
		),
	),
	$at-rules-data: (
		'container': (
			'alias': 'c',
		),
	),
);

If you want to completely overwrite map or one of its fields, specify null. Below in the configuration use *mapname*-ext and then your values.

@use 'mlut/tools' as ml with (
	$utils-data: (
		'utils': (
			'registry': (
				'Ps': null,
			),
		),
	),
	$utils-data-ext: (
		'utils': (
			'registry': (
				'Ps': (
					'properties': position,
					'keywords': ('sc': sticky),
				),
			)
		),
	),
);

@debug ml.uv('Ps-sc'); // sticky
@debug ml.uv('Ps-a'); // a

This is relevant for some smaller maps like a $breakpoints. In the specific settings will specified which maps have the possibility of rewriting using ext.

For the time being, you can look at the structure of maps with the settings in the code, but later it will be described in the documentation.

Source: content/main.css, line 1482

9.1 #settings.at_rules At-rules

Settings for media queries and other CSS at-rules. There is a small database and several configs.

Source: ../src/sass/tools/settings/common/_at-rules.scss, line 8

9.1.1 #settings.at_rules.breakpoints Breakpoints

Breakpoints are stored in the config $at-rules-cfg, in the breakpoints section. For convenience, they are configured in a separate map $breakpoints. You can see an example of simple use here.

Name Value
<sm 0px
sm 520px
md 768px
lg 992px
xl 1200px

To fully rewrite breakpoints, use $breakpoints-ext map:

@use 'mlut/tools' as ml with (
	$breakpoints: null,
	$breakpoints-ext: (
		'sm': 768px,
		'md': 1200px,
		'lg': 1440px,
	),
);

@debug map.get(ml.$at-rules-cfg, 'breakpoints');
// (
//   'sm': 768px,
//   'md': 1200px,
//   'lg': 1440px,
// )
Source: ../src/sass/tools/settings/common/_at-rules.scss, line 26

9.1.2 #settings.at_rules.data Data

$at-rules-db - map, the keys in which are the names of the at-rules, and the values are map with options. In the options of each at-rule there is a custom map, to which you can add alias for custom expressions. See example here.

Below are the at-rule options

Parameters:
  • alias
    string
    the abbreviation that will be used in the utils components. It will be converted into at-crule name. For example: @s => @supports
  • default
    boolean
    It can be true, only in one at-rule. Sets at-rule by default. This means that this at-rule will be used, without an indication of alias after the @ symbol. By default, media is default at-rule
    Defaults to: false
  • custom
    map
    Here you can set alias for custom expressions. See the example above
Source: ../src/sass/tools/settings/common/_at-rules.scss, line 14

9.2 #settings.general General

Settings that affect the work of the all toolkit.

Parameters:
  • $browser-font-size
    font size for converting px to rem. 16px used because is default font size in settings of most browsers.
    Defaults to: 16px
  • $su
    space unit value
    Defaults to: 0.25rem
  • $css-vars-fallback
    add fallback for values in grid-gutters units
    Defaults to: false
  • $css-transition-time
    default transition duration.
    Defaults to: 0.3s
  • $ratio-box-flex
    adds a more advanced version of Ratio-box helper with an arbitrary height - ratio-box-flex
    Defaults to: false
  • $wrapper-max-width
    max width of the Wraper helper
    Defaults to: 1200px
  • $css-var-prefix
    prefix for the CSS custom properties, which are generated in the values of utilities. For example, value of W-$myCard with prefix: var(--ml-myCard), and without: var(--myCard)
    Defaults to: 'ml-'
  • $class-prefix
    prefix, which will be added to CSS classes of all utilities. This can be useful when using mlut on top of the existing CSS
Source: ../src/sass/tools/settings/base/_general.scss, line 5

9.3 #settings.gs Grid system

Settings that affect the work of grid system both modern and legacy.

  • modern grid is based on CSS Grid and is built using common grid utilities, such as Gtc, Gap etc
  • legacy grid system is based on flexbox and works with helpers and custom utilities, such as -Gscc, -Gsf etc.
Parameters:
  • $legacy-grid-system
    enable legacy grid system and generate some CSS for it
    Defaults to: false
  • $gs-default-gtr
    default gutter on large width screen. Used as fallback for --ml-gg.
    Defaults to: 4u
  • $gs-columns
    columns count.
    Defaults to: 12
  • $gs-gutters
    map with grid gutters on breakpoints.
Source: ../src/sass/tools/settings/high/_grid.scss, line 5

9.3.1 #settings.gs.gtr Gutters

The gutters are stored in $gs-gutters map. The keys in it are the names of the breakpoints, and the values are gutter. It is automatically filled out based on breakpoints. If you want to supplement or change gutters, use $gs-gutters-ext. If you want to completely overwrite the initial values, specify them in $gs-gutters in the config. Pay attention that this behavior is different from all other settings like a breakpoints

Gutters value on breakpoints:

Breakpoint Gutter
<sm 3u
sm 3u
md 3u
lg 4u
xl 4u
xxl 4u
Source: ../src/sass/tools/settings/high/_grid.scss, line 19

9.4 #settings.utils Utilities

In the settings of utilities, there are both data and configs.

Source: ../src/sass/tools/settings/base/_utils.scss, line 4

9.4.1 #settings.utils.config Config

Most of the settings are stored here, on the basis of which utilities work. Below are some sections that may be useful during customization.

Source: ../src/sass/tools/settings/base/_utils.scss, line 82

9.4.1.1 #settings.utils.config.conversion Conversion type

Available on the key conversion-types. This is a map, the keys in which are names of types that are used in utility options. The values in a map are a list of converters through which the value of utilities passes.

$utils-cfg: (
	'conversion-types': (
		'angle': ('angle', 'global-kw', 'cust-prop'),
		'grid-span': ('grid-span', 'num-length', 'global-kw', 'cust-prop'),
	),
);

Each converter is a function that returns, either an converted or initial value. By default, if the value was converted, then the process stops, else the value passes to the next converter from the list. If not a single converter has no worked, then at the result we get the initial value. But this behavior can be changed when adding a keyword Pl(pipeline) to the list. The converters specified after it will be applied regardless of whether the value was converted in one of them. The list of all converters can be viewed in the code, but later they will be added here

Below you can find all available types of conversion. In the description of each type there will be a schema: a list of converters and keywords on which the conversion depends. For DRY reason, in the schema used Sass variables containing frequently used converters. They will be presented in the documentation as meta-types. You can use these variables when adding new types of conversion. In addition, the description of the type will have examples of its work.

Source: ../src/sass/tools/settings/base/_utils.scss, line 119
9.4.1.1.1 #settings.utils.config.conversion.abbr-kw abbr-kw

Expand abbreaviations of utilities. Schema:

('abbr-kw': list.join('abbr', $uv-type-default))

Usage:

@debug ml.uv('Wlc-tf'); // transform
@debug ml.uv('Ts-bdc;2s,c;1s'); // border-color 2s, color 1s
Source: ../src/sass/tools/settings/base/_utils.scss, line 257
9.4.1.1.2 #settings.utils.config.conversion.angle angle

Converts angles. Schema:

('angle': list.join('angle', $uv-type-base))

Usage:

@debug ml.uv('-Rt45d'); // 45deg
@debug ml.uv('-Rt-50g'); // -50grad
@debug ml.uv('-Sk3.14r;2r'); // 3.14rad 2rad
@debug ml.uv('-Hur-1.5t'); // -1.5turn
Source: ../src/sass/tools/settings/base/_utils.scss, line 224
9.4.1.1.3 #settings.utils.config.conversion.color color

Converts colors. Schema:

('color': list.join('color', $uv-type-base))

Usage:

@debug ml.uv('C-tp'); // transparent
@debug ml.uv('Bgc#c06*$bgAlpha'); // rgba(204, 0, 102, var(--ml-bgAlpha, 1))

// you can use custom color keyword that you added in the database
@debug ml.uv('Bgc-purple50*20p'); // rgba(102, 0, 204, 0.2)
Source: ../src/sass/tools/settings/base/_utils.scss, line 240
9.4.1.1.4 #settings.utils.config.conversion.gradient gradient

Converts values in the gradient functions. Schema:

('gradient': (
	'keyword', 'color', 'cust-prop', 'Pl', 'number', 'angle', 'global-kw'
))

Usage:

@debug ml.uv('-Gdrl-b;r,black,#ff0'); // repeating-linear-gradient(to bottom right, black, #ff0)
@debug ml.uv('-Gdl-50d,blue;3r,cc;80p'); // linear-gradient(50deg, blue 3rem, currentColor 80%)
Source: ../src/sass/tools/settings/base/_utils.scss, line 313
9.4.1.1.5 #settings.utils.config.conversion.grid-span grid-span

Converts special keywords, to specify the sizes of the grid items in spans. Schema:

('grid-span': list.join(('grid-span', 'num-length'), $uv-type-base))

Usage:

@debug ml.uv('Gc-s3'); // span 3 / span 3
Source: ../src/sass/tools/settings/base/_utils.scss, line 285
9.4.1.1.6 #settings.utils.config.conversion.grid-tpl grid-tpl

Adds converting of special keywords for grid templates to the default type. Schema:

('grid-tpl': list.join('grid-tracks', $uv-type-default))

Usage:

@debug ml.uv('Gtc-t4'); // repeat(4, minmax(0, 1fr))
@debug ml.uv('G-t3/af;d;15r'); // repeat(3, minmax(0, 1fr)) / auto-flow dense 15rem
Source: ../src/sass/tools/settings/base/_utils.scss, line 271
9.4.1.1.7 #settings.utils.config.conversion.kw-num-length kw-num-length

Type works almost as a default type, with the exception of that it does not convert numbers without units of measurement in a pixels. Schema:

('kw-num-length': list.set-nth($uv-type-default, 2, 'num-length'))

Usage:

@debug ml.uv('Fnw300'); // 300
@debug ml.uv('Fnw-bd'); // bolder
@debug ml.uv('Lnh4.5u'); // 1.125rem
Source: ../src/sass/tools/settings/base/_utils.scss, line 195
9.4.1.1.8 #settings.utils.config.conversion.meta_base $uv-type-base

The basic meta type on which all other types are based. Schema:

$uv-type-base: ('global-kw', 'cust-prop');

Usage:

// global keywords
@debug ml.uv('C-ih'); // inherit
@debug ml.uv('W-gSm'); // 520px - sm breakpoints

// custom properties
@debug ml.uv('W-$myCard?200'); // var(--ml-myCard, 200px)
Source: ../src/sass/tools/settings/base/_utils.scss, line 136
9.4.1.1.9 #settings.utils.config.conversion.meta_default $uv-type-default

Meta type that corresponds to the default conversion type. If the type of conversion is not specified for the utility, then this will be used. Schema:

$uv-type-default: list.join(('keyword', 'number'), $uv-type-base);

// and below in the conversion types
'conversion-types': (
	'default': $uv-type-default,

Usage:

// keyword
@debug ml.uv('Ai-c'); // center
@debug ml.uv('Bd'); // 1px solid

// number
@debug ml.uv('W200'); // 200px
@debug ml.uv('Ml-0.7'); // -0.7rem
@debug ml.uv('P1r;2e;5p'); // 1rem 2em 5%
@debug ml.uv('Ml-2.5gg'); // calc(var(--ml-gg) * -2.5)
@debug ml.uv('W1/3'); // 33.3333333333%
@debug ml.uv('W2/$div'); // calc(2 / var(--ml-div) * 100%)
Source: ../src/sass/tools/settings/base/_utils.scss, line 154
9.4.1.1.10 #settings.utils.config.conversion.num-length num-length

This type converts numbers almost as a default type, except that it does not convert numbers without units of measurement in a pixels. Schema:

('num-length': list.join('num-length', $uv-type-base))

Usage:

@debug ml.uv('Zi5'); // 5
@debug ml.uv('Tas2e'); // 2em
Source: ../src/sass/tools/settings/base/_utils.scss, line 181
9.4.1.1.11 #settings.utils.config.conversion.num-percent num-percent

Converts percent to decimal fractions. Schema:

('num-percent': list.join('num-percent', $uv-type-base))

Usage:

@debug ml.uv('O70p'); // 0.7
@debug ml.uv('-S-50p'); // -0.5
Source: ../src/sass/tools/settings/base/_utils.scss, line 210
9.4.1.1.12 #settings.utils.config.conversion.outline outline

Adds colors conversion to a default converters chain. Schema:

('outline': list.join(
	('keyword', 'color', 'number'), $uv-type-base
))

Usage:

@debug ml.uv('Bd3;tp;d'); // 3px transparent dotted
Source: ../src/sass/tools/settings/base/_utils.scss, line 298

9.4.1.2 #settings.utils.config.states States

States are stored in the states section and grouped by type:

  • pseudo-cls - pseudo classes
  • pseudo-elm - pseudo elements
  • custom - all the rest

Below is a quick reference of states. Later it will be supplemented by comments and examples.

If you want to add a state, it is recommended to do this in the custom section. Please note that in the code, all custom states begin with a hyphen. This prevents names collision with native states from CSS.

@use 'mlut/tools' as ml with (
	$utils-config: (
		'states': (
			'custom': (
				'rtl': '[dir=“rtl”]',
			),
		),
	),
);

@include ml.apply(('-rtl _Mr2r'), (), true);

// CSS
[dir=“rtl”] .-rtl_Mr2r {
	margin-right: 2rem;
}
Source: ../src/sass/tools/settings/base/_utils.scss, line 88
9.4.1.2.1 #settings.utils.config.states.custom custom
btc ">*+*"
evc ":nth-child(2n)"
evot ":nth-of-type(2n)"
odc ":nth-child(odd)"
odot ":nth-of-type(odd)"
op "[open]"
tif '[tabindex="0"]'
nojs ".no-js"
Source: content/generate.css, line 2730
9.4.1.2.2 #settings.utils.config.states.pseudo-cls pseudo classes
a ":active"
c ":checked"
d ":disabled"
df ":default"
de ":defined"
e ":empty"
en ":enabled"
f ":focus"
fw ":focus-within"
fv ":focus-visible"
frc ":first-child"
frot ":first-of-type"
h ":hover"
i ":invalid"
id ":indeterminate"
inr ":in-range"
lc ":last-child"
lot ":last-of-type"
ln ":link"
oc ":only-child"
oot ":only-of-type"
ot ":optional"
ouor ":out-of-range"
phs ":placeholder-shown"
r ":required"
rt ":root"
rdo ":read-only"
rdw ":read-write"
t ":target"
v ":visited"
vl ":valid"
Source: content/generate.css, line 2716
9.4.1.2.3 #settings.utils.config.states.pseudo-elm pseudo elements
af "::after"
b "::before"
frl "::first-line"
frlt "::first-letter"
flsb "::file-selector-button"
m "::marker"
ph "::placeholder"
s "::selection"
Source: content/generate.css, line 2723

9.4.2 #settings.utils.data Data

The database of utilities is divided into 3 sections:

  • utils - all utils that can be used to stylize
  • media - @media features
  • common - common utils for both section

Media features are here, because to work with them, the same code is used as for ordinary utilities.

The sections have a similar structure and consist of subsections such as registry and keywords.

Source: ../src/sass/tools/settings/common/_utils.scss, line 8

9.4.2.1 #settings.utils.data.registry Registry

The registry stores data of all utilities. You can get these data with the following path:

@use 'mlut/tools' as ml;
map.get(ml.$utils-db, 'utils', 'registry', '<utility-name>');

The registry is a map, the keys in which are the names of the utility, and the value can be, both a string with 1 property and a map with options. Below will be examined in detail the utility options. You can familiarize yourself with the utility registry on this page, and the registry of media features is available here.

Source: ../src/sass/tools/settings/common/_utils.scss, line 21

9.4.2.2 #settings.utils.data.kw Keywords

In this subsection, keywords that are used in several utilities are stored. To use a set of keywords from here, specify the corresponding map key, in the keywords setting of utility.

@use 'mlut/tools' as ml with  (
	$utils-data: (
		'utils': (
			'registry': (
				'Mxw': (
					'keywords': ('sizing', 'my-sizing'),
				),
				'Flb': (
					'keywords': ('sizing', 'my-sizing'),
				),
			),
			'keywords': (
				// adds new keywords to the existing set
				'box-alignment': (
					'sf': safe,
					'u': unsafe,
				),
				'my-sizing': (
					'sm': 22rem,
					'md': 44rem,
				),
			),
		),
	),
);

@debug ml.uv('Mxw-sm'); // 22rem
@debug ml.uv('Flb-md'); // 44rem
@debug ml.uv('Jc-c;sf'); // center safe

See the full list of keywords here.

Source: ../src/sass/tools/settings/common/_utils.scss, line 34

9.4.2.3 #settings.utils.data.options Utilities options

These options control how the utility works. You can find example of usage in the reference. Later more examples will be added.

Parameters:
  • properties
    string | list
    The list of CSS properties controlled by the utility. Properties are specified as strings without quotes. If you do not specify this option, then the name of the utility will be used as a property
  • preset-properties
    map
    Map with CSS properties and values that will be substituted for any utility value. As a value, you can specify the Sass function in which the following arguments will be passed: the name of the utility, value, CSS-value and important boolean flag
  • keywords
    string | list | map
    Abbreviations that will expand in CSS-values during conversion. You can clearly specify map in format ('abbr': value). You can also specify one or more links to the existing set. Link - the key in map keywords, which is located in the same database. In this map there are already sets of frequently used CSS keywords. Please note that the keyword is an empty line '' - the meaning of the default utility value
  • conversion
    string
    Type of conversion. It determines how the value of the utility in CSS value will convert. This means that for the Txt-l utility, CSS value will be lowercase, and for Wlc-l - left. See more details about the type of conversion in the description of the configure of utilities.
    Defaults to: 'default'
  • repeat-prop-values
    boolean
    The flag is relevant for utils that control several properties. If it is turned on and less values are specified for the utility than the properties, then the values will be repeated for incomplete properties. For example, a utility with the flag on will work approximately like margin: 1px;, and a utility without a flag, like background: red. Please note that an algorithm for repeating values differs from the repetition algorithm in CSS
    Defaults to: true
  • range-generator
    string
    range syntax processing method
    Defaults to: 'number'
  • selector
    string
    The modifier that will be added to the utility selector with any value and condition. It is a string-template in which the utility selector is indicated by &. For example: &::after
  • components
    string
    Here you can specify the components with which all utility values ​​will be generated. The components from this option will have a priority over those that are specified when creating a utility using Generation Syntax. This syntax is also used here. Please note that along with the components, you need to specify the name of the utility and here it can be changed. If you need to change only the name, write it without components. The name can be left empty, then the value of the utility will be used instead. This can be relevant only for utilities, in which the values ​​are keywords. Also note that even when the name changes in the options, inside mlut, the utility will still be identified on the initial key in $utils-db
  • multi-list-separator
    string
    The separator of the nested lists in the value of the utility. The option is relevant for utilities, in the property of which, CSS-value can be a list of a list. For example, border-radius: 2px 3px / 8px;. It is important to clearly specify this separator so that the conversion of the values works correctly. Usually in CSS such a separator will be , or /.
  • transformer
    string
    A function that will process CSS value after conversion
Source: ../src/sass/tools/settings/common/_utils.scss, line 74

9.4.3 #settings.utils.other Other

Other settings that are not contained in main large maps

Source: ../src/sass/tools/settings/base/_utils.scss, line 10

9.4.3.1 #settings.utils.other.groups Utils groups

Groups are stored in a separate database $utils-groups-db. To modify or add groups, use $utils-groups. When specifying utilities in the group, you can use Generation Syntax. In this case, utilities with components will be generated for each value.

@use 'mlut' as ml with (
	$utils-groups: (
		'MPSpaces': (
			'M_ frc', Mt, Mr, Mb, Ml, -Mx, -My,
			P, Pt, Pr, Pb, Pl, -Px, -Py,
		),
	),
	$utils: (
		'MPSpaces': (
			100, '$myOffset'
		),
	),
);

// CSS
// some utils from standard library before

.M100 {
  margin: 100px;
}

.M100_frc:first-child {
  margin: 100px;
}

.M-\$myOffset {
  margin: var(--ml-myOffset);
}

.M-\$myOffset_frc:first-child {
  margin: var(--ml-myOffset);
}

.Mt100 {
  margin-top: 100px;
}

// etc
Source: ../src/sass/tools/settings/base/_utils.scss, line 35

9.4.3.2 #settings.utils.other.up_specificity $utils-up-specificity

boolean | string
Increase the specificity of all utilities at once. When true - to each utility property will be added !important. A string with a CSS selector is also acceptable. It will be added before the utility selector.
Defaults to: false

@use 'mlut/tools' as ml with (
	$utils-up-specificity: true,
);

@include ml.apply('Mt2r');

// CSS
.Mt2r {
	margin-top: 2rem !important;
}
Source: ../src/sass/tools/settings/base/_utils.scss, line 16