CSS custom properties as of 2021
Blog post from LogRocket
Web applications often face challenges with managing large amounts of CSS, particularly when dealing with repeated values, which can make updates tedious. CSS custom properties, also known as CSS variables, offer a solution by allowing developers to store values in a single location for reuse across multiple components, simplifying updates and enhancing code clarity through semantic identifiers. These properties are subject to CSS cascading rules and can be utilized in various contexts, such as setting colors, font sizes, grid layouts, and buttons. Developers can also dynamically change these properties using JavaScript, providing flexibility in theme and layout adjustments. In React applications, libraries like React Custom Properties facilitate the application of CSS variables, enabling more efficient and declarative styling. Although CSS variables are still somewhat experimental, they have the potential to function as APIs and interact with JavaScript, making them a versatile tool for modern web development.