4 releases
Uses new Rust 2024
new 0.2.1 | Apr 23, 2025 |
---|---|
0.2.0 | Apr 21, 2025 |
0.1.1 | Mar 27, 2025 |
0.1.0 | Mar 27, 2025 |
#161 in Web programming
339 downloads per month
125KB
1K
SLoC
Rusty Cascading Style Sheets (RCSS)
Tip
Download the VSCode extension for syntax highlighting!
Rusty Cascading Style Sheets (RCSS) is a styling language that brings Rust-inspired syntax to CSS. It combines the robustness of Rust with SASS-like features such as nesting and variables for cleaner, more maintainable styles.
/* common/variables.rcss:
let primary_color: "#FFFFFF";
let secondary_color: "black";
fn padding() {
padding: 10px;
}
*/
use common::variables::*;
@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100..900;1,100..900&family=Rubik:ital,wght@0,300..900;1,300..900&display=swap');
.container {
width: 50%;
padding();
&:hover {
padding: 40px;
}
h2 {
color: &primary_color;
}
}
h4 {
width: 50%;
}
/* MOBILE STYLES */
@media screen and (max-width: 480px) {
.container {
width: 100%;
}
h4 {
width: 100%;
color: &secondary_color;
}
}
Note
The above RCSS code compiles to CSS in around 500µs!
Installation
First, if you don't have Cargo (Rust's package manager) installed, you can install it by following the instructions on the official Rust website.
Then, install:
cargo install rcss-css
Warning
If you encounter the following warning:
warning: be sure to add `/home/<YourUsername>/.cargo/bin` to your PATH to be able to run the installed binaries
For Linux Users
Add the following line to your shell configuration file (e.g., .bashrc
, .zshrc
, etc.):
export PATH="$HOME/.cargo/bin:$PATH"
Reload your shell configuration to apply the changes:
source ~/.bashrc
For Windows Users
-
Open the Start Menu and search for "Environment Variables."
-
Click on "Edit the system environment variables."
-
In the System Properties window, click the Environment Variables button.
-
Under System variables, locate the
Path
variable and click Edit. -
Add the following path to the list:
C:\Users\<YourUsername>\.cargo\bin
-
Click OK to save your changes.
Restart your terminal or command prompt to ensure the updated PATH is recognized.
Usage
RCSS expects a directory argument to watch. On file save, RCSS will compile automatically to ../css
rcss-css styles/rcss
This command will compile .rcss
files in styles/rcss
into standard CSS files at styles/css
.
Roadmap
✅ Phase 1: Core Features (Current)
- Implement Rust-like syntax parsing.
- Support variables and nesting.
- Support functions with no arguments
- Develop a VS Code extension with syntax highlighting.
- Implement importing
🚧 Phase 2: Enhancements (Upcoming)
- Support functions with arguments
- Add RCSS formatter
- Improve output css format
Base logo by Dzuk, licensed under CC BY-NC-SA. Download the emoji set
RCSS is licensed under the MIT License.
Dependencies
~6–16MB
~196K SLoC