DIP Switch Row
PCB DIP switch bank — 8-position binary configuration
Size
Material
State
<div class="dip-row">
<div class="dip-switch on" data-dip><div class="dip-lever"></div></div>
<div class="dip-switch" data-dip><div class="dip-lever"></div></div>
<div class="dip-switch on" data-dip><div class="dip-lever"></div></div>
<div class="dip-switch" data-dip><div class="dip-lever"></div></div>
<div class="dip-switch on" data-dip><div class="dip-lever"></div></div>
<div class="dip-switch" data-dip><div class="dip-lever"></div></div>
<div class="dip-switch" data-dip><div class="dip-lever"></div></div>
<div class="dip-switch on" data-dip><div class="dip-lever"></div></div>
</div> .dip-row { display: flex; gap: 4px; padding: 6px 8px; background: var(--bg-inset); border-radius: var(--radius-sm); border: 1px solid var(--border-subtle); }
.dip-switch {
width: 18px; height: 30px; border-radius: 3px;
background: var(--bg-surface); border: 1px solid var(--border-mid);
position: relative; cursor: pointer;
box-shadow: inset 0 1px 0 var(--glossy-hi);
}
.dip-lever {
position: absolute; left: 3px; right: 3px; height: 12px;
border-radius: 2px; background: linear-gradient(180deg, #888, #555);
transition: top 0.12s var(--snap-fast); top: 14px;
box-shadow: 0 1px 2px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.3);
}
.dip-switch.on .dip-lever { top: 3px; background: linear-gradient(180deg, var(--green-hi), var(--green-on)); } API
| Class | Type | Description |
|---|---|---|
.dip-switch | Base | Primary component class |
.md | Size | Medium (default) variant |
.chrome | Material | Chrome surface variant |
.on | State | On state |
Design Notes
Physical Analog
Reference devices: PCB DIP switch banks on synthesizers (Roland TB-303, Korg MS-20), audio equipment, and network hardware. Mechanism: Dual In-line Package switches -- tiny SPST slide switches arrayed in a plastic housing at 2.54mm pitch. Each switch has a detented two-position action. Lever slides vertically (up = ON, down = OFF). Tiny leaf spring provides detent and contact force.
Geometry
| Property | Value |
|---|---|
| Individual switch | 18x30px |
| Lever | 12px tall, slides vertically |
| Array | 4, 8, or 12 switches in a row at 4px gap |
| Housing | Black molded nylon (bg-inset) |
| Lever material | Polished metal (metallic gradient) |
CSS Recipe
Row Container (PCB Housing)
.dip-row { display: flex; gap: 4px; padding: 6px 8px; background: var(--bg-inset); border-radius: var(--radius-sm); border: 1px solid var(--border-subtle); }
Individual Switch Housing
.dip-switch {
width: 18px; height: 30px; border-radius: 3px;
background: var(--bg-surface); border: 1px solid var(--border-mid);
position: relative; cursor: pointer;
box-shadow: inset 0 1px 0 var(--glossy-hi);
}
Lever
.dip-lever {
position: absolute; left: 3px; right: 3px; height: 12px;
border-radius: 2px; background: linear-gradient(180deg, #888, #555);
transition: top 0.12s var(--snap-fast); top: 14px;
box-shadow: 0 1px 2px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.3);
}
ON State
.dip-switch.on .dip-lever { top: 3px; background: linear-gradient(180deg, var(--green-hi), var(--green-on)); }
HTML Structure
<div class="dip-row">
<div class="dip-switch on" data-dip><div class="dip-lever"></div></div>
<div class="dip-switch" data-dip><div class="dip-lever"></div></div>
<div class="dip-switch on" data-dip><div class="dip-lever"></div></div>
<div class="dip-switch" data-dip><div class="dip-lever"></div></div>
<div class="dip-switch on" data-dip><div class="dip-lever"></div></div>
<div class="dip-switch" data-dip><div class="dip-lever"></div></div>
<div class="dip-switch" data-dip><div class="dip-lever"></div></div>
<div class="dip-switch on" data-dip><div class="dip-lever"></div></div>
</div>
Size Variants
No explicit size variants. Fixed dimensions replicate real DIP switch proportions.
Material Variants
- Housing: Panel surface
- Lever OFF: Metallic gradient (
#888to#555) - Lever ON: Green gradient (green-hi to green-on)
- Row container: PCB board (bg-inset)
Theme Behavior
- Surface colors swap via tokens for housing and container
- Metallic lever gradient is fixed (metal is metal)
- Green ON state is fixed
Constraints
- Lever MUST slide vertically:
top: 14px(OFF/down) totop: 3px(ON/up). - Lever transition MUST use
--snap-fastat 0.12s for detent snap feel. - Each switch operates independently (NOT mutually exclusive like segmented control).
- Row container MUST use
bg-insetto represent the PCB mounting board. - Lever MUST have metallic gradient to represent polished metal contact.
Accessibility
- Add
tabindex="0"androle="switch"witharia-checkedon each.dip-switch - Keyboard: Space to toggle individual switch
- Requires JS to toggle
.onclass on each switch independently
♿
Accessibility
- Element
- Use <button> with role="switch"
- Keyboard
- Space to toggle
- Focus
-
Visible focus indicator required. Use native browser focus ring or custom
:focus-visiblestyles.