- Create components that support atomic CSS and themes
- Set styles for specific media breakpoints
- Use variables from the theme in composite CSS properties
- Support for hover and any other pseudo-classes
- Short aliases for each property
Install and Usage
Before you start working with Atomize, you need to set up dependencies:
npm i @quarkly/atomize styled-components
Atomize serves as a wrapper around a styled-component and has a similar API.
Just call the method using the name of the required element:
import atomize from '@quarkly/atomize';const Box = atomize;
As a result, we get the React component that can take any CSS in the form of properties.
<Box ="red" />
The React inheritance mechanism is also provided:
const MyComponent = className// some logic herereturn <div = />;;const Box = ;
You can use the system of alias properties to make it easier to use. For example, bgc === backgroundColor.
<Box ="red" />
To see the full list of properties and aliases, follow this link.
You can also disable aliases for the specific component if you need. Just pass an object with the configuration where set "useAliases: false".
const Box = atomize
By default, Atomize components do not include a theme and you need to set up dependencies:
npm i @quarkly/theme
Quarkly themes are based on CSS variables. The key feature is that variables from themes can be reused both in props and themes. You don’t have to use additional abstractions, like template functions, and no additional editing is needed.
To use variables from a theme, just add your theme to an application with a Theme component, describe the property in the theme and call this property using the prefix "--".
You can also use it in the theme itself:
import Theme from "@quarkly/theme";const theme =color:dark: "#212121"border:dark: "1px solid --color-dark";const MyBox =<Theme =><Box="100px"="100px"="--border-dark"="--color-dark"/></Theme>;
Shorter syntax is used for colors in the JSX markup:
<Box ="--dark" />
Themes have breakpoints for working with media expressions.
Any property can be prefixed with a breakpoint key name.
import Theme from "@quarkly/theme";const theme =breakpoints:sm: type: "min-width" value: 576md: type: "min-width" value: 768lg: type: "min-width" value: 992color:'dark-mobile': "#424242"'dark-tablet': "#212121";const MyBox =<Theme =><Box="100px"="100px"="--dark-mobile"="--dark-tablet"/></Theme>;
Just pass an object with the configuration to a component when creating it:
const Button = atomize;
The key is the prefix in the name of the property, and the value is a CSS selector. This is the same way we implemented pseudo-classes.
For example, if you specify the hover prefix for any CSS property, it will be applied to a certain effect:
You can also combine effects with media expressions:
The second purpose of Atomize is to create widgets in Quarkly based on custom React components.
Just wrap your component in Atomize and describe its configuration so that Quarkly can understand which properties can be interactively edited.
You do not need to add a Theme to your component when you use it in Quarkly. All the variables from the project will be automatically available in your component.
The configuration fields for the component look like this:
- effects – defines browser pseudo-classes (hover, focus, etc.)
- description – component description that will appear when you mouse over its name
- propInfo – configuration of controls that will be displayed on the right panel
Boxeffects:hover: ":hover"description:en: "Awesome box component"propInfo:someProp:control: "input"someProp: "Hello World!";
Possible control options:
To specify the props to be displayed on the right panel, use this template:
- description – tooltip text based on localization language
- control – control type (from the list above). It is a required property
- category – name for your category in the right panel; if there is no category with this name, it will be created automatically
- weight – control width. The range of values is from 0 to 1, which equals from 0 to 100% of the right panel width. It is possible to show several controls in one line
someProp:description: en: "Your text"control: "input"category: 'Main'weight: 1
Returns a string with the checked value.
Property "checkedValue" describes the name for the selected option:
Returns a string with the checked value.
Property "checkedValue" describes the name for the selected option.
Property "icon" describes the system name for the icon:
checkedValue: "valueName"icon: "iconName"
Select and radio-group
Returns a string with the selected value.
Property "variants" contains a list of available options:
variants: 'one' 'two' 'three'
Returns a string with a font styles.
Returns a string with a variable or custom value in #HEX or RGBA.
Returns a string with a variable or custom color in #HEX or RGBA and image or gradient styles if they were defined.
//) 0%,) 100%)//)/
Transition, transform, shadow and filter
Returns a string with a property styles.
import atomize from '@quarkly/atomize';
Default export. This is a wrapper around styled from
import getTransform from '@quarkly/atomize;
Method that returns a function by name to transform the value.
name- method name for a transform
import transformVar from '@quarkly/atomize;
Transform of CSS variables
transformVarkey: string, value: string: string;
import splitCSSRule from '@quarkly/atomize;
Breaks the CSS string into an array of rules.
splitCSSRulerule: T, separator?: string: Array<T>
Default theme for using CSS variables and defining breakpoints.
import themeDefault from '@quarkly/atomize;
import dict from '@quarkly/atomize;
Dictionary for defining configuration of CSS rules
- alias - name abbreviation
- type - CSS value type
import aliasesDict from '@quarkly/atomize;
Dictionary of abbreviations generated from
- Code refactoring to TypeScript
- Auto sync with "can i use" and "emmet"
- Comprehensive documentation
Licensed under MIT.