What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use CSS custom properties to pass values between CSS and browser JavaScript: read an effective value with getComputedStyle(element).getPropertyValue('--token') and change it with element.style.setProperty('--token', value). Sass serves a different role: JavaScript can run Sass during a build, but Sass variables do not become browser runtime variables. Interpolate Sass values into CSS custom properties when you need the compiled CSS to expose them.

Choose the right layer: Sass at build time, JavaScript at runtime

Sass and browser JavaScript operate at different stages. Sass compiles source such as variables, mixins, loops, and selector generation into CSS before that CSS is delivered to the browser. Browser JavaScript runs after page load and can respond to user input or application state by changing CSS values.

That makes a CSS custom property the practical bridge: Sass can emit its initial value, and JavaScript can later update it. Keep stable structure and calculations in Sass; use runtime JavaScript for the smaller set of values that must change while the page is running.

The Sass JavaScript API can drive compilation from JavaScript, including with compile, compileAsync, compileString, and compileStringAsync (Sass JavaScript API). Sass documents compile(path, options) as available in Dart Sass since version 1.45.0; it is not supported by Node Sass (Sass compile() API). This is a build workflow, not a requirement to compile Sass in the browser just to change a style token.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Redragon Mechanical Gaming Keyboard Wired, 11 Programmable Backlit Modes, Hot-Swappable Red Switch, Anti-Ghosting, Double-Shot PBT Keycaps, Light Up Keyboard for PC Mac
  • Brilliant Color Illumination- With 11 unique backlights, choose the perfect ambiance for any mood. Adjust light speed and brightness among 5 levels for a comfortable environment, day or night. The double injection ABS keycaps ensure clear backlight and precise typing. From late-night tasks to immersive gaming, our mechanical keyboard enhances every experience
  • Support Macro Editing: The K671 Mechanical Gaming Keyboard can be macro editing, you can remap the keys function, set shortcuts, or combine multiple key functions in one key to get more efficient work and gaming. The LED Backlit Effects also can be adjusted by the software(note: the color can not be changed)
  • Hot-swappable Linear Red Switch- Our K671 gaming keyboard features red switch, which requires less force to press down and the keys feel smoother and easier to use. It's best for rpgs and mmo, imo games. You will get 4 spare switches and two red keycaps to exchange the key switch when it does not work.
  • Full keys Anti-ghosting- All keys can work simultaneously, easily complete any combining functions without conflicting keys. 12 multimedia key shortcuts allow you to quickly access to calculator/media/volume control/email
  • Professional After-Sales Service- We provide every Redragon customer with 24-Month Warranty , Please feel free to contact us when you meet any problem. We will spare no effort to provide the best service to every customer

Read and change a CSS custom property with JavaScript

Custom properties are CSS declarations whose names begin with two hyphens, such as --accent. They participate in the cascade and inherit from their parent by default. Define one in CSS, use it with var(), then read or set it from JavaScript:

:root {
  --accent: royalblue;
}

.button {
  color: var(--accent);
}
const root = document.documentElement;
const current = getComputedStyle(root)
  .getPropertyValue('--accent')
  .trim();

root.style.setProperty('--accent', 'tomato');

Here, document.documentElement is the page’s root element. Setting --accent there makes the changed value available to descendants through inheritance, unless a more specific declaration overrides it. For a value that should affect only one element, call setProperty() on that element’s style instead.

Rank #2
Sale
RisoPhy Mechanical Gaming Keyboard, RGB 104 Keys Ultra-Slim LED Backlit USB Wired Keyboard with Blue Switch, Durable Abs Keycaps/Anti-Ghosting/Spill-Resistant Computer Keyboard for PC Mac Xbox Gamer
  • 【Mechanical Keyboard: Responsive BLue Switches】RisoPhy PC keyboard features clicky keys which offer you higher accuracy and quicker response with an enjoyable click sound when typing.This keyboard is more comfortable to type on since it features deeper key travel,greater feedback,and more space between keys.For those who prefer keyboards with a more tactile and "clicky" feel,our keyboard with BLUE switches is a nice choice.
  • 【Rainbow Backlit Keyboard: illuminate Your Desktop】With 9 different backlights,5 levels of light speed and brightness,this computer keyboard enriches your gaming experience and improves your mood greatly,which is a great addition to your desktop,especially in the dark.Plus,the ultra-durable double injection ABS engineered keycaps provide crystal clear uniform backlight and greatly improve your typing accuracy at night.
  • 【High-end 104 Keys Full-Size Keyboard】The Win lock function frees your worry about mistyping when gaming(Fn+Win).Keycaps are pluggable and easy to clean,saving you much unnecessary trouble.We designed 4 hydrophobic holes for this keyboard,allowing water to flow away quickly to prevent damage to the keyboard.No longer afraid of accidents.(✦Include a keycaps puller for cleaning or other needs.)
  • 【Advanced Ergonomic Comfort】This PC gamer Keyboard adopts a scientific stair-up keycap design that keeps your arms in the most natural state to minimize hand fatigue for long time use.In order to improve your posture and make you more comfortable during use,the wired keyboard comes with 2 strong foldable rear kickstands to slope it.Moreover,the keyboard is non-slip enough because there are 4 rubber padding underneath the keyboard.
  • 【100% Anti-Ghosting & 12 Multimedia Combinations】100% anti-ghosting gaming keyboard allows all keys to work simultaneously,no matter how fast you type.12 multimedia key shortcuts allow you to quickly access to calculator/media/volume control/email.RisoPhy mechanical gaming keyboard with the number pad greatly improves your productivity.This ultra-durable keyboard with up to 50 million keystrokes life works well with Windows 7/8/10/XP/VISTA/95/98/XP/2000/ME/VISTA and Mac OS Xbox etc.

