Attributes & specifiers
Asterix relies in a few attributes to work.
Attributes are filled with specifiers to enable related css rules. They can be chained.
<div data-layout="--grid--items-center" data-cols="--2--l4" data-gap="--2">
<div>Items</div>
<div>Items</div>
<div>Items</div>
<div>Items</div>
<div data-col="--2--l4">Fullwidth items</div>
</div>Asterix provides a bunch of specifiers.
Specifiers can be added anywhere in your code. They can be set globally, locally and responsively.
When a specifier is responsive, you can use it combined with any breakpoint registered into Asterix. Just add the breakpoint key to the specifier after the -- chaining string.
For example, --mgrid will only set a --grid context for screen with a higher width than the m breakpoint value.
Built-in attributes and specifiers
All builtins specifiers are responsive
[data-layout]
Set a grid or a flex context to the element and handle positioning rules.
<div data-layout="--flex--justify-space-between">...</div>Modifiers
--auto
--block
--flex
--grid
--none
--items-center
--items-end
--items-start
--items-stretch
--justify-center
--justify-end
--justify-space-between
--justify-start
--justify-stretch
--self-center
--self-end
--self-start
--self-stretch
[data-cols]
Set the columns number for a grid context
Specifiers
Loops on $asterix-conf grid-columns-number parameter and build a specifier for each number.
[data-col]
Set the element's column spaning
Specifiers
Loops on $asterix-conf grid-columns-number parameter and build a specifier for each number.
[data-gap], [data-hgap], [data-vgap]
Set gaps between columns, rows and flex children.
Specifiers
Loops on asterix-vars gaps group and build a specifier for each value.
hgap and vgap are working exactly the same way, except they only set horizontal gap for hgap (between columns) and vertical gap for vgap (between rows) separately.
Adding a specifier
You can use the --spe($name[, $responsively: false, $attribute: data-spe]) mixin.
By default, all custom specifiers are attached to the [data-spe] html attribute.
Let's say you want to create a button design system.
Implementing buttons variations with --spe() provides a reliable pattern allowing unlimited chaining. This is perfect for extending a basic design system item.
It could start like this:
Optional parameters
$responsively
default: false
When set to true, asterix will add rules for each breakpoint value.
Responsive specifier naming pattern is --[breakpoint key][specifier name]. For example, a flex context starting at m will be written --mflex.
$attribute
default: data-spe
Set a different attribute used to call this specifier. When set to class, you are therefore able to call the specifier inside the class html attribute : <div class="--specifier"></div>
$local
default: true
Indicate if the required specifier has to be exclusive to the current scope or if it can be used anywhere in children elements.
When creating a top-level specifier, you'll have to set $local to false, so it does not use a parent selector.
Create a new attribute
You design system will probably need extra values, and you want to be able to use them responsively on the HTML side.
Let's say you want to implement a basic design-system buttons layout.
First step is to implement the basic button styling. By using css variables internally, we make it simpler to extend, but you can perfectly use sass variables... Write your own rules !
This makes any HTML element having data-btn as attribute a button
Then, you need to extend from this basic layout to make your declinals:
Notice the use of $attribute and $local parameters into the --spe mixin.
They are mandatory to create a top level specifier. More info about --spe().
And you'll have on the html side plenty specifiers available for setting easily your buttons:

Last updated