CSS is painful
CSS is a critical piece of the frontend toolkit, but it's hard to manage, especially in large projects. Styles are written in a global scope, which is narrowed through complex selectors. Specificity issues, redundancy, bloat, and maintenance can become a nightmare. And modular, component-based projects only add to the complexity. Atomizer enables you to style directly in your components, avoiding the headache of writing and managing stylesheets.
Style with class
Most approaches to styling inside components rely on inline styles, which are limiting. Atomic CSS, like inline styles, offers single-purpose units of style, but applied via classes. This allows for the use of handy things such as media queries, contextual styling and pseudo-classes. The lower specificity of classes also allows for easier overrides. And the short, predictable classnames are highly reusable and compress well.
Meet Atomizer
Atomizer is a utility for modern web sites. Atomizer generates an Atomic stylesheet from the ACSS classes you're actually using in your project (no unused styles!), or predeclare styles in configuration - it's up to you. Atomizer is not opinionated, brings no CSS of its own, and integrates nicely with your favorite task runner.
Colors
hex
color.
Variables
"Variables" are useful for theming but they can also be used to share a common value across style declarations.
In this example, brandColor
is responsible for setting the text color, background color and border color, while columnWidth
dictates the width of the first box and the left offset of its sibling.
Contextual selectors
Atomizer syntax allows you to style elements depending on their ancestors or siblings.
In this example, two identical sets of boxes are styled differently depending on the class applied to their parent element.
Pseudo-classes
Create styles that rely on pseudo-classes.
In this example, the foreground and background color change when users hover over the box.
You can also combine descendant selectors with pseudo-classes. In this example, the nested box is revealed when a user hovers over its parent:
Lorem ipsum
Grids
What do you prefer? Floats? Flexbox? Inline-block? CSS table? Atomizer supports it all, and you can use any measurement style you want (fraction, percentage, em, rem, px, etc.)
Responsive Web Design (RWD)
Define your responsive "breakpoints" in configuration using standard media query syntax. Then, reference those breakpoints in your Atomizer classes or configuration.
Classes mapped to a single breakpoint
Reference your breakpoints in your classnames using a double-dash suffix (eg, --sm
).
In this example, the four boxes are styled as inline-block
, with a width
of 25%
when the viewport is more than 700px
wide.
Classes mapped to multiple breakpoints
Classes may have different values associated with different breakpoints; meaning the same class applies different styles depending on media queries.
Helpers
Atomizer offers a selection of helper classes for common styling, such as "clearfix" to clear floats (Cf
), Bd
to help with setting borders, Ell
to truncate text with ellipsis, Hidden
to visually hide text, and more.
For example LineClamp()
, which takes two parameters:
Lorem ipsum dolor sit amet, id oratio graeco nostrum sit, latine eligendi scribentur mea ex. Tota dolorem voluptua eos at. Ei nec reque viderer facilis. Aliquip necessitatibus ex pri, pertinax atomorum ei sea. Ea omittam appetere posidonium per, te meliore volutpat duo, dolorem ponderum interpretaris sea ut.