CSS Settings Toggle List
A settings panel of rows with a title, a short description and a switch, where the whole row is clickable.
<fieldset class="settings-list">
<legend>Notifications</legend>
<label>
<span><strong>Comments</strong>When someone replies to you</span>
<input type="checkbox" role="switch" checked>
</label>
<label>
<span><strong>Mentions</strong>When someone tags you</span>
<input type="checkbox" role="switch">
</label>
<label>
<span><strong>Weekly digest</strong>A summary every Monday</span>
<input type="checkbox" role="switch" checked>
</label>
</fieldset>
.settings-list {
width: 100%;
max-width: 300px;
margin: 0;
padding: 0;
overflow: hidden;
border: 1px solid #e4e4e7;
border-radius: 14px;
background: #fff;
color: #18181b;
font-family: system-ui, sans-serif;
}
.settings-list legend {
float: left;
width: 100%;
padding: 12px 16px 4px;
color: #71717a;
font-size: 12px;
font-weight: 700;
letter-spacing: 0.06em;
text-transform: uppercase;
}
.settings-list label {
display: flex;
justify-content: space-between;
align-items: center;
gap: 12px;
clear: both;
padding: 10px 16px;
border-top: 1px solid #f4f4f5;
cursor: pointer;
}
.settings-list label:first-of-type {
border-top: 0;
}
.settings-list label:hover {
background: #fafafa;
}
.settings-list span {
display: grid;
color: #71717a;
font-size: 12px;
}
.settings-list strong {
color: #18181b;
font-size: 14px;
font-weight: 600;
}
.settings-list input {
position: relative;
flex: none;
width: 40px;
height: 24px;
margin: 0;
border-radius: 999px;
background: #d4d4d8;
-webkit-appearance: none;
appearance: none;
cursor: pointer;
transition: background 0.2s ease;
}
.settings-list input::before {
content: "";
position: absolute;
top: 3px;
left: 3px;
width: 18px;
height: 18px;
border-radius: 50%;
background: #fff;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
transition: transform 0.2s ease;
}
.settings-list input:checked {
background: #16a34a;
}
.settings-list input:checked::before {
transform: translateX(16px);
}
.settings-list input:focus-visible {
outline: 2px solid #16a34a;
outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
.settings-list input,
.settings-list input::before {
transition: none;
}
}
About this CSS Settings Toggle List
This CSS Settings Toggle List is 101 lines of pure CSS (1.7 KB) with no JavaScript and no dependencies. It uses transitions, transforms, box shadows and CSS Grid. It works in current versions of Chrome, Edge, Safari and Firefox. It works in any stack: plain HTML, React, Vue, Svelte, Astro, WordPress or Webflow.
CSS features used
- transitions
- transforms
- box shadows
- CSS Grid
- Flexbox
- the :checked state (no JavaScript)
- keyboard focus styles
- reduced-motion support
Customize it
The colors in this snippet. Search and replace them to match your brand:
#e4e4e7#fff#18181b#71717a#f4f4f5#fafafa#d4d4d8#16a34a
How to use this settings toggle list
- Copy the HTML and paste it where you want the element to appear.
- Copy the CSS into your stylesheet, or inside a
<style>tag. - Keep the
.settings-listclass name, or rename it in both places. Then tweak colors, sizes and timing to match your design. - Using React or Next.js? Change
classtoclassNamein the HTML. The CSS works as is, including in Tailwind projects (put it in your global stylesheet).
Building with an AI tool?
“Copy for AI” copies a short prompt for Cursor, Claude Code, Lovable, Bolt or v0. Your AI tool opens the Markdown version of this snippet and reads the HTML, CSS and setup notes there. If your tool can't open links, with the code instead. More ways to use copy CSS with AI.