DevPlatform
Home
Components
Search
Submit
Earn
Login
Sign Up Free
Light Mode Toggle - Preview | DevPlatform
DevPlatform
Categories
Accordion
Animation
Box Shadow
Button
Card
Footer
Form
Gallery
Hero Section
Inputs
Loader
Marquee
Modal
Modules
Navbar
Progress Bar
Radio Buttons
Search-Bar
Sections
Slider
Tab
Timeline
Toggle
Light Mode Toggle
jitesh208
Jan 28, 2026
2
0
Share
Live Preview
Refresh
Live Editor
HTML
CSS
JS
HTML
CSS
JavaScript
1
<input type="checkbox" id="flip-toggle" class="toggle-checkbox"> <div class="card-container"> <!-- Front Face - Light Mode --> <div class="card-face card-front"> <div class="particle"></div> <div class="particle"></div> <div class="particle"></div> <div class="icon-container"> <div class="icon-circle">☀️</div> </div> <div class="card-content"> <h2 class="card-title">Light Mode</h2> <p class="card-description"> Bright, clean interface perfect for daytime use and maximum readability. </p> </div> <label for="flip-toggle" class="toggle-button"> <span>Switch to Dark</span> <span>🌙</span> </label> </div> <!-- Back Face - Dark Mode --> <div class="card-face card-back"> <div class="particle"></div> <div class="particle"></div> <div class="particle"></div> <div class="icon-container"> <div class="icon-circle">🌙</div> </div> <div class="card-content"> <h2 class="card-title">Dark Mode</h2> <p class="card-description"> Elegant, sophisticated interface ideal for night viewing and reduced eye strain. </p> <div class="features"> </div> </div> <label for="flip-toggle" class="toggle-button"> <span>Switch to Light</span> <span>☀️</span> </label> </div> </div>
1
* { margin: 0; padding: 0; box-sizing: border-box; } body { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); font-family: 'Poppins', sans-serif; padding: 20px; perspective: 1000px; } /* Hide the checkbox */ .toggle-checkbox { display: none; } /* Main card container */ .card-container { width: 380px; height: 480px; position: relative; transform-style: preserve-3d; transition: transform 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55); } /* Rotate the entire card when checked */ .toggle-checkbox:checked ~ .card-container { transform: rotateY(180deg); } /* Common styles for both card faces */ .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; border-radius: 24px; padding: 40px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.1); display: flex; flex-direction: column; justify-content: space-between; } /* Front face - Light theme */ .card-front { background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%); color: #1a1a2e; } /* Back face - Dark theme */ .card-back { background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%); color: #ffffff; transform: rotateY(180deg); } /* Icon container */ .icon-container { width: 120px; height: 120px; margin: 0 auto 30px; position: relative; } .icon-circle { width: 100%; height: 100%; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 4em; position: relative; animation: float 3s ease-in-out infinite; } .card-front .icon-circle { background: linear-gradient(135deg, #ffd89b 0%, #ff6b9d 100%); box-shadow: 0 15px 35px rgba(255, 107, 157, 0.4), inset 0 -5px 15px rgba(0, 0, 0, 0.1); } .card-back .icon-circle { background: linear-gradient(135deg, #4a69bd 0%, #6c5ce7 100%); box-shadow: 0 15px 35px rgba(108, 92, 231, 0.4), inset 0 -5px 15px rgba(0, 0, 0, 0.2); } @keyframes float { 0%, 100% { transform: translateY(0px); } 50% { transform: translateY(-10px); } } /* Rotating rays around icon */ .icon-circle::before { content: ''; position: absolute; width: 140%; height: 140%; border-radius: 50%; background: linear-gradient(0deg, transparent 48%, currentColor 50%, transparent 52%), linear-gradient(90deg, transparent 48%, currentColor 50%, transparent 52%); opacity: 0.2; animation: rotate-rays 8s linear infinite; } @keyframes rotate-rays { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } /* Card content */ .card-content { text-align: center; flex: 1; display: flex; flex-direction: column; justify-content: center; } .card-title { font-size: 2em; font-weight: 700; margin-bottom: 15px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; } .card-back .card-title { background: linear-gradient(135deg, #4a69bd 0%, #6c5ce7 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; } .card-description { font-size: 1.05em; line-height: 1.6; opacity: 0.8; margin-bottom: 25px; } /* Features list */ .features { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; } .feature-item { display: flex; align-items: center; gap: 12px; padding: 10px 15px; border-radius: 12px; background: rgba(0, 0, 0, 0.03); transition: all 0.3s ease; } .card-back .feature-item { background: rgba(255, 255, 255, 0.05); } .feature-icon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 1.2em; flex-shrink: 0; } .card-front .feature-icon { background: linear-gradient(135deg, #ff6b9d 0%, #ffa06b 100%); } .card-back .feature-icon { background: linear-gradient(135deg, #4a69bd 0%, #6c5ce7 100%); } .feature-text { font-size: 0.9em; text-align: left; font-weight: 500; } /* Toggle button */ .toggle-button { width: 100%; padding: 16px; border-radius: 16px; border: none; font-family: inherit; font-size: 1.1em; font-weight: 600; cursor: pointer; transition: all 0.3s ease; position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; gap: 10px; } .card-front .toggle-button { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4); } .card-back .toggle-button { background: linear-gradient(135deg, #4a69bd 0%, #6c5ce7 100%); color: white; box-shadow: 0 8px 24px rgba(108, 92, 231, 0.4); } .toggle-button::before { content: ''; position: absolute; top: 50%; left: 50%; width: 0; height: 0; border-radius: 50%; background: rgba(255, 255, 255, 0.3); transform: translate(-50%, -50%); transition: width 0.6s, height 0.6s; } .toggle-button:hover::before { width: 300px; height: 300px; } .toggle-button:hover { transform: translateY(-2px); } .card-front .toggle-button:hover { box-shadow: 0 12px 32px rgba(102, 126, 234, 0.6); } .card-back .toggle-button:hover { box-shadow: 0 12px 32px rgba(108, 92, 231, 0.6); } .toggle-button span { position: relative; z-index: 1; } /* Decorative elements */ .card-face::before { content: ''; position: absolute; top: -50%; right: -50%; width: 200%; height: 200%; background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%); pointer-events: none; } .card-back::before { background: radial-gradient(circle, rgba(255, 255, 255, 0.05) 0%, transparent 70%); } /* Particles effect */ .particle { position: absolute; width: 6px; height: 6px; background: currentColor; border-radius: 50%; opacity: 0.3; animation: particle-float 4s ease-in-out infinite; } .particle:nth-child(1) { top: 20%; left: 10%; animation-delay: 0s; } .particle:nth-child(2) { top: 60%; left: 85%; animation-delay: 1s; } .particle:nth-child(3) { top: 80%; left: 20%; animation-delay: 2s; } @keyframes particle-float { 0%, 100% { transform: translateY(0) scale(1); opacity: 0.3; } 50% { transform: translateY(-20px) scale(1.2); opacity: 0.6; } } /* Responsive */ @media (max-width: 480px) { .card-container { width: 100%; max-width: 360px; height: 500px; } .card-face { padding: 30px 25px; } .card-title { font-size: 1.75em; } }
1
Comments
0
Want to comment?
Please
login
or
sign up
to post comments.
No comments yet
Be the first to comment on this component!
Comments 0
Want to comment?
Please login or sign up to post comments.
No comments yet
Be the first to comment on this component!