Getting Started with Elevate CSS
This quick start guide is included to give you an opportunity to dive right into the world of Elevate CSS with a demo project. Note that as this is a proof-of-concept, it is not intended to be used as a production-ready framework yet. With that said, however, it is highly recommended that you familiarize yourself with the configuration section as well as it provides a deeper understanding of Elevate’s capabilities, functionality, and best practices as well as how to best leverage the framework for your specific needs.
Installation and Usage
-
Download the Elevate CSS alpha from GitHub
-
Install Elevate’s Dependencies
-
Watch Files for Changes and Convert Elevate’s Syntax to CSS
Basic Configuration
Elevate’s general settings are defined in elevate/config/elevate.ts
:
What Are ‘Utility Strings’?
Basic Usage:
At the heart of Elevate’s syntax is what are called “utility strings”, which are used to describe styling and serve as the basis for CSS generation while simultaneously doubling as the actual CSS classes. This convention means that, by default, your CSS files only ever contain classes that are actually being used in your markup.
Unlike traditional utility frameworks which come packed with pre-defined utility classes, you are effectively writing CSS as you write utility strings in Elevate through the expression of property and modifier combinations - which are validated against your design system and a series of built-in conventions as well as your own custom syntax rules at build-time to ensure consistency.
The Utility String Format:
Direct Properties:
Direct properties are properties that do not require any modifier and that define a single CSS declaration. Generally used for layout and positioning.
Compound Properties:
Compound properties are properties that require one or more modifiers to be applied. These properties are used to create more complex CSS declarations.
Practical Examples:
Bringing it all together, here are some examples of Elevate’s syntax in action:
Breakpoints and Responsive Design
Elevate affords and enforces a mobile-first, organized syntax for responsive design:
Universal classes are applied on the far-left and apply to all breakpoints by default unless overridden at a breakpoint. Breakpoints are specified using the /breakpoint/
syntax, allowing you to discern the responsive behavior of an element at a glance and keeping things organized by default.
Operator Flags
In order to allow for greater flexibility, Elevate supports a series of flags to further refine styling choices and to support more complex and dynamic behaviors while preserving semantic clarity.
The Contextual Flag [@]:
Allows complex, conditional styling for states, conditions, and other pseudo-classes or pseudo-elements:
Note that you can chain property modifier combinations with an underscore inside of the contextual flag’s brackets. This allows more concise expression of design intent. No more pseudo-class spam or unnecessary nesting!
The Functional Flag [$]:
Exempt certain classes from CSS generation (e.g. for JavaScript interactions or labelling):
The Elements of Elevate
Elevate’s systems are driven by three distinct elements:
-
Design Tokens
- Purpose: Global, immutable design constraints.
- Location:
design/
directory - Configuration:
elevate/config/design.ts
andelevate/design
- Characteristics: Centralized values, enforce system-wide consistency.
Example:
-
Syntactic Rules
- Purpose: Property-specific structural validation and syntax construction or extension.
- Location:
rules/
directory - Configuration:
elevate/config/syntax.ts
andelevate/rules
- Characteristics: Validate property values, provide transformations, and structure or extend syntax.
Example:
-
Property Declarations
- Purpose: Mapping design system tokens and/or syntax rule mappings to CSS declarations.
- Location:
config/
directory - Configuration:
elevate/config/syntax.ts
- Characteristics: Validate property values, provide transformations, and structure or extend syntax.
Example:
-
This Is Elevate CSS: