Powerful event-driven functions for conditional styling and dynamic value generation.
Create reusable event functions with conditional logic:
/* Create event function */ @event event-name(param) { if param: white { return: black; } el-if param: black { return: white; } el { return: blue; } } body { /* returns white */ background: @event.event-name(black); } button { /* returns black */ color: @event.event-name(white); /* returns blue */ background: @event.event-name(); }
Generate dynamic values with @random and process with events:
/* Generate random values */ str(val1, "@random([lightgreen, skyblue, white])") str(val2, "@random([darkgreen, midnightblue, red])") /* Create event to process values */ @event myfunc(e) { if e: val1 { return: val2; } el-if e: val2 { return: val1; } el { return: white; } } /* Apply dynamic styling */ .box { background: @event.myfunc(val1); border-color: @event.myfunc(val2); color: @event.myfunc(yellow); }
Perform math operations with the num() function and events:
/* Event with numerical logic */ @event cal(num) { if num: num(40+20) { return: num(40+20 / 2)px; } el { return: num(60-40)px; } } /* Calculate and store result */ str(calRes, "num(20+20)") button { /* Returns 30px (60 / 2) */ padding: @event.cal(60); /* Returns 20px (60-40) */ margin: @event.cal(calRes); }
if
- Primary condition checkel-if
- Secondary condition checksel
- Default fallback case@random([values])
- Random selectionnum(expression)
- Mathematical operationsstr()
for stored values@event theme(mode) { if mode: dark { return: #1a1a1a; } el { return: #f8f8f8; } } body { background: @event.theme(dark); color: @event.theme(light); }
@event spacing(size) { if size: small { return: num(8 * 1.25)px; } el-if size: medium { return: num(16 * 1.25)px; } el { return: num(24 * 1.25)px; } } .container { padding: @event.spacing(medium); }
str(primary, "@random([#4361ee, #f72585, #7209b7])") str(secondary, "@random([#4cc9f0, #4895ef, #560bad])") @event color(type) { if type: primary { return: primary; } el { return: secondary; } } .card { background: @event.color(primary); border-color: @event.color(secondary); }
Generates a random value from the provided array on each page load:
@random([value1, value2, value3])
Performs mathematical operations:
num(expression)
Creates reusable conditional logic blocks:
@event name(param) { /* conditional logic */ }