π Bro β‘ A super fast stylesheet language for cool kids!
π Written in Nim language
API reference | Download (not yet)
- β‘ Extremely fast & Highly optimized Jump to Benchmarks
- π Lightweight, 1.5MB tiny executable
- π± Dependency Free / No Virtual Machine
- πͺ Strongly Typed = Perfect Cascading Style Sheets π€©
- π Works on Linux, macOS, Windows
- π A beautiful, improved
SASS
-like Syntax Learn Bro in 5 minutes - π Standard Library (
strings
,arrays
,objects
,math
,regex
,os
) Check the manual - π Human readable Syntax => Developer friendly
var
&const
[]
Arrays{}
Objectsif
&case
Conditionalsfor
Loop Statementsfn
Functions &mix
Mixins- Overloading + Closures + Forward declaration
CSS
toBASS
AST withinclude some.css
BASS
imports usingimport std/[strings, math]
- JSON/YAML stream to BASS using
json("some.json")
,yaml("some.yml")
- π Built-in CSS Optimization (Autoprefixer, Minifier, CSS Alphabetize & Deduplication)
- πΊ CSS SourceMap Generator
- π CSS Reload & Browser sync Setup info
- π΄ Abstract Syntax Tree binary serialization
- π Built-in
HTML
,JSON
Documentation Generator - π₯ Works with Node.js & Bun.js via
NAPI
- π Works in Browser via WASM (unstable)
- π Dynamically Linked Library
- π
Warnings
=> Unused Variables - π
Warnings
=> Unused Mixins, Functions, Empty selectors - π
Errors
=> invalid properties/values or typos! - π³ Recommended Extension
.bass
- π© Open Source | LGPLv3 license
- π Written in Nim language
- π Made for Cool Kids
Warning
Bro is still under development. Expect bugs and incomplete features.
Note
Since Bro is written in native code, anti-virus software can sometimes incorrectly flag it as a virus
Install Bro as a standalone CLI application. Get it from Releases or build it from source using Nim & Nimble.
Integrate Bro in your Nim application
import bro
let stylesheet = """
$colors = [blue, yellow, orchid]
for $color in $colors:
.bg-{$color}
background: $color
"""
var
p: Parser = parseStylesheet(stylesheet)
c: Compiler = newCompiler(p.getStylesheet, minify = true)
echo c.getCSS # .bg-blue{background:blue}.bg-yellow{...
Integrate the most powerful CSS pre-processor in your Node.js/Bun app. Bro is available as a native addon module
let stylesheet = `
$colors = [blue, yellow, orchid]
for $color in $colors:
.bg-{$color}
background: $color
`
const bro = require("bro.node")
bro.compile(stylesheet) // .bg-blue{background:blue}.bg-yellow{...
Build complex real-time web-apps using Bro + WebAssembly
<style type="text/bro" id="stylesheet">
$colors = [blue, yellow, orchid]
for $color in $colors:
.bg-{$color}
background: $color
</style>
<script src="/bro.min.js"></script>
bro.compile('#stylesheet') // .bg-blue{background:blue}.bg-yellow{...
DartSass, SassC, Bro, BroJS (via NAPI w/ Node & Bun), Sass (JS w/ Node & Bun)
1.572.876 lines of
.btn
background: yellow
Benchmark 1: ./dart sass.snapshot test.sass:test.css --no-source-map --style=compressed
Time (abs β‘): 4.925 s [User: 6.060 s, System: 0.263 s]
Benchmark 2: bro test.sass test.css --min
Time (abs β‘): 441.7 ms [User: 422.3 ms, System: 19.9 ms]
Benchmark 3: sassc test.sass test.css --style=compressed
Time (abs β‘): 5.757 s [User: 5.346 s, System: 0.400 s]
Benchmark 4: bun bro.js
Time (abs β‘): 679.0 ms [User: 616.0 ms, System: 24.0 ms]
Benchmark 5: node bro.js
Time (abs β‘): 653.7 ms [User: 625.8 ms, System: 32.3 ms]
Benchmark 6: node sass.js
Time (abs β‘): 12.783 s [User: 19.640 s, System: 1.185 s]
Benchmark 7: bun sass.js
Time (abs β‘): 10.485 s [User: 20.422 s, System: 1.030 s]
Summary
'bro test.sass test.css --min' ran
1.48 times faster than 'node bro.js'
1.54 times faster than 'bun bro.js'
11.15 times faster than './dart sass.snapshot test.sass:test.css --no-source-map --style=compressed'
13.03 times faster than 'sassc test.sass test.css --style=compressed'
23.74 times faster than 'bun sass.js'
28.94 times faster than 'node sass.js'
Check Benchmarks page for more numbers
Benchmarks made with [hyperfine](https://github.com/sharkdp/hyperfine) on**Ubuntu 22.04 LTS** / Ryzen 5 5600g 3.9GHz Γ 12 / RAM 32 GB 3200MHz / SSD M.2
- The Interpreter (Tokens, Lexer, Parser, AST, Compiler)
- CSS Selectors ref
- Compile-time
- Variables
- Arrays/Objects
- Anonymous arrays and objects
- Constants
- Functions
- Closures
- Overloading
- Recursive calls
- Mixins
- Conditionals (
if
,elif
,else
, andcase
) - For/Loop statements
for $x in $y
- Typed CSS properties/values
- Warnings unused
variables
,functions
- CSS Variable Declaration using
var
instead of--
- String/Variable concatenation using
&
and backticks
- Handle single/multi line comments
- Memoization
- Import CSS/BASS files
- Implement AST caching system
- Command Line Interface
- CLI
watch
for live changes - CLI
build
BASS code to CSS - CLI generate source
map
- CLI
ast
command for generating binary AST
- CLI
- Build
- Cross-platform compilation
- Node.js/Bun.js via NAPI
- Browser with WASM via Emscripten
- Convert boring SASS to BASS
- CLI
doc
command for generating documentation website
- π Found a bug? Create a new Issue
- π Wanna help? Fork it!
- Create a Syntax Highlighter for your favorite code editor.
- π Get β¬20 in cloud credits from Hetzner
- π₯° Donate to OpenPeeps via PayPal address
Bro Language LGPLv3 license.Made by Humans from OpenPeeps.
Copyright Β© 2024 OpenPeeps & Contributors β All rights reserved.