UI Components
Explore our collection of modern UI components with ready-to-use code examples.
Button Styles
Customizable button styles with various effects and animations.
/* Base Button Styles */
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
padding: 0.8rem 2rem;
border-radius: var(--border-radius);
font-weight: 600;
transition: var(--transition);
cursor: pointer;
border: none;
position: relative;
overflow: hidden;
z-index: 1;
}
/* Gradient Button */
.btn-gradient {
background: linear-gradient(45deg, var(--accent-color), var(--highlight-color));
background-size: 200% auto;
color: white;
transition: 0.5s;
}
.btn-gradient:hover {
background-position: right center;
}
/* 3D Button Effect */
.btn-3d {
box-shadow: 0 5px 0 0 rgba(0, 0, 0, 0.2);
transition: all 0.1s ease;
}
.btn-3d:active {
transform: translateY(5px);
box-shadow: none;
}
Button Examples
Loader Styles
Creative loading indicators for your applications.
/* Advanced Loader with Multiple Layers */
.loader-advanced-1 {
width: 60px;
height: 60px;
border: 4px solid transparent;
border-top-color: var(--accent-color);
border-bottom-color: var(--accent-color);
border-radius: 50%;
animation: spin 1.5s linear infinite;
position: relative;
}
.loader-advanced-1::before,
.loader-advanced-1::after {
content: '';
position: absolute;
border-radius: 50%;
border: 4px solid transparent;
}
.loader-advanced-1::before {
top: 5px;
left: 5px;
right: 5px;
bottom: 5px;
border-top-color: var(--highlight-color);
border-bottom-color: var(--highlight-color);
animation: spin 2s linear infinite reverse;
}
.loader-advanced-1::after {
top: 15px;
left: 15px;
right: 15px;
bottom: 15px;
border-top-color: var(--warning-color);
border-bottom-color: var(--warning-color);
animation: spin 3s linear infinite;
}
Loader Examples
Card Styles
Modern card designs with hover effects and interactive elements.
/* Card with Hover Effect */
.card-hover-effect {
position: relative;
overflow: hidden;
}
.card-hover-effect::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(45deg,
rgba(15, 52, 96, 0.3),
rgba(233, 69, 96, 0.3));
opacity: 0;
transition: opacity 0.5s ease;
z-index: 1;
}
.card-hover-effect:hover::before {
opacity: 1;
}
.card-hover-content {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
padding: 1.5rem;
background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
transform: translateY(100%);
transition: transform 0.5s ease;
z-index: 2;
}
.card-hover-effect:hover .card-hover-content {
transform: translateY(0);
}
Card Examples

Web Design
Learn modern web design techniques with our comprehensive tutorials.
Explore our collection of web design resources and tools.

JavaScript
Master JavaScript with interactive examples and projects.
Dive deep into modern JavaScript frameworks and libraries.

UI/UX Design
Create beautiful user interfaces with our design system.
Learn the principles of user experience and interface design.
Form Elements
Interactive form components with validation and custom styles.
/* Floating Label Form Control */
.form-floating {
position: relative;
margin-bottom: 1.5rem;
}
.form-floating .form-control {
height: calc(3.5rem + 2px);
padding: 1rem 0.75rem;
}
.form-floating label {
position: absolute;
top: 0;
left: 0;
height: 100%;
padding: 1rem 0.75rem;
pointer-events: none;
border: 1px solid transparent;
transform-origin: 0 0;
transition: opacity 0.1s ease-in-out, transform 0.1s ease-in-out;
}
.form-floating .form-control:focus ~ label,
.form-floating .form-control:not(:placeholder-shown) ~ label {
transform: scale(0.85) translateY(-0.5rem) translateX(0.15rem);
opacity: 0.65;
}
/* Custom Switch Toggle */
.form-switch {
position: relative;
display: inline-block;
width: 50px;
height: 24px;
margin-right: 0.5rem;
}
.switch-slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(255, 255, 255, 0.1);
transition: .4s;
border-radius: 24px;
}
.switch-slider:before {
position: absolute;
content: "";
height: 16px;
width: 16px;
left: 4px;
bottom: 4px;
background-color: var(--text-color);
transition: .4s;
border-radius: 50%;
}
input:checked + .switch-slider {
background-color: var(--accent-color);
}
input:checked + .switch-slider:before {
transform: translateX(26px);
}
Form Example
CSS Animations
Bring your website to life with these animation techniques.
/* Animation Container */
.animation-examples {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
gap: 1.5rem;
margin: 2rem 0;
}
.animation-card {
position: relative;
height: 150px;
background: var(--secondary-color);
border-radius: var(--border-radius);
cursor: pointer;
overflow: hidden;
transition: var(--transition);
}
.animation-card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}
.animation-bg {
position: absolute;
width: 100%;
height: 100%;
background: linear-gradient(45deg, var(--accent-color), var(--highlight-color));
opacity: 0.1;
}
.animation-box {
width: 60px;
height: 60px;
margin: 30px auto;
background: var(--accent-color);
border-radius: 8px;
}
.animation-title {
display: block;
text-align: center;
font-weight: bold;
margin-top: -15px;
color: var(--text-color);
}
/* Keyframe Animations */
@keyframes bounce {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(-20px); }
}
@keyframes rotate {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
@keyframes pulse {
0%, 100% { transform: scale(1); }
50% { transform: scale(1.2); }
}
@keyframes shake {
0%, 100% { transform: translateX(0); }
20%, 60% { transform: translateX(-10px); }
40%, 80% { transform: translateX(10px); }
}
@keyframes flip {
0% { transform: perspective(400px) rotateY(0); }
50% { transform: perspective(400px) rotateY(180deg); }
100% { transform: perspective(400px) rotateY(360deg); }
}
@keyframes float {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(-10px); }
}
/* Animation Classes */
.bounce { animation: bounce 1s infinite ease-in-out; }
.rotate { animation: rotate 2s infinite linear; }
.pulse { animation: pulse 1.5s infinite ease-in-out; }
.shake { animation: shake 0.5s infinite ease-in-out; }
.flip { animation: flip 2s infinite ease-in-out; }
.float { animation: float 3s infinite ease-in-out; }
/* Animation Controls */
.animation-paused .animation-box {
animation-play-state: paused;
}
Image Carousel
A responsive image carousel with navigation controls.

Tanjiro Kamado
Demon Slayer: Kimetsu no Yaiba
.jpg?updatedAt=1753792276753)
Nezuko Kamado
Demon Slayer: Kimetsu no Yaiba

