Collection of free CSS custom property (variables) code examples from Codepen and other resources

Browse a collection of free CSS custom property (variables) code examples from Codepen and other resources to enhance your website’s design with reusable, maintainable styles.

Text Grid with Mouse Interaction

Author:
@keyframers | December 14, 2020
Made with:
HTML / CSS (SCSS) / JS

Compatible browsers:
Chrome, Edge, Firefox, Opera, Safari
Responsive:
yes
Dependencies:
-
CSS Variables with Shadow Lists

CSS Variables with Shadow Lists

Author:
Will Boyd | December 6, 2020
Made with:
HTML / CSS

About a code

A couple examples of how CSS variables can hold some or all of a list of box-shadows.

Compatible browsers:
Chrome, Edge, Firefox, Opera, Safari
Responsive:
no
Dependencies:
-

Playing with CSS Variables

Author:
Mert Cukuren | December 3, 2020
Made with:
HTML / CSS (SCSS) / JS (Babel)

Compatible browsers:
Chrome, Edge, Firefox, Opera, Safari
Responsive:
no
Dependencies:
randomcolor.js
Theming with Custom Properties

Theming with Custom Properties

Author:
Michelle Barker | November 1, 2020
Made with:
HTML / CSS

Compatible browsers:
Chrome, Edge, Firefox, Opera, Safari
Responsive:
yes
Dependencies:
-
His Dark Materials TV Series Logo with CSS

His Dark Materials TV Series Logo with CSS

Author:
Michelle Barker | November 17, 2020
Made with:
HTML / CSS (SCSS)

Compatible browsers:
Chrome, Edge, Firefox, Opera, Safari
Responsive:
yes
Dependencies:
-

Dark Mode with CSS Variables

Author:
Tushar Choudhari | September 1, 2020
Made with:
HTML / CSS / JS

Compatible browsers:
Chrome, Edge, Firefox, Opera, Safari
Responsive:
yes
Dependencies:
-
Fit Text with CSS Variables

Fit Text with CSS Variables

Author:
Shaw | March 19, 2020
Made with:
HTML / CSS / JS

Compatible browsers:
Chrome, Edge, Firefox, Opera, Safari
Responsive:
yes
Dependencies:
-

Random Bubble Scene Using Variable Scope

Author:
Jhey | November 6, 2019
Made with:
HTML (Pug) / CSS (Stylus)

Compatible browsers:
Chrome, Edge, Firefox, Opera, Safari
Responsive:
yes
Dependencies:
-

SVG Animation with Speech Recognition

Author:
Lisi | May 4, 2019
Made with:
HTML / CSS (SCSS) / JS (Babel)

Compatible browsers:
Chrome, Edge, Firefox, Opera, Safari
Responsive:
yes
Dependencies:
just-animate.js, tweenmax.js

Dynamic CSS @keyframes with CSS Vanilla

Author:
Sandrina Pereira | April 16, 2019
Made with:
HTML / CSS (SCSS) / JS

Compatible browsers:
Chrome, Edge, Firefox, Opera, Safari
Responsive:
no
Dependencies:
-

Sizing Areas with Custom Properties

Author:
Nils Binder | March 19, 2019
Made with:
HTML / CSS (SCSS) / JS

About a code

Illustrates a technique to control the sizing of different areas on your website using CSS custom properties.

Compatible browsers:
Chrome, Edge, Firefox, Opera, Safari
Responsive:
yes
Dependencies:
-
Using Locally Scoped Custom Properties

Using Locally Scoped Custom Properties

Author:
Kevin | March 11, 2019
Made with:
HTML / CSS

About a code

By using locally scopped properties, we can easily style individual components. The title here has a class of .title, as do the h2 for each of the following sections. Because I'm using locally scoped properties to style them, I don't even need to select them, I only have to select the parent and change the value of the property. There is no need to define them in the global scope, as they aren't global properties. For example, the --button-scale has no need to be defined globally, as it's only used within my buttons. Working like this can help keep things nice and organized, yet very easy to make changes without getting into specificity wars or the need to go wild with extra classes to make minor modifications.

Compatible browsers:
Chrome, Edge, Firefox, Opera, Safari
Responsive:
yes
Dependencies:
font-awesome.css
Alerts - Custom Variables

Alerts - Custom Variables

Author:
Robin Rendle | February 25, 2019
Made with:
HTML / CSS (SCSS)

Compatible browsers:
Chrome, Edge, Firefox, Opera, Safari
Responsive:
yes
Dependencies:
-

CSS Theme Switcher

Author:
Michelle Barker | February 18, 2019
Made with:
HTML / CSS (SCSS)

About a code

A user can click or tap on a button to reverse the colors of the site from dark text on a light background to light text on dark. There may be subtle changes too, like switching to a different highlight color to maintain sufficient contrast with the background.

