Segmented control
For looking at the same list through a different lens — picking one of two to four views.
Live preview
Source
<div class="dc-sg-wrap">
<div class="dc-sg" role="group" aria-label="주문 상태로 보기">
<input class="dc-sg__in" type="radio" name="dc-sg-state" id="dc-sg-all" checked>
<label class="dc-sg__lb" for="dc-sg-all">전체</label>
<input class="dc-sg__in" type="radio" name="dc-sg-state" id="dc-sg-doing">
<label class="dc-sg__lb" for="dc-sg-doing">진행중</label>
<input class="dc-sg__in" type="radio" name="dc-sg-state" id="dc-sg-done">
<label class="dc-sg__lb" for="dc-sg-done">완료</label>
</div>
</div>
.dc-sg-wrap {
padding: var(--dc-4);
background: var(--dc-bg);
font-family: var(--dc-font);
}
.dc-sg {
position: relative;
display: flex; gap: 3px;
padding: 3px;
border-radius: var(--dc-r-full);
background: var(--dc-sunken);
}
.dc-sg__in {
position: absolute;
width: 1px; height: 1px; margin: 0; opacity: 0;
pointer-events: none;
}
.dc-sg__lb {
flex: 1 1 0; min-width: 0;
display: grid; place-items: center;
min-height: 44px; padding: 0 var(--dc-2);
border-radius: var(--dc-r-full);
color: var(--dc-text-sub);
font-size: 14px; font-weight: 700; letter-spacing: -.01em;
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
cursor: pointer;
transition: background var(--dc-fast), color var(--dc-fast);
}
.dc-sg__in:checked + .dc-sg__lb {
background: var(--dc-surface); color: var(--dc-text);
box-shadow: var(--dc-sh-1);
}
.dc-sg__in:focus-visible + .dc-sg__lb {
outline: 2px solid var(--dc-brand); outline-offset: 2px;
}
.dc-sg--solid .dc-sg__in:checked + .dc-sg__lb {
background: var(--dc-brand); color: var(--dc-text-on);
}
.dc-sg--block { border-radius: var(--dc-r-md); }
.dc-sg--block .dc-sg__lb { border-radius: var(--dc-r-sm); }
How to use it
- Two to four segments; at five, switch to scrollable tabs or a select
- Use it to filter one list, not to swap whole screens — that is what tabs are for
- One segment is always selected; there is no empty state here
- Keep the labels a similar length — equal-width slots truncate only the long one
Watch out for
- Hidden radios must still move with the arrow keys; keep the line that forwards focus-visible to the label
- Never shrink the tappable segment below 44px tall
- Name the set with aria-label on the role="group" wrapper