Like toggle
For an action that flips on and off in place — no navigation, no save button, only the state changes.
Live preview
Source
<div class="dc-likebox">
<input class="dc-like__in" type="checkbox" id="dc-like-post" />
<label class="dc-like" for="dc-like-post">
<svg class="dc-like__ico" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 20.3 10.6 19C6.5 15.3 4 13 4 10.2A4.2 4.2 0 0 1 8.2 6c1.5 0 2.9.7 3.8 1.9A4.7 4.7 0 0 1 15.8 6 4.2 4.2 0 0 1 20 10.2c0 2.8-2.5 5.1-6.6 8.8z" /></svg>
<span class="dc-like__txt">좋아요</span>
</label>
</div>
.dc-likebox {
display: flex;
align-items: center;
padding: var(--dc-4);
background: var(--dc-surface);
font-family: var(--dc-font);
}
.dc-like__in {
position: absolute;
width: 1px;
height: 1px;
opacity: 0;
pointer-events: none;
}
.dc-like {
display: inline-flex;
align-items: center;
gap: var(--dc-2);
min-height: 44px;
padding: 0 var(--dc-3);
border-radius: var(--dc-r-full);
color: var(--dc-text-sub);
font-family: var(--dc-font);
font-size: 14px;
font-weight: 600;
cursor: pointer;
transition: background var(--dc-fast), color var(--dc-fast);
}
.dc-like:hover { background: var(--dc-sunken); }
.dc-like__ico {
width: 24px;
height: 24px;
fill: none;
stroke: currentColor;
stroke-width: 1.8;
stroke-linejoin: round;
transition: transform var(--dc-fast), fill var(--dc-fast);
}
.dc-like__txt { line-height: 1.2; }
.dc-like__n {
min-width: 2ch;
font-variant-numeric: tabular-nums;
color: var(--dc-text-sub);
}
.dc-like__in:checked + .dc-like {
color: var(--dc-danger);
background: var(--dc-danger-soft);
}
.dc-like__in:checked + .dc-like .dc-like__ico {
fill: currentColor;
stroke: currentColor;
transform: scale(1.12);
}
.dc-like__in:checked + .dc-like .dc-like__n { color: var(--dc-danger); }
.dc-like__in:focus-visible + .dc-like {
outline: 2px solid var(--dc-brand);
outline-offset: 2px;
}
.dc-like--round {
justify-content: center;
min-width: 44px;
padding: 0;
}
How to use it
- Flip the look on tap; waiting for the server first makes the app feel dead
- When a count is shown, reflect the viewer's own tap in it immediately
- It must be obvious from the shape that tapping again undoes it
Watch out for
- Do not signal the on state with color alone; change fill or weight too
- Built as a checkbox it announces on/off by itself — never a div with a click handler
- Icon-only versions need a dc-sr name and a 44×44px tap target