DevPlatform
Home
Components
Search
Submit
Earn
Login
Sign Up Free
Toggle white - 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
Toggle white
sachin007
Jan 25, 2026
2
0
Share
Live Preview
Refresh
Live Editor
HTML
CSS
JS
HTML
CSS
JavaScript
1
<div class="toggle-container"> <div class="toggle-label">3D Toggle Switch</div> <div class="toggle-switch" id="toggleSwitch"> <div class="toggle-track"></div> <div class="toggle-slider"></div> </div> <div class="status-text" id="statusText">OFF</div> </div>
1
body { margin: 0; padding: 0; height: 100vh; display: flex; justify-content: center; align-items: center; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); font-family: Arial, sans-serif; perspective: 1000px; } .toggle-container { text-align: center; } .toggle-label { color: white; font-size: 18px; margin-bottom: 30px; font-weight: 500; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3); } .toggle-switch { position: relative; width: 100px; height: 50px; background: linear-gradient(145deg, #b8b8b8, #e0e0e0); border-radius: 50px; cursor: pointer; transition: all 0.4s ease; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3), inset 0 -4px 8px rgba(0, 0, 0, 0.2), inset 0 4px 8px rgba(255, 255, 255, 0.3); transform-style: preserve-3d; transform: translateZ(0); } .toggle-switch:hover { transform: translateZ(10px) scale(1.05); } .toggle-switch.active { background: linear-gradient(145deg, #45a049, #66bb6a); box-shadow: 0 8px 20px rgba(76, 175, 80, 0.4), inset 0 -4px 8px rgba(0, 0, 0, 0.2), inset 0 4px 8px rgba(255, 255, 255, 0.3); } .toggle-slider { position: absolute; top: 5px; left: 5px; width: 40px; height: 40px; background: linear-gradient(145deg, #ffffff, #f0f0f0); border-radius: 50%; transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55); box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3), inset 0 -2px 4px rgba(0, 0, 0, 0.1), inset 0 2px 4px rgba(255, 255, 255, 0.8); transform: translateZ(20px); } .toggle-switch.active .toggle-slider { transform: translateX(50px) translateZ(20px) rotate(360deg); background: linear-gradient(145deg, #ffffff, #f5f5f5); } .toggle-slider::before { content: ''; position: absolute; top: 50%; left: 50%; width: 30px; height: 30px; background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.8), transparent); border-radius: 50%; transform: translate(-50%, -50%); } .status-text { margin-top: 30px; color: white; font-size: 20px; font-weight: 700; opacity: 0; transform: translateY(-10px) translateZ(0); transition: all 0.4s ease; text-shadow: 0 4px 8px rgba(0, 0, 0, 0.4); letter-spacing: 2px; } .status-text.show { opacity: 1; transform: translateY(0) translateZ(30px); } .toggle-track { position: absolute; top: 50%; left: 10px; right: 10px; height: 2px; background: rgba(0, 0, 0, 0.1); transform: translateY(-50%); border-radius: 2px; }
1
const toggleSwitch = document.getElementById('toggleSwitch'); const statusText = document.getElementById('statusText'); let isActive = false; toggleSwitch.addEventListener('click', function() { isActive = !isActive; if (isActive) { toggleSwitch.classList.add('active'); statusText.textContent = 'ON'; } else { toggleSwitch.classList.remove('active'); statusText.textContent = 'OFF'; } statusText.classList.remove('show'); setTimeout(() => { statusText.classList.add('show'); }, 50); }); // Show initial status setTimeout(() => { statusText.classList.add('show'); }, 100);
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!