폼
스위치
즉시 적용되는 설정을 전환할 때 진주빛 손잡이가 잉크색 영역 위로 미끄러져 이동합니다.
이 페이지의 내용
스위치는 진주빛 손잡이가 잉크색 영역 위로 미끄러져 이동하는 오목한 영역입니다. 변경 즉시 적용되는 설정에는 기본 체크박스에 .switch 클래스와 role="switch" 속성을 함께 적용하세요. 폼과 함께 제출하는 선택 항목에는 체크박스가 의미를 더 명확히 전달합니다.
스위치
<label class="check"> <input type="checkbox" role="switch" class="switch" checked> Email notifications</label><label className="check"> <input type="checkbox" role="switch" className="switch" defaultChecked /> Email notifications</label><label class="check"> <input type="checkbox" role="switch" class="switch" checked> Email notifications</label><template> <label class="check"> <input type="checkbox" role="switch" class="switch" checked> Email notifications </label></template>#크기
크기
<input type="checkbox" role="switch" class="switch switch-sm" aria-label="Small" checked><input type="checkbox" role="switch" class="switch" aria-label="Medium" checked><input type="checkbox" role="switch" class="switch switch-lg" aria-label="Large" checked><> <input type="checkbox" role="switch" className="switch switch-sm" aria-label="Small" defaultChecked /> <input type="checkbox" role="switch" className="switch" aria-label="Medium" defaultChecked /> <input type="checkbox" role="switch" className="switch switch-lg" aria-label="Large" defaultChecked /></><input type="checkbox" role="switch" class="switch switch-sm" aria-label="Small" checked><input type="checkbox" role="switch" class="switch" aria-label="Medium" checked><input type="checkbox" role="switch" class="switch switch-lg" aria-label="Large" checked><template> <input type="checkbox" role="switch" class="switch switch-sm" aria-label="Small" checked> <input type="checkbox" role="switch" class="switch" aria-label="Medium" checked> <input type="checkbox" role="switch" class="switch switch-lg" aria-label="Large" checked></template>#설정 목록의 스위치
설정 목록
<div class="sheet flex flex-col p(0)"> <label class="check justify-between gap-lg px-lg py-md"> <span>Automatic updates</span> <input type="checkbox" role="switch" class="switch" checked> </label> <label class="check justify-between gap-lg px-lg py-md bt(1) bt-solid bt-line-hair"> <span>Usage analytics</span> <input type="checkbox" role="switch" class="switch"> </label></div><div className="sheet flex flex-col p(0)"> <label className="check justify-between gap-lg px-lg py-md"> <span>Automatic updates</span> <input type="checkbox" role="switch" className="switch" defaultChecked /> </label> <label className="check justify-between gap-lg px-lg py-md bt(1) bt-solid bt-line-hair"> <span>Usage analytics</span> <input type="checkbox" role="switch" className="switch" /> </label></div><div class="sheet flex flex-col p(0)"> <label class="check justify-between gap-lg px-lg py-md"> <span>Automatic updates</span> <input type="checkbox" role="switch" class="switch" checked> </label> <label class="check justify-between gap-lg px-lg py-md bt(1) bt-solid bt-line-hair"> <span>Usage analytics</span> <input type="checkbox" role="switch" class="switch"> </label></div><template> <div class="sheet flex flex-col p(0)"> <label class="check justify-between gap-lg px-lg py-md"> <span>Automatic updates</span> <input type="checkbox" role="switch" class="switch" checked> </label> <label class="check justify-between gap-lg px-lg py-md bt(1) bt-solid bt-line-hair"> <span>Usage analytics</span> <input type="checkbox" role="switch" class="switch"> </label> </div></template>#비활성 상태
비활성 상태
<input type="checkbox" role="switch" class="switch" aria-label="Beta features" disabled><input type="checkbox" role="switch" class="switch" aria-label="Security alerts" checked disabled><> <input type="checkbox" role="switch" className="switch" aria-label="Beta features" disabled /> <input type="checkbox" role="switch" className="switch" aria-label="Security alerts" defaultChecked disabled /></><input type="checkbox" role="switch" class="switch" aria-label="Beta features" disabled><input type="checkbox" role="switch" class="switch" aria-label="Security alerts" checked disabled><template> <input type="checkbox" role="switch" class="switch" aria-label="Beta features" disabled> <input type="checkbox" role="switch" class="switch" aria-label="Security alerts" checked disabled></template>#접근성
- 보조 기술이 체크 여부 대신 켜짐과 꺼짐을 알리도록
role="switch"속성을 유지하세요. - 모든 스위치에는 레이블이 필요합니다. 스위치를
<label>요소로 감싸거나,<label for>로 레이블을 연결하거나,aria-label속성을 지정하세요. - 입력 요소는 기본 컨트롤과 마찬가지로 포커스를 받을 수 있으며 Space 키로 상태를 전환합니다.
#클래스
| 클래스 | 설명 |
|---|---|
switch | role="switch"를 지정한 네이티브 체크박스입니다. 트랙의 높이는 22px이고 손잡이는 트랙 가장자리에서 3px 안쪽에 놓입니다. 터치 화면에서는 같은 트랙 주변에 44px 크기의 터치 영역을 확보하며, 텍스트를 오른쪽에서 왼쪽으로 읽는 환경에서는 손잡이가 반대 방향으로 움직입니다. |
switch-sm | 18px 트랙. 기본값은 22px입니다.적용할 클래스는 switch입니다 |
switch-lg | 26px 트랙입니다. 기본값은 22px입니다.적용할 클래스는 switch입니다 |