Get started with classnames CDN
MIT licensed
Classnames is a JS utility for conditionally applying and removing CSS classes.
Tags:- react
- css
- classes
- classname
- classnames
- util
- utility
Stable version
Copied!
How to start using classnames CDN
<!DOCTYPE html>
<html>
<head>
<title>Get started with classnames CDN - cdnhub.io</title>
<script src="https://cdn.jsdelivr.net/npm/classnames@2.5.2/index.min.js"></script>
<style>
.active, .focus {
background-color: lightblue;
}
</style>
</head>
<body>
<button id="toggle-btn">Toggle classes</button>
<script>
const Classnames = require('classnames');
const toggleBtn = document.getElementById('toggle-btn');
const btnClassNames = Classnames.bind(document.getElementById('toggle-btn'));
toggleBtn.addEventListener('click', () => {
btnClassNames.toggle('active');
btnClassNames.toggle('focus');
});
</script>
</body>
</html>
Copied!
Copied!
Copied!
Copied!