Use the declaration API for dashed CSS names

CSSStyleDeclaration provides getPropertyValue(), setProperty(), and removeProperty() for declaration blocks. These methods take CSS property names in hyphenated form, which is especially useful for custom properties. Ordinary CSS properties may also have camel-case JavaScript aliases where supported (MDN: CSSStyleDeclaration).

To remove an inline custom-property declaration, call removeProperty('--accent'), or pass an empty string as the value to setProperty(). If you need !important, provide it as the third, priority argument rather than including it in the value; for example, root.style.setProperty('--accent', 'tomato', 'important'). The method returns undefined (MDN: setProperty()).

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Redragon K521 Upgrade Rainbow LED Gaming Keyboard, 104 Keys Wired Mechanical Feeling Keyboard with Multimedia Keys, One-Touch Backlit, Anti-Ghosting, Compatible with PC, Mac, PS4/5, Xbox
  • 【Dreamy Rainbow Gaming Keyboard】K521 Gaming Keyboard Adopts a Different LED Backlight Design, Upgraded on the Traditional LED Backlight Effect, Making the Light More Penetrating, Giving You a More Dazzling Visual Effect, Making Your Gaming Process More Enjoyable
  • 【One Touch Opens & Visual Feast】The K521 Red Dragon Keyboard has a One-Touch on/off Lighting Button for Added Convenience. It also has a Three-Position Adjustable Breathing Mode and a Four-Position Adjustable Brightness Lighting Mode
  • 【Mechanical Feeling & Fast Tapping】The PC Keyboard Keys are Designed for Mechanical Feeling, Giving You a Better Feel During Use and the Ability to Trigger Keys Quickly, Allowing You to Win All Your Games
  • 【19 Keys Anti-Ghosting Keyboard】Anti-Ghosting Ensures Every Button Can Be Triggered. This Allows You to Trigger Key Combinations In The Game Accurately, And Each Skill Can Be Accurately Released to Increase Your Winning Rate. Redragon K521 Will Be Your Perfect Partner
  • 【12 Multimedia Combination Keys】The K521 Wired Gaming Keyboard is Equipped with 12 Multimedia Keys That Can Greatly Enhance Your Gaming/Office Efficiency and Make It More Convenient to Use

Know what you are reading: inline style versus computed style

What you need Use What it tells you
Read an inline declaration element.style.getPropertyValue('--accent') The value declared in that element’s inline style block; it does not tell you the final value contributed by other rules.
Read the effective value getComputedStyle(element).getPropertyValue('--accent') The computed result after stylesheets, inheritance, and the cascade are applied.
Change one element’s inline declaration element.style.setProperty('--accent', value) Adds or changes an inline declaration on that element.

A computed-style object is read-only. Use a mutable inline style or a stylesheet rule to make a change, rather than trying to assign to the computed-style result (MDN: CSSStyleDeclaration).

getPropertyValue() returns an empty string if the property is not set in the declaration being read. For computed style, the returned value is a computed and serialized representation, not necessarily the exact text authored in a stylesheet. Equivalent authored colors, for example, can be returned in an RGB representation. Trim the value when surrounding whitespace is not meaningful, and avoid tests that assume the string will match the original source spelling (MDN: getPropertyValue()).

