Utilities – also known as "trumps," "helper classes," or "alterations" – are high-specificity selectors for making very targeted alterations to existing elements or components.
Each utility is a small, atomic style declaration that, when chained together, should mitigate most situations in which custom CSS must be written. Just write these classes right in your mark-up and you're all set!
Most utilities come with responsive options, enabling alterations at targeted screen size ranges. For example, "small padding on smaller screens, larger padding on bigger screens."
While an atomic CSS approach comes with many advantages, we recognize it also offers a notable disadvantage: reducing the CSS cascade. This is especially true for repeated UI elements, which can end up creating redundant mark-up. For these instances, Dialtone offers components.
d-bt applies a border (b) to the top (t) side. 1px is the default width, and the color is inherited from the foreground color (currentColor).
< div class = " d-bt" >
< dt-text> Box</ dt-text>
</ div>
Raw HTML renders visuals only. You may need to add JS to replicate its functionality.
d-btw4 applies a 4px (4) width (w) to the top (t).
< div class = " d-bt d-btw4" >
< dt-text> Box</ dt-text>
</ div>
Raw HTML renders visuals only. You may need to add JS to replicate its functionality.
d-bc-critical applies a critical border (b) color (c).
< div class = " d-bt d-btw4 d-bc-critical" >
< dt-text> Box</ dt-text>
</ div>
Raw HTML renders visuals only. You may need to add JS to replicate its functionality.
A basic example styling a container by combining Dialtone's CSS utilities. Follow each step with this Codepen template.
< div>
< dt-text> Box</ dt-text>
</ div>
Raw HTML renders visuals only. You may need to add JS to replicate its functionality.
Apply a Primary Inverted Surface Color .
< div class = " d-bgc-primary-inverted" >
< dt-text> Box</ dt-text>
</ div>
Raw HTML renders visuals only. You may need to add JS to replicate its functionality.
Since this will be primary content on a dark surface, let's use d-fc-primary-inverted from the font color utilities .
< div class = " d-bgc-primary-inverted d-fc-primary-inverted" >
< dt-text> Box</ dt-text>
</ div>
Raw HTML renders visuals only. You may need to add JS to replicate its functionality.
Let's use d-p-100 padding for all four sides, from the list of padding utility classes .
< div class = " d-bgc-primary-inverted d-fc-primary-inverted d-p-100" >
< dt-text> Box</ dt-text>
</ div>
Raw HTML renders visuals only. You may need to add JS to replicate its functionality.
Let's repeat them in a Stack component. Note that I've moved the surface and foreground colors to the parent container so they may inherit.
Box 1
Box the 2nd
Box third
Box IV
< div class = " d-p-100" >
< dt-text> Box 1</ dt-text>
</ div>
< div class = " d-p-100" >
< dt-text> Box the 2nd</ dt-text>
</ div>
< div class = " d-p-100" >
< dt-text> Box third</ dt-text>
</ div>
< div class = " d-p-100" >
< dt-text> Box IV</ dt-text>
</ div>
Raw HTML renders visuals only. You may need to add JS to replicate its functionality.
Let's add the direction prop to make them flow horizontally.
Box 1
Box the 2nd
Box third
Box IV
< div class = " d-p-100" >
< dt-text> Box 1</ dt-text>
</ div>
< div class = " d-p-100" >
< dt-text> Box the 2nd</ dt-text>
</ div>
< div class = " d-p-100" >
< dt-text> Box third</ dt-text>
</ div>
< div class = " d-p-100" >
< dt-text> Box IV</ dt-text>
</ div>
Raw HTML renders visuals only. You may need to add JS to replicate its functionality.
Add a border between each item with d-divide-x. Its default color is currentColor.
Box 1
Box the 2nd
Box third
Box IV
< div class = " d-p-100" >
< dt-text> Box 1</ dt-text>
</ div>
< div class = " d-p-100" >
< dt-text> Box the 2nd</ dt-text>
</ div>
< div class = " d-p-100" >
< dt-text> Box third</ dt-text>
</ div>
< div class = " d-p-100" >
< dt-text> Box IV</ dt-text>
</ div>
Raw HTML renders visuals only. You may need to add JS to replicate its functionality.
8. And Change the Border Color Since the border color inherits the color of the parent's foreground (implicitly currentColor), let's soften it with a bold inverted border color d-divide-moderate-inverted.
Box 1
Box the 2nd
Box third
Box IV
< div class = " d-p-100" >
< dt-text> Box 1</ dt-text>
</ div>
< div class = " d-p-100" >
< dt-text> Box the 2nd</ dt-text>
</ div>
< div class = " d-p-100" >
< dt-text> Box third</ dt-text>
</ div>
< div class = " d-p-100" >
< dt-text> Box IV</ dt-text>
</ div>
Raw HTML renders visuals only. You may need to add JS to replicate its functionality.
Add some icons .
< dt-stack direction = " row" gap = " 100" class = " d-p-100" >
< dt-icon name = " alert-triangle" size = " 200" />
< dt-text> Box 1</ dt-text>
</ dt-stack>
< dt-stack direction = " row" gap = " 100" class = " d-p-100" >
< dt-icon name = " info" size = " 200" />
< dt-text> Box the 2nd</ dt-text>
</ dt-stack>
< dt-stack direction = " row" gap = " 100" class = " d-p-100" >
< dt-icon name = " alert-circle" size = " 200" />
< dt-text> Box third</ dt-text>
</ dt-stack>
< dt-stack direction = " row" gap = " 100" class = " d-p-100" >
< dt-icon name = " check-circle" size = " 200" />
< dt-text> Box IV</ dt-text>
</ dt-stack>
Raw HTML renders visuals only. You may need to add JS to replicate its functionality.
Apply a semantic surface color to convey some meaning to them, e.g. d-bgc-critical-strong.
< dt-stack direction = " row" gap = " 100" class = " d-bgc-critical-strong d-p-100" >
< dt-icon name = " alert-triangle" size = " 200" />
< dt-text> Critical</ dt-text>
</ dt-stack>
< dt-stack direction = " row" gap = " 100" class = " d-bgc-info-strong d-p-100" >
< dt-icon name = " alert-circle" size = " 200" />
< dt-text> Info</ dt-text>
</ dt-stack>
< dt-stack direction = " row" gap = " 100" class = " d-bgc-positive-strong d-p-100" >
< dt-icon name = " check-circle" size = " 200" />
< dt-text> Positive</ dt-text>
</ dt-stack>
Raw HTML renders visuals only. You may need to add JS to replicate its functionality.
Use the DtText component for text styling. It provides a semantic, prop-driven API for typography.
< dt-stack direction = " row" gap = " 100" class = " d-bgc-critical-strong d-p-100" >
< dt-icon name = " alert-triangle" size = " 200" />
< dt-text kind = " label" :size = " 200" > Critical</ dt-text>
</ dt-stack>
< dt-stack direction = " row" gap = " 100" class = " d-bgc-info-strong d-p-100" >
< dt-icon name = " alert-circle" size = " 200" />
< dt-text kind = " label" :size = " 200" > Info</ dt-text>
</ dt-stack>
< dt-stack direction = " row" gap = " 100" class = " d-bgc-positive-strong d-p-100" >
< dt-icon name = " check-circle" size = " 200" />
< dt-text kind = " label" :size = " 200" > Positive</ dt-text>
</ dt-stack>
Raw HTML renders visuals only. You may need to add JS to replicate its functionality.
Refine the spacing by adjusting the Stack gap prop and padding utilities for horizontal and vertical padding.
< dt-stack direction = " row" gap = " 50" class = " d-bgc-critical-strong d-py-50 d-px-100" >
< dt-icon name = " alert-triangle" size = " 200" />
< dt-text kind = " label" :size = " 200" > Critical</ dt-text>
</ dt-stack>
< dt-stack direction = " row" gap = " 50" class = " d-bgc-info-strong d-py-50 d-px-100" >
< dt-icon name = " alert-circle" size = " 200" />
< dt-text kind = " label" :size = " 200" > Info</ dt-text>
</ dt-stack>
< dt-stack direction = " row" gap = " 50" class = " d-bgc-positive-strong d-py-50 d-px-100" >
< dt-icon name = " check-circle" size = " 200" />
< dt-text kind = " label" :size = " 200" > Positive</ dt-text>
</ dt-stack>
Raw HTML renders visuals only. You may need to add JS to replicate its functionality.
Add d-bar-300 to each item for subtle rounded corners.
< dt-stack direction = " row" gap = " 50" class = " d-bar-300 d-bgc-critical-strong d-py-50 d-px-100" >
< dt-icon name = " alert-triangle" size = " 200" />
< dt-text kind = " label" :size = " 200" > Critical</ dt-text>
</ dt-stack>
< dt-stack direction = " row" gap = " 50" class = " d-bar-300 d-bgc-info-strong d-py-50 d-px-100" >
< dt-icon name = " alert-circle" size = " 200" />
< dt-text kind = " label" :size = " 200" > Info</ dt-text>
</ dt-stack>
< dt-stack direction = " row" gap = " 50" class = " d-bar-300 d-bgc-positive-strong d-py-50 d-px-100" >
< dt-icon name = " check-circle" size = " 200" />
< dt-text kind = " label" :size = " 200" > Positive</ dt-text>
</ dt-stack>
Raw HTML renders visuals only. You may need to add JS to replicate its functionality.
View the final result in this Codepen template . Continue to explore using the variety of CSS utilities listed here.