Compatible browsers:
Chrome, Edge, Firefox, Opera, Safari
Responsive:
yes
Dependencies:
-

Custom Cursor with CSS Variables

Author:
Tobias Reich | February 2, 2019
Made with:
HTML / CSS (SCSS) / JS (Babel)

About a code

Custom cursor with CSS variables and a snap animation that focuses the element you're currently hovering.

Compatible browsers:
Chrome, Edge, Firefox, Opera, Safari
Responsive:
no
Dependencies:
-

Expanding Search

Author:
Ana Tudor | November 8, 2018
Made with:
HTML / CSS (SCSS)

Compatible browsers:
Chrome, Edge, Firefox, Opera, Safari
Responsive:
no
Dependencies:
-

Duotone Filtering with CSS Variables

Author:
Jhey | July 11, 2018
Made with:
HTML (Pug) / CSS (Stylus) / JS (Babel)

About a code

Was playing with mix-blend-mode to create different duotone filters. Then I thought it might be cool to have a handy selector wheel to try out different filters. So here it is! A duotone filtering tester using CSS variables. The inner ring is the lightening color whilst the outer is the darkening color. To change the colors, adjust the colors variable in the pug code.

Compatible browsers:
Chrome, Edge, Firefox, Opera, Safari
Responsive:
no
Dependencies:
-

There's No Place Like Home

Author:
tiffany choong | June 23, 2018
Made with:
HTML / CSS (SCSS) / JS (Babel)

About a code

A CSS-only house based off of the Pokemon Gameboy art featuring some JS and CSS variables to change its colours.

Compatible browsers:
Chrome, Edge, Firefox, Opera, Safari
Responsive:
no
Dependencies:
-
Responsive Infographic with CSS Variables and Flexbox Tricks

Responsive Infographic with CSS Variables and Flexbox Tricks

Author:
Ana Tudor | June 20, 2018
Made with:
HTML (Pug) / CSS (SCSS)

Compatible browsers:
Chrome, Edge, Firefox, Opera, Safari
Responsive:
yes
Dependencies:
-

Resizable Elements with Scoped CSS Variables & Touch Support

Author:
Jhey | March 11, 2018
Made with:
HTML (Pug) / CSS (Stylus) / JS (Babel)

Compatible browsers:
Chrome, Edge, Firefox, Opera, Safari
Responsive:
yes
Dependencies:
-

Ripple Effect Using CSS Variables

Author:
jakob-e | February 28, 2018
Made with:
HTML / CSS (SCSS) / JS (TypeScript)

Compatible browsers:
Chrome, Edge, Firefox, Opera, Safari
Responsive:
no
Dependencies:
-

Hover Effect Using CSS Variables

Author:
Dronca Raul | February 26, 2018
Made with:
HTML / CSS (SCSS) / JS

Compatible browsers:
Chrome, Edge, Firefox, Opera, Safari
Responsive:
no
Dependencies:
-

Scroll and Morph

Author:
Mikael Ainalem | February 20, 2018
Made with:
HTML / CSS / JS

About a code

Uses the basicScroll parallax scroll library to morph text on scroll. Morphing is accomplished through CSS variables & CSS clip-path.

Compatible browsers:
Chrome, Edge, Firefox, Opera, Safari
Responsive:
no
Dependencies:
basicScroll.js

Card Animation

Author:
Lam Chang | February 6, 2018
Made with:
HTML / CSS / JS

About a code

Card animation with CSS and HTML and some click events, CSS variables.

Compatible browsers:
Chrome, Edge, Firefox, Opera, Safari
Responsive:
yes
Dependencies:
-

Splitting.js: CSS Vars for Split Words & Chars

Author:
Shaw | December 21, 2017
Made with:
HTML / CSS (SCSS) / JS

About a code

These animations/transitions are all done with CSS after Splitting adds helper spans & CSS Variables.

Compatible browsers:
Chrome, Edge, Firefox, Opera, Safari
Responsive:
yes
Dependencies:
splitting.css, splitting.js

CSS Custom Pproperty Hover Effects

Author:
Marius Niveri | November 10, 2017
Made with:
HTML / CSS (SCSS)

About a code

Adding a cool hover/focus effect to icons from the Orion Icon Library with the help of CSS custom properties.

Compatible browsers:
Chrome, Edge, Firefox, Opera, Safari
Responsive:
yes
Dependencies:
-

Thermostat with Form Elements & CSS Variables

Author:
Ana Tudor | September 26, 2017
Made with:
HTML (Pug) / CSS (SCSS) / JS (Babel)

Compatible browsers:
Chrome, Edge, Firefox, Opera, Safari
Responsive:
no
Dependencies:
conic-gradient.js

Morphing Fullscreen Navigation Menu [~60fps animation]

Author:
Dannie Vinther | September 14, 2017
Made with:
HTML / CSS / JS (Babel)

About a code

