This example shows two buttons: one styled with SASS-compiled CSS and one styled using CSS-in-JS with JavaScript. Both change color on hover.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>SASS vs CSS-in-JS Example</title>
<style>
/* Compiled SASS styles */
.button {
background-color: #3498db;
color: white;
padding: 1rem 2rem;
border: none;
cursor: pointer;
font-size: 1rem;
border-radius: 0.5rem;
transition: background-color 0.3s ease;
}
.button:hover {
background-color: #2c80b4;
}
</style>
</head>
<body>
<button class="button">SASS Styled Button</button>
<script>
// CSS-in-JS style applied via JavaScript
const cssInJsButton = document.createElement('button');
cssInJsButton.textContent = 'CSS-in-JS Styled Button';
cssInJsButton.style.backgroundColor = '#e67e22';
cssInJsButton.style.color = 'white';
cssInJsButton.style.padding = '1rem 2rem';
cssInJsButton.style.border = 'none';
cssInJsButton.style.cursor = 'pointer';
cssInJsButton.style.fontSize = '1rem';
cssInJsButton.style.borderRadius = '0.5rem';
cssInJsButton.style.transition = 'background-color 0.3s ease';
cssInJsButton.addEventListener('mouseover', () => {
cssInJsButton.style.backgroundColor = '#b36116';
});
cssInJsButton.addEventListener('mouseout', () => {
cssInJsButton.style.backgroundColor = '#e67e22';
});
document.body.appendChild(cssInJsButton);
</script>
</body>
</html>