accent-color 속성

The accent-color property

체크박스·라디오·슬라이더·프로그레스바 같은 브라우저 기본 폼 컨트롤의 색을 CSS 한 줄로 바꾸는 속성. 커스텀 컴포넌트를 새로 만들지 않아도 됩니다.

다른 이름: CSS accent-color폼 컨트롤 강조색
···
html
<div class="wrap" id="wrap">
  <label class="row"><input type="checkbox" checked><span>뉴스레터 구독</span></label>
  <label class="row"><input type="checkbox"><span>SMS 알림</span></label>
  <label class="row"><input type="radio" name="plan" checked><span>Basic</span></label>
  <label class="row"><input type="radio" name="plan"><span>Pro</span></label>
  <input class="full" type="range" min="0" max="100" value="65">
  <progress class="full" id="pg" value="65" max="100"></progress>
  <code id="hex">#5b5bf7</code>
</div>
css
.wrap{width:min(320px,88%);display:grid;gap:clamp(8px,2.2vmin,12px)}
.row{display:flex;align-items:center;gap:8px;font:600 clamp(11px,2.8vmin,13px)/1 system-ui;color:var(--fg)}
input[type=checkbox],input[type=radio]{width:17px;height:17px}
.full{width:100%}
progress{height:9px}
code{justify-self:center;font:700 clamp(9px,2.4vmin,11px)/1 ui-monospace,monospace;color:var(--muted)}
js
var COLORS = ['#5b5bf7', '#f25c8a', '#18c29c', '#f59e0b', '#8b5cf6'];
var wrap = document.getElementById('wrap'), hex = document.getElementById('hex'), pg = document.getElementById('pg');
var idx = 0;
function render() {
  var c = COLORS[idx];
  wrap.style.accentColor = c;
  hex.textContent = c;
}
render();
setInterval(function () { idx = (idx + 1) % COLORS.length; render(); }, 2200);
setInterval(function () { pg.value = 30 + Math.round(Math.random() * 60); }, 1400);

accent-color: 색상;은 checkbox, radio, range, progress 네 가지 기본 폼 컨트롤에 적용됩니다. 브라우저가 컨트롤의 체크 표시·트랙·채워진 영역 등 내부 요소의 색을 자동으로 계산해서 바꿔줍니다 — 배경·테두리·체크마크를 각각 따로 스타일링할 필요가 없습니다.

이 속성은 상속됩니다. 그래서 :root나 상위 컨테이너 하나에 한 번만 지정하면 그 안의 모든 폼 컨트롤에 자동으로 적용됩니다. 값으로 auto를 주면 브라우저·OS 기본색으로 되돌아갑니다.

다만 컨트롤의 크기·모양·둥근 정도까지는 바꿀 수 없습니다 — 완전히 커스텀한 모양이 필요하면 여전히 appearance: none과 직접 그리는 방식이 필요합니다. accent-color는 "색만 빠르게 맞추고 싶을 때" 가장 저렴한 선택지입니다.

언제 쓰나

기본 폼 컨트롤의 브랜드색만 빠르게 맞추고 싶을 때 씁니다. 모양까지 바꿔야 하면 커스텀 컴포넌트가 필요합니다.