Performant fullscreen navigation menu transition using javascript and custom properties (css variables). Ideal for mobile in terms of reachability.

Compatible browsers:
Chrome, Edge, Firefox, Opera, Safari
Responsive:
yes
Dependencies:
-

Card UI Skeleton Screen

Author:
Max Böck | August 9, 2017
Made with:
HTML / CSS (SCSS)

About a code

This creates a skeleton of a card component using CSS custom properties to draw different gradients on the background-image. Skeleton screens can be used to improve perceived performance while loading.

Compatible browsers:
Chrome, Edge, Firefox, Opera, Safari
Responsive:
no
Dependencies:
-
Bar Chart in CSS Grid + Variables

Bar Chart in CSS Grid + Variables

Author:
Miriam Suzanne | August 3, 2017
Made with:
HTML / CSS

Compatible browsers:
Chrome, Edge, Firefox, Opera, Safari
Responsive:
yes
Dependencies:
-

Spring Physics with CSS Variables

Author:
Val Head | June 7, 2017
Made with:
HTML / CSS / JS (Babel)

Compatible browsers:
Chrome, Edge, Firefox, Opera, Safari
Responsive:
yes
Dependencies:
hammer.js

Psycho Glitch (CSS variables & @keyframes)

Author:
Alex Nozdriukhin | May 29, 2017
Made with:
HTML / CSS (SCSS)

About a code

The glitch effect, recreated with animated CSS custom properties. Pure CSS.

Compatible browsers:
Chrome, Edge, Opera, Safari
Responsive:
yes
Dependencies:
-

Sunset/Sunrise Animation with CSS Variables

Author:
Envato Tuts+ | May 22, 2017
Made with:
HTML / CSS (SCSS)

Compatible browsers:
Chrome, Edge, Firefox, Opera, Safari
Responsive:
no
Dependencies:
-

Alex the CSS Husky Reactive

Author:
Envato Tuts+ | May 22, 2017
Made with:
HTML / CSS (SCSS) / JS

Compatible browsers:
Chrome, Edge, Firefox, Opera, Safari
Responsive:
yes
Dependencies:
rx.css, rx.js, rx.dom.js

Cross-Browser Animated CSS Cube with Custom Properties

Author:
Ana Tudor | May 6, 2017
Made with:
HTML (Haml) / CSS (SCSS)

Compatible browsers:
Chrome, Edge, Firefox, Opera, Safari
Responsive:
yes
Dependencies:
-

Single Div Accordion (Animated with CSS Variables)

Author:
Dan Wilson | May 3, 2017
Made with:
HTML / CSS / JS

Compatible browsers:
Chrome, Edge, Firefox, Opera, Safari
Responsive:
yes
Dependencies:
-

News App Concept with CSS Variables

Author:
David Khourshid | April 24, 2017
Made with:
HTML / CSS (SCSS) / JS (Babel)

Compatible browsers:
Chrome, Edge, Firefox, Opera, Safari
Responsive:
yes
Dependencies:
rxcss.css, rx.js, hammer.js, flipping.js

Dance of the Hexagons and Variables

Author:
Dan Wilson | February 23, 2017
Made with:
HTML / CSS / JS

About a code

Using CSS variables and transitions to manipulate separate transform functions individually.

Compatible browsers:
Chrome, Edge, Firefox, Opera, Safari
Responsive:
yes
Dependencies:
-

Parallax Scene with CSS Variables

Author:
Tobias Reich | November 17, 2016
Made with:
HTML / CSS (SCSS) / JS (Babel)

About a code

Parallax scene with JS controlled CSS variables using basicScroll.

Compatible browsers:
Chrome, Edge, Firefox, Opera, Safari
Responsive:
yes
Dependencies:
basicscroll.js

Discover Our Extensive Snippet Library

This heading suggests that your website provides a wide variety of snippets across different technologies, encouraging users to explore and use these resources for their development projects.

HTML Snippets.

Explore a collection of HTML snippets designed to streamline your web development process. From basic structures to complex elements.

CSS Snippets.

Discover powerful CSS snippets that help you style your web pages with ease. Whether you need layout solutions, animations

JavaScript Snippets.

Enhance your website's interactivity with our JavaScript snippets. From DOM manipulation to advanced algorithms

Bootstrap Snippets.

Leverage the power of Bootstrap with our collection of snippets. Quickly integrate responsive design components

Tailwind Snippets.

Speed up your development process with Tailwind CSS snippets. These utility-first CSS snippets enable you to

jQuery Snippets.

Simplify your JavaScript development with jQuery snippets. Easily perform common tasks like event handling, animations

React Snippets.

Build robust, component-based user interfaces with our React snippets. From state management to lifecycle methods,

Vue Snippets.

Streamline Vue.js development with our collection of snippets for creating components, managing state, and handling events.

Ready to set your Brand ablaze?

Let's craft a visual identity that ignites passion and loyalty. ✨