폼
라디오 버튼
여러 선택지 중 하나를 고르는 작고 둥근 버튼으로, 네이티브 라디오 입력에 적용합니다.
이 페이지의 내용
라디오 버튼은 작고 둥글며 안쪽이 오목합니다. 선택하면 안쪽이 색으로 채워지고 점이 나타납니다. 둥근 라디오 버튼은 ‘이 중 하나’를, 네모난 체크박스는 ‘이 중 원하는 항목 모두’를 뜻합니다. 네이티브 <input type="radio">에 .radio를 적용하고, 입력 요소와 해당 텍스트를 <label class="check">로 감싸 행 어디를 눌러도 선택할 수 있게 하세요.
라디오 버튼
<fieldset class="fieldset"> <legend class="fieldset-legend">Visibility</legend> <label class="check"> <input type="radio" class="radio" name="visibility" value="public" checked> Public </label> <label class="check"> <input type="radio" class="radio" name="visibility" value="team"> Team only </label> <label class="check"> <input type="radio" class="radio" name="visibility" value="private"> Private </label></fieldset><fieldset className="fieldset"> <legend className="fieldset-legend">Visibility</legend> <label className="check"> <input type="radio" className="radio" name="visibility" value="public" defaultChecked /> Public </label> <label className="check"> <input type="radio" className="radio" name="visibility" value="team" /> Team only </label> <label className="check"> <input type="radio" className="radio" name="visibility" value="private" /> Private </label></fieldset><fieldset class="fieldset"> <legend class="fieldset-legend">Visibility</legend> <label class="check"> <input type="radio" class="radio" name="visibility" value="public" checked> Public </label> <label class="check"> <input type="radio" class="radio" name="visibility" value="team"> Team only </label> <label class="check"> <input type="radio" class="radio" name="visibility" value="private"> Private </label></fieldset><template> <fieldset class="fieldset"> <legend class="fieldset-legend">Visibility</legend> <label class="check"> <input type="radio" class="radio" name="visibility" value="public" checked> Public </label> <label class="check"> <input type="radio" class="radio" name="visibility" value="team"> Team only </label> <label class="check"> <input type="radio" class="radio" name="visibility" value="private"> Private </label> </fieldset></template>#라디오 버튼 그룹
같은 name 값을 가진 라디오 버튼은 하나의 그룹을 이룹니다. 하나를 선택하면 나머지 선택이 해제되며, 방향키로 그룹 안에서 선택을 옮길 수 있습니다. 그룹을 fieldset에 넣고 legend에 선택지가 답하는 질문을 적으세요.
#가로 배치
짧은 선택지 몇 개는 나란히 배치할 수 있습니다. 각 레이블이 어느 원에 속하는지 분명하도록 선택지 사이 간격을 원과 레이블 사이 간격보다 넓게 두세요.
가로 배치
<fieldset class="fieldset"> <legend class="fieldset-legend">Billing period</legend> <div class="flex flex-wrap gap-lg"> <label class="check"><input type="radio" class="radio" name="period" checked> Monthly</label> <label class="check"><input type="radio" class="radio" name="period"> Yearly</label> </div></fieldset><fieldset className="fieldset"> <legend className="fieldset-legend">Billing period</legend> <div className="flex flex-wrap gap-lg"> <label className="check"> <input type="radio" className="radio" name="period" defaultChecked /> Monthly </label> <label className="check"><input type="radio" className="radio" name="period" /> Yearly</label> </div></fieldset><fieldset class="fieldset"> <legend class="fieldset-legend">Billing period</legend> <div class="flex flex-wrap gap-lg"> <label class="check"><input type="radio" class="radio" name="period" checked> Monthly</label> <label class="check"><input type="radio" class="radio" name="period"> Yearly</label> </div></fieldset><template> <fieldset class="fieldset"> <legend class="fieldset-legend">Billing period</legend> <div class="flex flex-wrap gap-lg"> <label class="check"><input type="radio" class="radio" name="period" checked> Monthly</label> <label class="check"><input type="radio" class="radio" name="period"> Yearly</label> </div> </fieldset></template>#비활성화
라디오 버튼을 비활성화하면 원이 흐려지고 레이블은 비활성 상태의 글자색으로 바뀝니다. 선택지 하나만 비활성화하거나 fieldset을 비활성화해 그룹 전체를 비활성화할 수 있습니다.
비활성화
<fieldset class="fieldset"> <legend class="fieldset-legend">Region</legend> <label class="check"><input type="radio" class="radio" name="region" checked> Tokyo</label> <label class="check"><input type="radio" class="radio" name="region"> Frankfurt</label> <label class="check"> <input type="radio" class="radio" name="region" disabled> Virginia, at capacity </label></fieldset><fieldset className="fieldset"> <legend className="fieldset-legend">Region</legend> <label className="check"> <input type="radio" className="radio" name="region" defaultChecked /> Tokyo </label> <label className="check"><input type="radio" className="radio" name="region" /> Frankfurt</label> <label className="check"> <input type="radio" className="radio" name="region" disabled /> Virginia, at capacity </label></fieldset><fieldset class="fieldset"> <legend class="fieldset-legend">Region</legend> <label class="check"><input type="radio" class="radio" name="region" checked> Tokyo</label> <label class="check"><input type="radio" class="radio" name="region"> Frankfurt</label> <label class="check"> <input type="radio" class="radio" name="region" disabled> Virginia, at capacity </label></fieldset><template> <fieldset class="fieldset"> <legend class="fieldset-legend">Region</legend> <label class="check"><input type="radio" class="radio" name="region" checked> Tokyo</label> <label class="check"><input type="radio" class="radio" name="region"> Frankfurt</label> <label class="check"> <input type="radio" class="radio" name="region" disabled> Virginia, at capacity </label> </fieldset></template>#컨트롤 선택
라디오 버튼은 모든 선택지를 한꺼번에 보여 주며, 선택지마다 한 행을 차지합니다. 하나를 고르는 데 다음과 같은 컨트롤도 사용할 수 있습니다.
- 보기 전환처럼 짧은 선택지 2~5개를 한 행에 배치할 때는 세그먼트 컨트롤을 사용하세요.
- 선택지를 모두 표시하기 어렵거나 공간이 좁을 때는 셀렉트를 사용하세요.
- 선택지마다 제목과 설명 한 문장이 필요할 때는 선택 옵션를 사용하세요.
- 보기에 즉시 반영되는 필터에는 칩을 사용하세요.
#접근성
- 그룹의 모든 라디오 버튼에 같은
name값을 지정하세요. 이 값이 없으면 여러 라디오 버튼을 동시에 선택할 수 있고 방향키로 라디오 버튼 사이를 이동할 수 없습니다. - 탭으로 이동할 때 그룹에서 포커스가 멈추는 곳은 한 곳입니다. Tab 키를 누르면 선택된 라디오 버튼에 포커스가 가며, 선택된 항목이 없으면 첫 번째 라디오 버튼에 포커스가 갑니다. 그 위치에서 방향키로 이동할 수 있습니다.
- 적절한 기본값이 있다면 해당 선택지를 처음부터 선택해 두세요. 아무것도 선택되지 않은 상태에서 시작한 그룹은 사용자가 한 번 선택하고 나면 그 상태로 되돌릴 수 없습니다.
#클래스
| 클래스 | 설명 |
|---|---|
radio | 원형의 오목한 영역으로 표시하는 네이티브 type="radio" 입력 요소입니다. |