Stylesheets are pretty cool. Writing them in Lua is not.
Here’s a compiler to make stylesheets from a sass-like (lass) language to lua if you (like me) have some niche reason to not use Studio’s style editor
Installation
- Install rust
- Run
cargo install rbx-lass - Run
rbx-lass <input files> -o <output file>
Example lass file
// Only double slash comments are supported, and are not emitted
:root
--MyFavoriteColor: Color3.new(0, 1, 0)
TextButton, TextLabel
TextColor3: Color3.new(1, 1, 1)
BackgroundTransparency: 1
&:Hover
BackgroundTransparency: 0.5
// You can specify priority like this
@priority(10)
TextButton.special
// Instead of var(--MyVar) you do "$MyVar"
TextColor3: "$MyFavoriteColor"
another sample input
and its output
After that you can put this in the rest of your codebase
local stylesheet: StyleSheet = require(path.to.output)
Limitations
- Style rules can only be one line
- Lua expressions are not validated at all
- Fancy stuff like constants, mixins, functions and such are not supported
- Really unhelpful compiler responses
- Multiple input files are merged into one output instead of doing complicated StyleDerive stuff which I honestly don’t understand
- Probably really buggy
I heavy referenced css comparisons so if there’s something wrong with that page there is something wrong with lass as well
Can I use CSS/SCSS instead?
No
I found bugs
From my testing things should work decently well but if there are problems, go here
and then, of course
source