KyΕjurΕ Rengoku
Demon Slayer: Kimetsu no Yaiba
class Carousel {
constructor(element) {
this.carousel = element;
this.inner = this.carousel.querySelector('.carousel-inner');
this.items = this.carousel.querySelectorAll('.carousel-item');
this.prevBtn = this.carousel.querySelector('#carouselPrev');
this.nextBtn = this.carousel.querySelector('#carouselNext');
this.indicators = this.carousel.querySelectorAll('.carousel-indicator');
this.currentIndex = 0;
this.totalItems = this.items.length;
this.autoSlideInterval = null;
this.autoSlideDelay = 5000;
this.init();
}
init() {
this.prevBtn.addEventListener('click', () => this.prev());
this.nextBtn.addEventListener('click', () => this.next());
this.indicators.forEach((indicator, index) => {
indicator.addEventListener('click', () => this.goTo(index));
});
this.startAutoSlide();
// Pause on hover
this.carousel.addEventListener('mouseenter', () => this.stopAutoSlide());
this.carousel.addEventListener('mouseleave', () => this.startAutoSlide());
}
update() {
this.inner.style.transform = `translateX(-${this.currentIndex * 100}%)`;
this.indicators.forEach((indicator, index) => {
indicator.classList.toggle('active', index === this.currentIndex);
});
}
prev() {
this.currentIndex = (this.currentIndex - 1 + this.totalItems) % this.totalItems;
this.update();
}
next() {
this.currentIndex = (this.currentIndex + 1) % this.totalItems;
this.update();
}
goTo(index) {
this.currentIndex = index;
this.update();
}
startAutoSlide() {
this.autoSlideInterval = setInterval(() => this.next(), this.autoSlideDelay);
}
stopAutoSlide() {
clearInterval(this.autoSlideInterval);
}
}
// Initialize carousel
const carousel = new Carousel(document.getElementById('imageCarousel'));
Search Component
An interactive search bar with dynamic results.
class SearchComponent {
constructor(inputId, resultsId, data) {
this.searchInput = document.getElementById(inputId);
this.searchResults = document.getElementById(resultsId);
this.data = data;
this.init();
}
init() {
this.searchInput.addEventListener('input', () => this.handleInput());
this.searchInput.addEventListener('focus', () => {
if (this.searchInput.value.length > 0) {
this.searchResults.style.display = 'block';
}
});
document.addEventListener('click', (e) => {
if (!this.searchInput.contains(e.target) && !this.searchResults.contains(e.target)) {
this.searchResults.style.display = 'none';
}
});
}
handleInput() {
const query = this.searchInput.value.toLowerCase();
if (query.length === 0) {
this.searchResults.style.display = 'none';
return;
}
const results = this.data.filter(item =>
item.title.toLowerCase().includes(query) ||
item.description.toLowerCase().includes(query)
);
this.displayResults(results);
}
displayResults(results) {
this.searchResults.innerHTML = '';
if (results.length === 0) {
const noResults = document.createElement('div');
noResults.className = 'search-result-item';
noResults.textContent = 'No results found';
this.searchResults.appendChild(noResults);
} else {
results.forEach(result => {
const resultItem = document.createElement('div');
resultItem.className = 'search-result-item';
const title = document.createElement('div');
title.className = 'search-result-title';
title.textContent = result.title;
const desc = document.createElement('div');
desc.className = 'search-result-desc';
desc.textContent = result.description;
resultItem.appendChild(title);
resultItem.appendChild(desc);
resultItem.addEventListener('click', () => {
window.location.href = result.link;
});
this.searchResults.appendChild(resultItem);
});
}
this.searchResults.style.display = 'block';
}
}
// Sample data
const searchData = [
{
title: 'Button Styles',
description: 'Various button designs with hover effects',
link: '#buttons'
},
{
title: 'Loader Animations',
description: 'Creative loading indicators',
link: '#loaders'
},
{
title: 'Form Elements',
description: 'Interactive form components',
link: '#forms'
},
{
title: 'CSS Animations',
description: 'Keyframe animations and transitions',
link: '#animations'
}
];
// Initialize search component
const search = new SearchComponent('searchInput', 'searchResults', searchData);
Modal Dialog
A customizable modal dialog with dynamic content.
class Modal {
constructor(modalId) {
this.modal = document.getElementById(modalId);
this.openButtons = document.querySelectorAll(`[data-target="${modalId}"]`);
this.closeButtons = this.modal.querySelectorAll('.modal-close, .btn-cancel');
this.init();
}
init() {
// Open modal when clicking open buttons
this.openButtons.forEach(button => {
button.addEventListener('click', () => this.open());
});
// Close modal when clicking close buttons
this.closeButtons.forEach(button => {
button.addEventListener('click', () => this.close());
});
// Close modal when clicking outside content
this.modal.addEventListener('click', (e) => {
if (e.target === this.modal) {
this.close();
}
});
// Close modal with Escape key
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape' && this.modal.classList.contains('active')) {
this.close();
}
});
}
open() {
this.modal.classList.add('active');
document.body.style.overflow = 'hidden';
}
close() {
this.modal.classList.remove('active');
document.body.style.overflow = '';
}
setContent(title, content) {
const titleElement = this.modal.querySelector('.modal-title');
const contentElement = this.modal.querySelector('.modal-body');
if (titleElement) titleElement.textContent = title;
if (contentElement) contentElement.innerHTML = content;
}
}
// Initialize modal
const modal = new Modal('exampleModal');
// Example of opening modal programmatically
document.getElementById('openModalBtn').addEventListener('click', () => {
modal.open();
});
Toast Notifications
Display temporary notification messages to users.
class Toast {
constructor(containerId) {
this.container = document.getElementById(containerId);
}
show(message, type = 'info', duration = 5000) {
const toast = document.createElement('div');
toast.className = `toast toast-${type}`;
const iconClass = {
success: 'fa-check-circle',
error: 'fa-exclamation-circle',
warning: 'fa-exclamation-triangle',
info: 'fa-info-circle'
}[type];
toast.innerHTML = `
${type.charAt(0).toUpperCase() + type.slice(1)}
`;
this.container.appendChild(toast);
// Show toast
setTimeout(() => {
toast.classList.add('show');
}, 10);
// Close button
toast.querySelector('.toast-close').addEventListener('click', () => {
this.hideToast(toast);
});
// Auto hide
if (duration > 0) {
setTimeout(() => {
this.hideToast(toast);
}, duration);
}
}
hideToast(toast) {
toast.classList.remove('show');
setTimeout(() => {
toast.remove();
}, 300);
}
}
// Initialize toast
const toast = new Toast('toastContainer');
// Example usage
document.getElementById('showSuccessToast').addEventListener('click', () => {
toast.show('Operation completed successfully!', 'success');
});
document.getElementById('showErrorToast').addEventListener('click', () => {
toast.show('An error occurred. Please try again.', 'error');
});
document.getElementById('showWarningToast').addEventListener('click', () => {
toast.show('Warning: This action cannot be undone.', 'warning');
});
document.getElementById('showInfoToast').addEventListener('click', () => {
toast.show('New update available. Check it out!', 'info');
});
Accordion
A collapsible content component for organizing information.
What is CSS?
CSS (Cascading Style Sheets) is a style sheet language used for describing the presentation of a document written in HTML or XML. CSS describes how elements should be rendered on screen, on paper, in speech, or on other media.
What is JavaScript?
JavaScript is a programming language that conforms to the ECMAScript specification. JavaScript is high-level, often just-in-time compiled, and multi-paradigm. It has curly-bracket syntax, dynamic typing, prototype-based object-orientation, and first-class functions.
What is HTML?
The HyperText Markup Language, or HTML is the standard markup language for documents designed to be displayed in a web browser. It can be assisted by technologies such as Cascading Style Sheets (CSS) and scripting languages such as JavaScript.
class Accordion {
constructor(accordionId) {
this.accordion = document.getElementById(accordionId) || document.querySelector(accordionId);
this.items = this.accordion.querySelectorAll('.accordion-item');
this.init();
}
init() {
this.items.forEach(item => {
const header = item.querySelector('.accordion-header');
header.addEventListener('click', () => this.toggleItem(item));
});
}
toggleItem(item) {
const isActive = item.classList.contains('active');
// Close all items
this.items.forEach(i => {
i.classList.remove('active');
});
// Open clicked item if it was closed
if (!isActive) {
item.classList.add('active');
}
}
openItem(index) {
if (index >= 0 && index < this.items.length) {
this.toggleItem(this.items[index]);
}
}
closeItem(index) {
if (index >= 0 && index < this.items.length) {
this.items[index].classList.remove('active');
}
}
}
// Initialize accordion
const accordion = new Accordion('.accordion');
// Example of opening the first item programmatically
accordion.openItem(0);
Tab Component
A tabbed interface for organizing related content.
HTML Basics
HTML (HyperText Markup Language) is the most basic building block of the Web. It defines the meaning and structure of web content. Other technologies besides HTML are generally used to describe a web page's appearance/presentation (CSS) or functionality/behavior (JavaScript).
CSS Basics
Cascading Style Sheets (CSS) is a stylesheet language used to describe the presentation of a document written in HTML or XML (including XML dialects such as SVG, MathML or XHTML). CSS describes how elements should be rendered on screen, on paper, in speech, or on other media.
JavaScript Basics
JavaScript (JS) is a lightweight, interpreted, or just-in-time compiled programming language with first-class functions. While it is most well-known as the scripting language for Web pages, many non-browser environments also use it, such as Node.js, Apache CouchDB and Adobe Acrobat.
class Tabs {
constructor(tabsId) {
this.tabs = document.getElementById(tabsId) || document.querySelector(tabsId);
this.buttons = this.tabs.querySelectorAll('.tab-btn');
this.contents = this.tabs.querySelectorAll('.tab-content');
this.init();
}
init() {
this.buttons.forEach(button => {
button.addEventListener('click', () => {
const tabId = button.getAttribute('data-tab');
this.openTab(tabId);
});
});
}
openTab(tabId) {
// Hide all tab contents
this.contents.forEach(content => {
content.classList.remove('active');
});
// Deactivate all buttons
this.buttons.forEach(button => {
button.classList.remove('active');
});
// Show the selected tab content
const tabContent = this.tabs.querySelector(`#${tabId}`);
if (tabContent) {
tabContent.classList.add('active');
}
// Activate the clicked button
const activeButton = this.tabs.querySelector(`[data-tab="${tabId}"]`);
if (activeButton) {
activeButton.classList.add('active');
}
}
}
// Initialize tabs
const tabs = new Tabs('.tabs');
// Example of opening a tab programmatically
// tabs.openTab('tab2');
Tooltip Component
Display contextual information when hovering over elements.
/* Tooltip Styles */
.tooltip {
position: relative;
display: inline-block;
}
.tooltip-text {
position: absolute;
background: var(--dark-color);
color: var(--light-color);
padding: 0.5rem 1rem;
border-radius: var(--border-radius);
font-size: 0.8rem;
white-space: nowrap;
opacity: 0;
visibility: hidden;
transition: var(--transition);
z-index: 1;
margin-bottom: 0.5rem;
}
/* Position variations */
.tooltip-text.tooltip-right {
top: 50%;
left: 100%;
transform: translateY(-50%);
margin-left: 0.5rem;
margin-bottom: 0;
}
.tooltip-text.tooltip-bottom {
top: 100%;
left: 50%;
transform: translateX(-50%);
margin-top: 0.5rem;
margin-bottom: 0;
}
.tooltip-text.tooltip-left {
top: 50%;
right: 100%;
transform: translateY(-50%);
margin-right: 0.5rem;
margin-bottom: 0;
}
/* Arrow for tooltips */
.tooltip-text::after {
content: '';
position: absolute;
border-width: 5px;
border-style: solid;
}
/* Top tooltip arrow */
.tooltip-text:not(.tooltip-right):not(.tooltip-bottom):not(.tooltip-left)::after {
top: 100%;
left: 50%;
transform: translateX(-50%);
border-color: var(--dark-color) transparent transparent transparent;
}
/* Right tooltip arrow */
.tooltip-text.tooltip-right::after {
top: 50%;
right: 100%;
transform: translateY(-50%);
border-color: transparent var(--dark-color) transparent transparent;
}
/* Bottom tooltip arrow */
.tooltip-text.tooltip-bottom::after {
bottom: 100%;
left: 50%;
transform: translateX(-50%);
border-color: transparent transparent var(--dark-color) transparent;
}
/* Left tooltip arrow */
.tooltip-text.tooltip-left::after {
top: 50%;
left: 100%;
transform: translateY(-50%);
border-color: transparent transparent transparent var(--dark-color);
}
.tooltip:hover .tooltip-text {
opacity: 1;
visibility: visible;
}
Progress Bars
Show progress or completion status with customizable progress bars.
/* Progress Bar Styles */
.progress-container {
margin: 2rem 0;
}
.progress-title {
display: flex;
justify-content: space-between;
margin-bottom: 0.5rem;
font-size: 0.9rem;
}
.progress-bar {
height: 10px;
background: rgba(255, 255, 255, 0.1);
border-radius: 5px;
overflow: hidden;
}
.progress-fill {
height: 100%;
background: linear-gradient(90deg, var(--accent-color), var(--highlight-color));
border-radius: 5px;
transition: width 0.5s ease;
}
/* Animated progress bar */
.progress-animated .progress-fill {
position: relative;
overflow: hidden;
}
.progress-animated .progress-fill::after {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: linear-gradient(
to right,
rgba(255, 255, 255, 0) 0%,
rgba(255, 255, 255, 0.3) 50%,
rgba(255, 255, 255, 0) 100%
);
animation: progressShine 2s infinite;
}
@keyframes progressShine {
0% {
transform: translateX(-100%);
}
100% {
transform: translateX(100%);
}
}
CSS Grid System
Create responsive layouts with CSS Grid.
Basic 12-column Grid
Grid with Span
/* Grid System */
.grid-example {
display: grid;
grid-template-columns: repeat(12, 1fr);
gap: 1rem;
margin: 2rem 0;
}
.grid-item {
background-color: var(--accent-color);
color: var(--light-color);
padding: 1rem;
text-align: center;
border-radius: var(--border-radius);
font-weight: bold;
}
.grid-item:nth-child(odd) {
background-color: var(--highlight-color);
}
/* Responsive Grid Example */
.responsive-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
gap: 1.5rem;
}
/* Grid Areas Example */
.layout-grid {
display: grid;
grid-template-areas:
"header header header"
"sidebar main main"
"footer footer footer";
grid-template-columns: 250px 1fr 1fr;
grid-template-rows: auto 1fr auto;
gap: 1rem;
height: 100vh;
}
.layout-header {
grid-area: header;
}
.layout-sidebar {
grid-area: sidebar;
}
.layout-main {
grid-area: main;
}
.layout-footer {
grid-area: footer;
}
Flexbox Layout
Create flexible layouts with CSS Flexbox.
Basic Flexbox
Flexbox with Wrap
Flexbox Alignment
/* Flexbox Examples */
.flex-example {
display: flex;
gap: 1rem;
margin: 2rem 0;
padding: 1rem;
background: var(--glass-effect);
backdrop-filter: var(--glass-blur);
border-radius: var(--border-radius);
border: var(--glass-border);
}
.flex-item {
background-color: var(--accent-color);
color: var(--light-color);
padding: 1rem;
text-align: center;
border-radius: var(--border-radius);
font-weight: bold;
flex: 1;
}
.flex-item:nth-child(odd) {
background-color: var(--highlight-color);
}
/* Flexbox Direction Variations */
.flex-row {
flex-direction: row;
}
.flex-row-reverse {
flex-direction: row-reverse;
}
.flex-column {
flex-direction: column;
}
.flex-column-reverse {
flex-direction: column-reverse;
}
/* Flexbox Alignment */
.flex-center {
justify-content: center;
align-items: center;
}
.flex-start {
justify-content: flex-start;
}
.flex-end {
justify-content: flex-end;
}
.flex-between {
justify-content: space-between;
}
.flex-around {
justify-content: space-around;
}
.flex-evenly {
justify-content: space-evenly;
}
/* Flexbox Item Alignment */
.align-start {
align-items: flex-start;
}
.align-center {
align-items: center;
}
.align-end {
align-items: flex-end;
}
.align-stretch {
align-items: stretch;
}
Pagination
Navigate through multiple pages of content.
/* Pagination Styles */
.pagination {
display: flex;
justify-content: center;
gap: 0.5rem;
margin: 2rem 0;
list-style: none;
padding: 0;
}
.page-item {
display: inline-block;
}
.page-link {
display: block;
padding: 0.5rem 1rem;
border-radius: var(--border-radius);
background: rgba(255, 255, 255, 0.1);
color: var(--text-color);
transition: var(--transition);
text-decoration: none;
}
.page-link:hover {
background: var(--accent-color);
color: var(--light-color);
}
.page-item.active .page-link {
background: var(--accent-color);
color: var(--light-color);
font-weight: bold;
}
.page-item.disabled .page-link {
opacity: 0.5;
pointer-events: none;
cursor: not-allowed;
}
Dropdown Menu
Interactive dropdown menus for navigation or actions.
/* Dropdown Styles */
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-toggle {
display: flex;
align-items: center;
gap: 0.5rem;
}
.dropdown-menu {
position: absolute;
top: 100%;
left: 0;
min-width: 200px;
background: var(--secondary-color);
border-radius: var(--border-radius);
box-shadow: var(--box-shadow);
padding: 0.5rem 0;
list-style: none;
z-index: 100;
opacity: 0;
visibility: hidden;
transform: translateY(10px);
transition: var(--transition);
}
.dropdown-menu.show {
opacity: 1;
visibility: visible;
transform: translateY(0);
}
.dropdown-item {
display: block;
padding: 0.5rem 1rem;
color: var(--text-color);
text-decoration: none;
transition: var(--transition);
}
.dropdown-item:hover {
background: rgba(255, 255, 255, 0.1);
color: var(--accent-color);
}
.dropdown-divider {
height: 1px;
background: rgba(255, 255, 255, 0.1);
margin: 0.5rem 0;
border: none;
}
/* Hoverable dropdown */
.dropdown-menu-hoverable {
pointer-events: none;
}
.dropdown:hover .dropdown-menu-hoverable {
opacity: 1;
visibility: visible;
transform: translateY(0);
pointer-events: auto;
}
Responsive Utilities
Helper classes for building responsive layouts.
/* Responsive Breakpoints */
/* Extra small devices (phones, 576px and down) */
@media (max-width: 576px) {
.xs-hidden {
display: none !important;
}
.xs-block {
display: block !important;
}
.xs-flex {
display: flex !important;
}
}
/* Small devices (landscape phones, 576px and up) */
@media (min-width: 576px) {
.sm-hidden {
display: none !important;
}
.sm-block {
display: block !important;
}
.sm-flex {
display: flex !important;
}
}
/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) {
.md-hidden {
display: none !important;
}
.md-block {
display: block !important;
}
.md-flex {
display: flex !important;
}
}
/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) {
.lg-hidden {
display: none !important;
}
.lg-block {
display: block !important;
}
.lg-flex {
display: flex !important;
}
}
/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
.xl-hidden {
display: none !important;
}
.xl-block {
display: block !important;
}
.xl-flex {
display: flex !important;
}
}
/* Responsive Text Alignment */
@media (max-width: 576px) {
.text-xs-left { text-align: left !important; }
.text-xs-center { text-align: center !important; }
.text-xs-right { text-align: right !important; }
}
@media (min-width: 576px) {
.text-sm-left { text-align: left !important; }
.text-sm-center { text-align: center !important; }
.text-sm-right { text-align: right !important; }
}
@media (min-width: 768px) {
.text-md-left { text-align: left !important; }
.text-md-center { text-align: center !important; }
.text-md-right { text-align: right !important; }
}
@media (min-width: 992px) {
.text-lg-left { text-align: left !important; }
.text-lg-center { text-align: center !important; }
.text-lg-right { text-align: right !important; }
}
@media (min-width: 1200px) {
.text-xl-left { text-align: left !important; }
.text-xl-center { text-align: center !important; }
.text-xl-right { text-align: right !important; }
}
CSS Custom Properties
Use CSS variables for consistent theming and easy customization.
/* CSS Variables with Dark/Light Mode */
:root {
--primary-color: #1a1a2e;
--secondary-color: #16213e;
--accent-color: #0f3460;
--text-color: #e6e6e6;
--highlight-color: #e94560;
--success-color: #00b894;
--warning-color: #fdcb6e;
--info-color: #0984e3;
--dark-color: #0f0f1a;
--light-color: #f8f9fa;
--border-radius: 8px;
--box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
--transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
--glass-effect: rgba(255, 255, 255, 0.05);
--glass-border: 1px solid rgba(255, 255, 255, 0.1);
--glass-blur: blur(10px);
--section-padding: 6rem 2rem;
--header-height: 80px;
}
/* Light Mode Variables */
[data-theme="light"] {
--primary-color: #f8f9fa;
--secondary-color: #e9ecef;
--accent-color: #3a86ff;
--text-color: #212529;
--highlight-color: #ff006e;
--dark-color: #343a40;
--glass-effect: rgba(0, 0, 0, 0.05);
--glass-border: 1px solid rgba(0, 0, 0, 0.1);
}
/* Using Variables */
.component {
background-color: var(--primary-color);
color: var(--text-color);
border-radius: var(--border-radius);
box-shadow: var(--box-shadow);
transition: var(--transition);
}
.button {
background-color: var(--accent-color);
color: var(--light-color);
border: none;
padding: 0.5rem 1rem;
border-radius: var(--border-radius);
}
.button:hover {
background-color: var(--highlight-color);
}
Dark/Light Mode Toggle
Implement a theme switcher with CSS variables and JavaScript.
// Theme Toggle Implementation
const themeToggle = document.getElementById('themeToggle');
const currentTheme = localStorage.getItem('theme') || 'dark';
// Apply the current theme
document.documentElement.setAttribute('data-theme', currentTheme);
// Update the toggle icon
themeToggle.innerHTML = currentTheme === 'dark' ?
'' : '';
// Toggle theme when button is clicked
themeToggle.addEventListener('click', function() {
const currentTheme = document.documentElement.getAttribute('data-theme');
const newTheme = currentTheme === 'dark' ? 'light' : 'dark';
// Update the theme
document.documentElement.setAttribute('data-theme', newTheme);
localStorage.setItem('theme', newTheme);
// Update the icon
this.innerHTML = newTheme === 'dark' ?
'' : '';
// Show a toast notification
toast.show(`Switched to ${newTheme} mode`, 'success');
});
Glass Morphism Effect
Create modern frosted glass UI elements.
Glass Card
This is an example of the glass morphism effect with backdrop blur.
/* Glass Morphism Styles */
.glass-card {
background: var(--glass-effect);
backdrop-filter: var(--glass-blur);
-webkit-backdrop-filter: var(--glass-blur);
border: var(--glass-border);
border-radius: var(--border-radius);
padding: 2rem;
max-width: 500px;
width: 100%;
box-shadow: var(--box-shadow);
transition: var(--transition);
}
.glass-card:hover {
transform: translateY(-5px);
box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
}
.glass-title {
color: var(--accent-color);
margin-bottom: 1rem;
}
.glass-text {
color: var(--text-color);
opacity: 0.9;
margin-bottom: 1.5rem;
}
/* Glass Navbar Example */
.glass-navbar {
background: var(--glass-effect);
backdrop-filter: var(--glass-blur);
-webkit-backdrop-filter: var(--glass-blur);
border-bottom: var(--glass-border);
padding: 1rem 2rem;
position: fixed;
width: 100%;
top: 0;
z-index: 1000;
}
/* Glass Button Example */
.btn-glass {
background: var(--glass-effect);
backdrop-filter: var(--glass-blur);
-webkit-backdrop-filter: var(--glass-blur);
border: var(--glass-border);
color: var(--text-color);
transition: var(--transition);
}
.btn-glass:hover {
background: rgba(255, 255, 255, 0.2);
transform: translateY(-2px);
}
Custom Scrollbar
Style scrollbars to match your design.
/* Custom Scrollbar Styles */
/* Works in Chrome, Edge, and Safari */
::-webkit-scrollbar {
width: 10px;
height: 10px;
}
::-webkit-scrollbar-track {
background: rgba(255, 255, 255, 0.1);
border-radius: 5px;
}
::-webkit-scrollbar-thumb {
background: var(--accent-color);
border-radius: 5px;
}
::-webkit-scrollbar-thumb:hover {
background: var(--highlight-color);
}
/* For Firefox */
html {
scrollbar-width: thin;
scrollbar-color: var(--accent-color) rgba(255, 255, 255, 0.1);
}
/* Custom scrollbar for specific elements */
.custom-scroll {
scrollbar-width: thin;
scrollbar-color: var(--accent-color) rgba(255, 255, 255, 0.1);
}
.custom-scroll::-webkit-scrollbar {
width: 6px;
}
.custom-scroll::-webkit-scrollbar-thumb {
background: var(--accent-color);
}
Clip-path Effects
Create interesting shapes and reveal effects with clip-path.
/* Clip-path Shapes */
.clip-shape {
width: 150px;
height: 150px;
background: linear-gradient(45deg, var(--accent-color), var(--highlight-color));
margin: 1rem;
}
.clip-circle {
clip-path: circle(50% at 50% 50%);
}
.clip-triangle {
clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}
.clip-pentagon {
clip-path: polygon(50% 0%, 100% 38%, 82% 100%, 18% 100%, 0% 38%);
}
.clip-star {
clip-path: polygon(
50% 0%,
61% 35%,
98% 35%,
68% 57%,
79% 91%,
50% 70%,
21% 91%,
32% 57%,
2% 35%,
39% 35%
);
}
/* Clip-path Animation */
.clip-animate {
animation: clipPathAnimation 8s infinite alternate;
}
@keyframes clipPathAnimation {
0% {
clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%);
}
25% {
clip-path: polygon(0% 0%, 100% 0%, 100% 50%, 0% 50%);
}
50% {
clip-path: polygon(25% 25%, 75% 25%, 75% 75%, 25% 75%);
}
75% {
clip-path: polygon(0% 50%, 100% 50%, 100% 100%, 0% 100%);
}
100% {
clip-path: polygon(0% 0%, 50% 0%, 50% 100%, 0% 100%);
}
}
CSS Filter Effects
Apply visual effects like blur, brightness, and contrast.
/* CSS Filter Effects */
.filter-item {
position: relative;
width: 200px;
height: 200px;
margin: 1rem;
overflow: hidden;
border-radius: var(--border-radius);
}
.filter-item img {
width: 100%;
height: 100%;
object-fit: cover;
transition: var(--transition);
}
.filter-label {
position: absolute;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.7);
color: white;
padding: 0.5rem;
text-align: center;
}
/* Filter Effects */
.filter-blur img {
filter: blur(2px);
}
.filter-brightness img {
filter: brightness(1.5);
}
.filter-contrast img {
filter: contrast(1.5);
}
.filter-grayscale img {
filter: grayscale(100%);
}
.filter-hue-rotate img {
filter: hue-rotate(90deg);
}
.filter-invert img {
filter: invert(100%);
}
.filter-sepia img {
filter: sepia(100%);
}
/* Hover Effects */
.filter-item:hover img {
transform: scale(1.05);
}
.filter-item:hover .filter-label {
background: var(--accent-color);
}
/* Multiple Filters Example */
.filter-multiple {
filter: brightness(1.2) contrast(1.1) saturate(1.5);
}
Blend Modes
Create interesting visual effects by blending elements.
/* Blend Mode Examples */
.blend-container {
position: relative;
width: 300px;
height: 300px;
margin: 1rem;
border-radius: var(--border-radius);
overflow: hidden;
}
.blend-image {
width: 100%;
height: 100%;
background-size: cover;
background-position: center;
}
.blend-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0.7;
}
.blend-label {
position: absolute;
bottom: 1rem;
left: 1rem;
color: white;
font-weight: bold;
z-index: 1;
}
/* Blend Mode Variations */
.blend-multiply .blend-overlay {
mix-blend-mode: multiply;
}
.blend-screen .blend-overlay {
mix-blend-mode: screen;
}
.blend-overlay .blend-overlay {
mix-blend-mode: overlay;
}
.blend-darken .blend-overlay {
mix-blend-mode: darken;
}
.blend-lighten .blend-overlay {
mix-blend-mode: lighten;
}
.blend-color-dodge .blend-overlay {
mix-blend-mode: color-dodge;
}
.blend-color-burn .blend-overlay {
mix-blend-mode: color-burn;
}
.blend-hard-light .blend-overlay {
mix-blend-mode: hard-light;
}
.blend-soft-light .blend-overlay {
mix-blend-mode: soft-light;
}
.blend-difference .blend-overlay {
mix-blend-mode: difference;
}
.blend-exclusion .blend-overlay {
mix-blend-mode: exclusion;
}
.blend-hue .blend-overlay {
mix-blend-mode: hue;
}
.blend-saturation .blend-overlay {
mix-blend-mode: saturation;
}
.blend-color .blend-overlay {
mix-blend-mode: color;
}
.blend-luminosity .blend-overlay {
mix-blend-mode: luminosity;
}
3D Transforms
Create 3D effects with CSS transforms and perspective.
Front Side
This is the front of the 3D card
Back Side
This is the back of the 3D card
/* 3D Transform Examples */
.transform-3d {
width: 300px;
height: 200px;
position: relative;
transform-style: preserve-3d;
transition: transform 1s;
transform: perspective(1000px) rotateY(0deg);
}
.transform-3d:hover {
transform: perspective(1000px) rotateY(180deg);
}
.transform-front, .transform-back {
position: absolute;
width: 100%;
height: 100%;
backface-visibility: hidden;
border-radius: var(--border-radius);
padding: 2rem;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
box-shadow: var(--box-shadow);
}
.transform-front {
background: linear-gradient(45deg, var(--accent-color), var(--highlight-color));
color: white;
}
.transform-back {
background: linear-gradient(45deg, var(--highlight-color), var(--warning-color));
color: white;
transform: rotateY(180deg);
}
/* 3D Cube Example */
.cube-container {
width: 200px;
height: 200px;
position: relative;
transform-style: preserve-3d;
animation: rotateCube 10s infinite linear;
}
.cube-face {
position: absolute;
width: 100%;
height: 100%;
opacity: 0.8;
border: 2px solid white;
display: flex;
justify-content: center;
align-items: center;
font-size: 2rem;
font-weight: bold;
color: white;
}
.cube-face.front {
background: rgba(255, 0, 0, 0.7);
transform: translateZ(100px);
}
.cube-face.back {
background: rgba(0, 255, 0, 0.7);
transform: translateZ(-100px);
}
.cube-face.right {
background: rgba(0, 0, 255, 0.7);
transform: rotateY(90deg) translateZ(100px);
}
.cube-face.left {
background: rgba(255, 255, 0, 0.7);
transform: rotateY(-90deg) translateZ(100px);
}
.cube-face.top {
background: rgba(255, 0, 255, 0.7);
transform: rotateX(90deg) translateZ(100px);
}
.cube-face.bottom {
background: rgba(0, 255, 255, 0.7);
transform: rotateX(-90deg) translateZ(100px);
}
@keyframes rotateCube {
from {
transform: rotateX(0) rotateY(0) rotateZ(0);
}
to {
transform: rotateX(360deg) rotateY(360deg) rotateZ(360deg);
}
}
SVG Animations
Animate SVG graphics with CSS and JavaScript.
/* SVG Animation Styles */
.svg-animation {
display: block;
margin: 0 auto;
}
.svg-circle {
transition: stroke-dashoffset 1s ease-in-out;
}
.svg-text {
font-family: Arial, sans-serif;
font-weight: bold;
}
/* SVG Path Animation Example */
.svg-path {
stroke-dasharray: 1000;
stroke-dashoffset: 1000;
animation: dash 5s linear forwards;
}
@keyframes dash {
to {
stroke-dashoffset: 0;
}
}
/* SVG Morph Example */
.svg-morph {
transition: d 0.5s ease;
}
.svg-morph:hover {
d: path("M10,10 Q50,100 90,10 T170,10");
}
Scroll Animations
Trigger animations when elements come into view.
// Scroll Animation Implementation
const scrollElements = document.querySelectorAll('.scroll-animation-box');
const elementInView = (el) => {
const elementTop = el.getBoundingClientRect().top;
return (
elementTop <= (window.innerHeight || document.documentElement.clientHeight)
);
};
const displayScrollElement = (element) => {
element.classList.add('animated');
};
const hideScrollElement = (element) => {
element.classList.remove('animated');
};
const handleScrollAnimation = () => {
scrollElements.forEach((el) => {
if (elementInView(el)) {
displayScrollElement(el);
} else {
hideScrollElement(el);
}
});
};
// Initialize
window.addEventListener('scroll', () => {
handleScrollAnimation();
});
// Check on load
handleScrollAnimation();
Parallax Effects
Create depth with parallax scrolling effects.
Parallax Scrolling
Create engaging scrolling experiences
// Parallax Implementation
const parallaxContainer = document.querySelector('.parallax-container');
const parallaxLayers = document.querySelectorAll('.parallax-layer');
const updateParallax = () => {
const scrollPosition = window.pageYOffset;
const containerTop = parallaxContainer.offsetTop;
const containerHeight = parallaxContainer.offsetHeight;
// Only animate when container is in view
if (scrollPosition > containerTop - window.innerHeight &&
scrollPosition < containerTop + containerHeight) {
const containerScrollPosition = scrollPosition - containerTop;
parallaxLayers.forEach(layer => {
const speed = parseFloat(layer.getAttribute('data-speed'));
const yPos = -(containerScrollPosition * speed);
layer.style.transform = `translate3d(0, ${yPos}px, 0)`;
});
}
};
// Initialize
window.addEventListener('scroll', updateParallax);
window.addEventListener('resize', updateParallax);
Web Animations API
Create complex animations with JavaScript.
// Web Animations API Example
const waapiBox = document.getElementById('waapiBox');
let waapiAnimation;
// Create animation
function createAnimation() {
waapiAnimation = waapiBox.animate([
{
transform: 'translateX(0) rotate(0deg)',
backgroundColor: 'var(--accent-color)',
borderRadius: '0'
},
{
transform: 'translateX(200px) rotate(180deg)',
backgroundColor: 'var(--highlight-color)',
borderRadius: '50%'
},
{
transform: 'translateX(400px) rotate(360deg)',
backgroundColor: 'var(--warning-color)',
borderRadius: '0'
}
], {
duration: 2000,
iterations: Infinity,
direction: 'alternate',
easing: 'ease-in-out'
});
}
// Initialize animation
createAnimation();
// Control buttons
document.getElementById('waapiPlay').addEventListener('click', () => {
waapiAnimation.play();
});
document.getElementById('waapiPause').addEventListener('click', () => {
waapiAnimation.pause();
});
document.getElementById('waapiReverse').addEventListener('click', () => {
waapiAnimation.reverse();
});
document.getElementById('waapiCancel').addEventListener('click', () => {
waapiAnimation.cancel();
createAnimation();
});
Service Workers
Enable offline functionality and background sync.
// Service Worker Registration
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/sw.js')
.then(registration => {
console.log('ServiceWorker registration successful');
})
.catch(err => {
console.log('ServiceWorker registration failed: ', err);
});
});
}
// Service Worker Implementation (sw.js)
const CACHE_NAME = 'my-site-cache-v1';
const urlsToCache = [
'/',
'/styles/main.css',
'/scripts/main.js',
'/images/logo.png'
];
self.addEventListener('install', event => {
event.waitUntil(
caches.open(CACHE_NAME)
.then(cache => {
return cache.addAll(urlsToCache);
})
);
});
self.addEventListener('fetch', event => {
event.respondWith(
caches.match(event.request)
.then(response => {
// Cache hit - return response
if (response) {
return response;
}
// Clone the request
const fetchRequest = event.request.clone();
return fetch(fetchRequest).then(
response => {
// Check if we received a valid response
if (!response || response.status !== 200 || response.type !== 'basic') {
return response;
}
// Clone the response
const responseToCache = response.clone();
caches.open(CACHE_NAME)
.then(cache => {
cache.put(event.request, responseToCache);
});
return response;
}
);
})
);
});
self.addEventListener('activate', event => {
const cacheWhitelist = [CACHE_NAME];
event.waitUntil(
caches.keys().then(cacheNames => {
return Promise.all(
cacheNames.map(cacheName => {
if (cacheWhitelist.indexOf(cacheName) === -1) {
return caches.delete(cacheName);
}
})
);
})
);
});
WebSockets
Enable real-time bidirectional communication.
// WebSocket Implementation
const wsMessages = document.getElementById('websocketMessages');
const wsInput = document.getElementById('websocketInput');
const wsSend = document.getElementById('websocketSend');
// Connect to WebSocket server (replace with your server URL)
const socket = new WebSocket('wss://echo.websocket.org');
socket.onopen = function(e) {
addMessage('Connected to WebSocket server', 'system');
};
socket.onmessage = function(event) {
addMessage(event.data, 'received');
};
socket.onclose = function(event) {
if (event.wasClean) {
addMessage(`Connection closed cleanly, code=${event.code} reason=${event.reason}`, 'system');
} else {
addMessage('Connection died', 'system');
}
};
socket.onerror = function(error) {
addMessage(`Error: ${error.message}`, 'error');
};
// Send message
function sendMessage() {
const message = wsInput.value;
if (message) {
socket.send(message);
addMessage(message, 'sent');
wsInput.value = '';
}
}
// Add message to UI
function addMessage(message, type) {
const messageElement = document.createElement('div');
messageElement.className = `websocket-message websocket-${type}`;
messageElement.textContent = message;
wsMessages.appendChild(messageElement);
wsMessages.scrollTop = wsMessages.scrollHeight;
}
// Event listeners
wsSend.addEventListener('click', sendMessage);
wsInput.addEventListener('keypress', function(e) {
if (e.key === 'Enter') {
sendMessage();
}
});
Accessibility (a11y)
Make your website usable by everyone.
Semantic HTML
Use proper HTML elements for their intended purpose.
<nav> for navigation
<button> for buttons
<article> for self-contained content
<header>, <footer> for page structure
<h1>-<h6> for headings hierarchy
ARIA Attributes
Enhance accessibility when native HTML isn't enough.
<div role="button" tabindex="0">Click me</div>
<div aria-label="Close">X</div>
<button aria-expanded="false">Menu</button>
<input aria-invalid="true">
Keyboard Navigation
Ensure all functionality is available via keyboard.
<button tabindex="0">Interactive</button>
<div tabindex="-1">Programmatically focusable</div>
<a href="#content">Skip to content</a>
# Web Accessibility Checklist
## Perceivable
- Provide text alternatives for non-text content
- Provide captions and other alternatives for multimedia
- Create content that can be presented in different ways
- Make it easier for users to see and hear content
## Operable
- Make all functionality available from a keyboard
- Give users enough time to read and use content
- Do not use content that causes seizures
- Help users navigate and find content
## Understandable
- Make text readable and understandable
- Make content appear and operate in predictable ways
- Help users avoid and correct mistakes
## Robust
- Maximize compatibility with current and future tools
Modern Browser APIs
Powerful APIs available in modern browsers.
Geolocation API
Get the user's current location with permission.
Notifications API
Display system notifications to users.
Media Devices API
Access camera and microphone with permission.
Storage APIs
LocalStorage, SessionStorage, IndexedDB, and Cache API.
// Geolocation API Example
document.getElementById('geolocationBtn').addEventListener('click', () => {
if ('geolocation' in navigator) {
navigator.geolocation.getCurrentPosition(
position => {
const { latitude, longitude } = position.coords;
toast.show(`Location: ${latitude}, ${longitude}`, 'success');
},
error => {
toast.show(`Error: ${error.message}`, 'error');
}
);
} else {
toast.show('Geolocation not supported', 'error');
}
});
// Notifications API Example
document.getElementById('notificationBtn').addEventListener('click', () => {
if ('Notification' in window) {
Notification.requestPermission().then(permission => {
if (permission === 'granted') {
new Notification('Hello!', {
body: 'You have enabled notifications',
icon: '/icon.png'
});
}
});
}
});
// Media Devices API Example
document.getElementById('mediaDevicesBtn').addEventListener('click', () => {
if ('mediaDevices' in navigator) {
navigator.mediaDevices.getUserMedia({ video: true, audio: true })
.then(stream => {
toast.show('Media access granted', 'success');
// Do something with the stream
})
.catch(error => {
toast.show(`Error: ${error.message}`, 'error');
});
}
});
// Storage API Example
document.getElementById('storageBtn').addEventListener('click', () => {
// LocalStorage
localStorage.setItem('example', 'LocalStorage data');
// SessionStorage
sessionStorage.setItem('example', 'SessionStorage data');
// IndexedDB
const request = indexedDB.open('exampleDB', 1);
request.onupgradeneeded = event => {
const db = event.target.result;
db.createObjectStore('data', { keyPath: 'id' });
};
request.onsuccess = event => {
const db = event.target.result;
const transaction = db.transaction('data', 'readwrite');
const store = transaction.objectStore('data');
store.add({ id: 1, value: 'IndexedDB data' });
};
toast.show('Data stored in various storage APIs', 'success');
});
Testing and Debugging
Tools and techniques for testing and debugging web applications.
Browser DevTools
- Elements panel for DOM inspection
- Console for JavaScript debugging
- Network panel for API calls
- Performance panel for profiling
- Memory panel for leaks
Unit Testing
- Jest - JavaScript testing framework
- Mocha - Feature-rich test framework
- Chai - Assertion library
- Sinon - Spies, stubs and mocks
- Testing Library - DOM testing utilities
E2E Testing
- Cypress - Modern web testing
- Playwright - Cross-browser testing
- Selenium - Browser automation
- Puppeteer - Headless Chrome
// Example Jest Test
import { render, screen, fireEvent } from '@testing-library/react';
import Button from './Button';
describe('Button Component', () => {
test('renders button with text', () => {
render(<Button>Click me</Button>);
const buttonElement = screen.getByText(/click me/i);
expect(buttonElement).toBeInTheDocument();
});
test('calls onClick handler when clicked', () => {
const handleClick = jest.fn();
render(<Button onClick={handleClick}>Click me</Button>);
fireEvent.click(screen.getByText(/click me/i));
expect(handleClick).toHaveBeenCalledTimes(1);
});
test('applies primary style when primary prop is true', () => {
render(<Button primary>Primary</Button>);
const buttonElement = screen.getByText(/primary/i);
expect(buttonElement).toHaveClass('button--primary');
});
});
// Example Cypress Test
describe('Login Page', () => {
it('should login with valid credentials', () => {
cy.visit('/login');
cy.get('#email').type('user@example.com');
cy.get('#password').type('password123');
cy.get('button[type="submit"]').click();
cy.url().should('include', '/dashboard');
});
it('should show error with invalid credentials', () => {
cy.visit('/login');
cy.get('#email').type('invalid@example.com');
cy.get('#password').type('wrongpassword');
cy.get('button[type="submit"]').click();
cy.get('.error-message').should('be.visible');
});
});
Modern Build Tools
Tools to optimize and bundle your frontend code.
Webpack
Module bundler with extensive plugin system.
Vite
Next generation frontend tooling with instant server start.
React
A JavaScript library for building user interfaces.
Django
High-level Python web framework for rapid development.
Rollup
Efficient bundler for libraries and applications.
Parcel
Zero configuration web application bundler.
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.[contenthash].js',
clean: true,
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
},
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'postcss-loader'
]
},
{
test: /\.(png|svg|jpg|jpeg|gif)$/i,
type: 'asset/resource'
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: './src/index.html'
}),
new MiniCssExtractPlugin({
filename: 'styles.[contenthash].css'
})
],
devServer: {
static: {
directory: path.join(__dirname, 'dist'),
},
compress: true,
port: 9000,
hot: true,
},
optimization: {
splitChunks: {
chunks: 'all',
},
},
};
Contact Us
Have questions or feedback? Send us a message.