Corner Shapes visualizer
Home
Snippets
Corner Shapes visualizer
HTML
CSS
JS
<div id="shape-parent"> <div class="controls-card"> <div class="header"> <h2>Corner Shape API</h2> <p>Supported in Chromium 139+</p> </div> <div class="control-group"> <label for="shape-select">corner-shape</label> <div class="select-wrapper"> <select id="shape-select"> <option value="round">Round</option> <option value="scoop">Scoop</option> <option value="bevel">Bevel</option> <option value="notch">Notch</option> <option value="square">Square</option> <option value="squircle">Squircle</option> </select> <svg class="select-icon" xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg> </div> </div> <div class="control-group"> <div class="range-header"> <label for="radius-range">border-radius</label> <span id="radius-value">100px</span> </div> <input type="range" id="radius-range" min="0" max="250" value="30"> </div> </div> </div>
:root { --bg-color: #0f172a; --card-bg: rgba(255, 255, 255, 0.95); --text-primary: #1e293b; --text-secondary: #64748b; --accent-color: #6366f1; } * { box-sizing: border-box; } body { font-family: 'Inter', sans-serif; background-color: var(--bg-color); display: flex; justify-content: center; align-items: center; min-height: 100vh; margin: 0; color: var(--text-primary); } #shape-parent { position: relative; width: 350px; height: 350px; background: linear-gradient(135deg, #6366f1, #ec4899); display: flex; justify-content: center; align-items: center; box-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.5); --corner-shape: round; --border-radius: 30px; corner-shape: var(--corner-shape); border-radius: var(--border-radius); transition: all 0.3s ease; } .controls-card { background: var(--card-bg); padding: 2rem; border-radius: 16px; width: 300px; box-shadow: 0 4px 24px -4px rgba(0, 0, 0, 0.2); display: flex; flex-direction: column; gap: 1rem; z-index: 10; } .header { text-align: center; h2 { margin: 0 0 0.25rem 0; font-size: 1.25rem; } p { margin: 0; color: var(--text-secondary); font-size: 0.875rem; } } .control-group { display: flex; flex-direction: column; gap: 0.5rem; } label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-secondary); } .select-wrapper { position: relative; } select { width: 100%; padding: 0.75rem 1rem; background-color: #f1f5f9; border: 1px solid transparent; border-radius: 8px; font-family: inherit; font-size: 1rem; color: var(--text-primary); appearance: none; cursor: pointer; transition: border-color 0.2s; } select:focus { outline: none; border-color: var(--accent-color); } .select-icon { position: absolute; right: 1rem; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--text-secondary); } .range-header { display: flex; justify-content: space-between; align-items: center; } #radius-value { font-family: monospace; font-size: 0.75rem; background-color: #e0e7ff; color: var(--accent-color); padding: 2px 6px; border-radius: 4px; } input[type=range] { -webkit-appearance: none; width: 100%; height: 6px; background: #e2e8f0; border-radius: 5px; outline: none; margin-top: 0.5rem; } input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 18px; height: 18px; background: var(--accent-color); cursor: pointer; border-radius: 50%; border: 2px solid white; box-shadow: 0 1px 3px rgba(0,0,0,0.1); } input[type=range]::-moz-range-thumb { width: 18px; height: 18px; background: var(--accent-color); cursor: pointer; border-radius: 50%; border: 2px solid white; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
const shapeParent = document.getElementById('shape-parent'); const shapeSelect = document.getElementById('shape-select'); const radiusRange = document.getElementById('radius-range'); const radiusValue = document.getElementById('radius-value'); function updateShape() { const shape = shapeSelect.value; const radius = radiusRange.value + 'px'; radiusValue.textContent = radius; shapeParent.style.setProperty('--corner-shape', shape); shapeParent.style.setProperty('--border-radius', radius); } shapeSelect.addEventListener('change', updateShape); radiusRange.addEventListener('input', updateShape); updateShape();
Ad #1
Ad #2
Scroll to Top