ScarCSS
A lightweight, utility-first frontend framework for styling and interactions using custom attributes. ScarCSS provides unique utilities and animations not found in other frameworks, with a familiar syntax that's easy to learn and use.
Features
- Unique Utility Classes: Over 300+ utility classes including unique effects like magic gradients, text effects, and shapes
- Animation System: Built-in entrance and continuous animations
- Hover Effects: Interactive hover states with smooth transitions
- No Dependencies: Pure vanilla JavaScript implementation
- Dynamic Element Support: Automatically processes elements added after initial load
- Auto-generated Classes: Performance optimization through style deduplication
- NPM Package: Easy installation and usage in any project
Installation
Via NPM
npm install scarcss
Via CDN
<script src="https://cdn.jsdelivr.net/npm/scarcss@1.0.0/dist/scarcss.min.js"></script>
Manual Download
Download the latest release from the releases page and include it in your project.
Usage
Basic Usage
Include ScarCSS in your project:
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/scarcss@1.0.0/dist/scarcss.min.js"></script>
</head>
<body>
<h1 @scar="text-3xl text-blue-500 text-glow">Hello ScarCSS!</h1>
<button @scar="bg-magic text-white py-2 px-4 rounded hover-pop"
@action="{alert:'Hello from ScarCSS!'}">
Click Me
</button>
</body>
</html>
With Module Bundler
import ScarCSS from 'scarcss';
const scarCSS = new ScarCSS();
Unique Utility Classes
ScarCSS includes unique utility classes not found in other frameworks:
Magic Gradients
bg-magic - Purple to blue gradient
bg-fire - Pink to red gradient
bg-ocean - Blue gradient
bg-sunset - Pink gradient
bg-forest - Green gradient
Text Effects
text-glow - Subtle text glow
text-shadow - Classic text shadow
text-3d - 3D text effect
text-neon - Neon text effect
Shapes
shape-circle - Perfect circle
shape-blob - Organic blob shape
shape-star - Star shape
shape-heart - Heart shape
Animations
Entrance Animations
animate-fade-in - Fade in effect
animate-slide-up - Slide from bottom
animate-slide-down - Slide from top
animate-slide-left - Slide from right
animate-slide-right - Slide from left
animate-bounce-in - Bounce in effect
animate-zoom-in - Zoom in effect
Continuous Animations
animate-pulse - Gentle pulsing
animate-bounce - Bouncing effect
animate-spin - Continuous spinning
animate-ping - Ping effect
Hover Effects
hover-pop - Scale up on hover
hover-float - Float up on hover
hover-glow - Add glow on hover
hover-tilt - Tilt on hover
JavaScript Actions
Trigger JavaScript behaviors using the @action attribute:
<button @action="{alert:'Hello World'}">Click Me</button>
<button @action="{menuToggle:'#mobileMenu'}">Toggle Menu</button>
<button @action="{modalOpen:'#myModal'}">Open Modal</button>
<button @action="{modalClose:'#myModal'}">Close Modal</button>
<button @action="{copyToClipboard:'Text to copy'}">Copy Text</button>
Examples
Card Component
<div @scar="bg-white rounded-lg shadow-xl p-6 max-w-sm mx-auto">
<div @scar="bg-magic shape-circle w-16 h-16 mx-auto mb-4"></div>
<h3 @scar="text-xl font-bold text-center mb-2">Card Title</h3>
<p @scar="text-gray-600 text-center mb-4">This is a card component styled with ScarCSS.</p>
<button @scar="bg-blue-500 text-white py-2 px-4 rounded hover:bg-blue-600 w-full">
Action Button
</button>
</div>
Animated Button
<button @scar="bg-fire text-white py-3 px-6 rounded-lg hover-pop animate-pulse shadow-lg">
Animated Button
</button>
Responsive Grid
<div @scar="grid grid-cols-1 md:grid-cols-3 gap-4">
<div @scar="bg-ocean text-white p-4 rounded text-center animate-fade-in">Column 1</div>
<div @scar="bg-sunset text-white p-4 rounded text-center animate-fade-in">Column 2</div>
<div @scar="bg-forest text-white p-4 rounded text-center animate-fade-in">Column 3</div>
</div>
API
Utility Classes
ScarCSS provides utility classes for:
- Layout - Display, position, flexbox, grid
- Spacing - Padding, margin
- Sizing - Width, height
- Typography - Font size, weight, color
- Backgrounds - Colors, gradients
- Borders - Width, color, radius
- Effects - Shadows, opacity, filters
- Interactivity - Cursor, pointer events
- Transitions - Transition properties
- Transforms - Scale, rotate, skew
- Animations - Built-in animations
JavaScript Actions
alert(message) - Show browser alert
menuToggle(selector) - Toggle visibility of element
modalOpen(selector) - Show modal element
modalClose(selector) - Hide modal element
copyToClipboard(text) - Copy text to clipboard
Browser Support
ScarCSS works in all modern browsers that support:
- ES6 JavaScript features
- CSS3
- DOM APIs
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature)
- Commit your changes (
git commit -m 'Add some AmazingFeature')
- Push to the branch (
git push origin feature/AmazingFeature)
- Open a pull request
License
MIT License
Author
Zawiyar Awan
Keywords
css, framework, utility, frontend, scar, attributes, tailwind, bootstrap