Rank #4
Sale
Logitech G413 SE Full-Size Mechanical Gaming Keyboard - Black
  • Take your gaming skills to the next level: The Logitech G413 SE is a full-size keyboard with gaming-first features and the durability and performance necessary to compete
  • PBT keycaps: Heat- and wear-resistant, this computer gaming keyboard features the most durable material used in keycap design
  • Tactile mechanical switches: Uncompromising performance is always within reach with this wired gaming keyboard
  • Premium color, material and finish: Elevate your gaming setup with this backlit keyboard featuring a sleek, black-brushed aluminum top case and white LED lighting
  • 6-Key rollover anti-ghosting performance: Experience reliable key input with this anti-ghosting keyboard versus non-gaming mechanical keyboards
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Expose Sass values to CSS—and then to JavaScript

Sass variables exist during compilation; they are not automatically available to browser JavaScript. To make a Sass value available at runtime, interpolate it into a CSS custom-property declaration. Sass treats custom-property values as text and passes tokens through, so a SassScript expression needs interpolation:

$brand: #3366ff;

:root {
  --brand: #{$brand};
  --literal-example: $brand;
}

The compiled CSS contains --brand: #3366ff, but the second declaration contains the literal text $brand. Sass documents this pass-through behavior for custom-property declarations; interpolation is the way to insert the Sass value (Sass: Property Declarations).

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Sale
AULA F2088 Typewriter Style Mechanical Gaming Keyboard Wired, 104 Keys
  • Retro Typewriter Style Round Keycaps: Mechanical blue switch offers a quicker and springier response, crisp click sound, precise tactile feedback for ultimate gaming performance. Double-shot injection molded vintage steampunk round keycaps for clear backlight and extreme durability. The stepped floating keycap fit your fingertips perfectly for precise positioning, prevent fatigue and wrong typing. Comes with keycap puller for easy keycaps cleaning
  • Multimedia and Backlight Control Knob: This wired mechanical keyboard effortlessly controls media thanks to its dedicated media control keys. Quick-access buttons for media volume, backlight effect, music play, pause, switch. You can switch 19 different lighting effects or adjust the backlit brightness and speed. And you can create 3 customized backlight as you like. Long press knob for three seconds to switch between media and lighting modes
  • Metal Panel and Magnetic Wrist Rest: The computer keyboard panel is made of top-grade aluminium alloy material, with matte-finish texture, sturdy and robust enough to protect it from scratch. The ergonomic ABS palm rest provides firm support that alleviates pressure on your wrist from gaming at an elevated angle. The surface has a smooth and comfortable touch that enhances the feeling of the keyboard. USB connector for a reliable connection and ultimate gaming performance
  • 104 Keys Anti-Ghosting Programmable: This mechanical gaming keyboard features Anti Ghosting Technology which ensures your simultaneous keystrokes register the way you intended, allow multi-keys to work simultaneously with high speed. Each key is controlled by independent switch, let you enjoy high-grade games with fast response, boosting your performance! The PC Gaming Keyboard has been ergonomically designed to be a superb typing tool for office work as well
  • Stylish Durable and Wide Compatibility: Modern and sleek design with superior performance. High low key layout with suspended round key fits fingers effectively, help reduce hand fatigue, aluminum alloy metal panel, matte texture, sturdy and robust, protect it from scratch. Support PC Mac Laptop, Tablet, Desktop computer, suitable for Windows 7/8/10/XP/Vista, Linux and Mac OS systems. USB wired conection, plug and play! No drivers or softwares are required

If a quoted Sass string must remain quoted in a custom-property value, interpolation alone removes the quotes. Sass recommends using meta.inspect() for that case. Once the CSS is generated and loaded, browser JavaScript can read or override the emitted custom property just like any other CSS custom property.

Add type and inheritance rules with @property

Ordinary custom properties are flexible and untyped. The CSS Properties and Values API lets you register a property with a syntax, inheritance behavior, and initial value, either with the CSS @property at-rule or JavaScript’s CSS.registerProperty() (MDN: CSS Properties and Values API).

@property --progress {
  syntax: '<number>';
  inherits: false;
  initial-value: 0;
}

MDN marks this API Baseline 2024, meaning it works across the latest devices since July 2024, while warning that older browsers may lack support. If typed behavior is important to your interface, check target-browser compatibility and provide a suitable fallback rather than assuming registration is universally available.

Keep the boundary simple

  • Use Sass for values and structure settled before delivery; use browser JavaScript for values that need to change after page load.
  • Use a custom property as the shared value, and choose its location deliberately: a root-level declaration for inherited page-wide values, or an element’s inline style for a local override.
  • Read with computed style when you want the effective value, but compare semantic values rather than expecting the exact authored spelling.
  • Use Sass interpolation such as #{$brand} to expose a Sass variable in a custom property; a bare Sass variable name there passes through as text.
  • Use @property or CSS.registerProperty() only when syntax, inheritance, or an initial value needs explicit metadata, and account for older-browser support.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.