탐색

v2.1.0
폼

척도

한 줄로 늘어선 숫자 중 양끝을 포함해 하나를 골라 답하는 컴포넌트입니다.

이 페이지의 내용

척도는 가능성, 만족도, 난이도처럼 정도를 묻는 질문에 한 줄로 늘어선 숫자 중 하나를 골라 답하는 컴포넌트입니다. 각 숫자는 네이티브 라디오 버튼을 감싸는 <label> 요소에 표시합니다. 따라서 방향키로 그룹 안에서 이동할 수 있고, 폼에는 선택값이 유지됩니다. 기본 상태에서 각 칸은 하나의 윤곽선으로 둘러싸인 평평한 표면이며, 선택한 칸은 진한 색으로 표시합니다.

척도

<div class="card w-full max-w(480)">  <fieldset class="fieldset">    <legend class="fieldset-legend">How likely are you to recommend Atlas to a colleague?</legend>    <div class="scale">      <label class="scale-option">        <input class="scale-input" type="radio" name="recommend" value="0">0      </label>      <label class="scale-option">        <input class="scale-input" type="radio" name="recommend" value="1">1      </label>      <label class="scale-option">        <input class="scale-input" type="radio" name="recommend" value="2">2      </label>      <label class="scale-option">        <input class="scale-input" type="radio" name="recommend" value="3">3      </label>      <label class="scale-option">        <input class="scale-input" type="radio" name="recommend" value="4">4      </label>      <label class="scale-option">        <input class="scale-input" type="radio" name="recommend" value="5">5      </label>      <label class="scale-option">        <input class="scale-input" type="radio" name="recommend" value="6">6      </label>      <label class="scale-option">        <input class="scale-input" type="radio" name="recommend" value="7">7      </label>      <label class="scale-option">        <input class="scale-input" type="radio" name="recommend" value="8" checked>8      </label>      <label class="scale-option">        <input class="scale-input" type="radio" name="recommend" value="9">9      </label>      <label class="scale-option">        <input class="scale-input" type="radio" name="recommend" value="10">10      </label>      <p class="scale-ends"><span>Not at all likely</span><span>Extremely likely</span></p>    </div>  </fieldset></div>
<div className="card w-full max-w(480)">  <fieldset className="fieldset">    <legend className="fieldset-legend">      How likely are you to recommend Atlas to a colleague?    </legend>    <div className="scale">      <label className="scale-option">        <input className="scale-input" type="radio" name="recommend" value="0" />0      </label>      <label className="scale-option">        <input className="scale-input" type="radio" name="recommend" value="1" />1      </label>      <label className="scale-option">        <input className="scale-input" type="radio" name="recommend" value="2" />2      </label>      <label className="scale-option">        <input className="scale-input" type="radio" name="recommend" value="3" />3      </label>      <label className="scale-option">        <input className="scale-input" type="radio" name="recommend" value="4" />4      </label>      <label className="scale-option">        <input className="scale-input" type="radio" name="recommend" value="5" />5      </label>      <label className="scale-option">        <input className="scale-input" type="radio" name="recommend" value="6" />6      </label>      <label className="scale-option">        <input className="scale-input" type="radio" name="recommend" value="7" />7      </label>      <label className="scale-option">        <input className="scale-input" type="radio" name="recommend" value="8" defaultChecked />8      </label>      <label className="scale-option">        <input className="scale-input" type="radio" name="recommend" value="9" />9      </label>      <label className="scale-option">        <input className="scale-input" type="radio" name="recommend" value="10" />10      </label>      <p className="scale-ends"><span>Not at all likely</span><span>Extremely likely</span></p>    </div>  </fieldset></div>
<div class="card w-full max-w(480)">  <fieldset class="fieldset">    <legend class="fieldset-legend">How likely are you to recommend Atlas to a colleague?</legend>    <div class="scale">      <label class="scale-option">        <input class="scale-input" type="radio" name="recommend" value="0">0      </label>      <label class="scale-option">        <input class="scale-input" type="radio" name="recommend" value="1">1      </label>      <label class="scale-option">        <input class="scale-input" type="radio" name="recommend" value="2">2      </label>      <label class="scale-option">        <input class="scale-input" type="radio" name="recommend" value="3">3      </label>      <label class="scale-option">        <input class="scale-input" type="radio" name="recommend" value="4">4      </label>      <label class="scale-option">        <input class="scale-input" type="radio" name="recommend" value="5">5      </label>      <label class="scale-option">        <input class="scale-input" type="radio" name="recommend" value="6">6      </label>      <label class="scale-option">        <input class="scale-input" type="radio" name="recommend" value="7">7      </label>      <label class="scale-option">        <input class="scale-input" type="radio" name="recommend" value="8" checked>8      </label>      <label class="scale-option">        <input class="scale-input" type="radio" name="recommend" value="9">9      </label>      <label class="scale-option">        <input class="scale-input" type="radio" name="recommend" value="10">10      </label>      <p class="scale-ends"><span>Not at all likely</span><span>Extremely likely</span></p>    </div>  </fieldset></div>
<template>  <div class="card w-full max-w(480)">    <fieldset class="fieldset">      <legend class="fieldset-legend">How likely are you to recommend Atlas to a colleague?</legend>      <div class="scale">        <label class="scale-option">          <input class="scale-input" type="radio" name="recommend" value="0">0        </label>        <label class="scale-option">          <input class="scale-input" type="radio" name="recommend" value="1">1        </label>        <label class="scale-option">          <input class="scale-input" type="radio" name="recommend" value="2">2        </label>        <label class="scale-option">          <input class="scale-input" type="radio" name="recommend" value="3">3        </label>        <label class="scale-option">          <input class="scale-input" type="radio" name="recommend" value="4">4        </label>        <label class="scale-option">          <input class="scale-input" type="radio" name="recommend" value="5">5        </label>        <label class="scale-option">          <input class="scale-input" type="radio" name="recommend" value="6">6        </label>        <label class="scale-option">          <input class="scale-input" type="radio" name="recommend" value="7">7        </label>        <label class="scale-option">          <input class="scale-input" type="radio" name="recommend" value="8" checked>8        </label>        <label class="scale-option">          <input class="scale-input" type="radio" name="recommend" value="9">9        </label>        <label class="scale-option">          <input class="scale-input" type="radio" name="recommend" value="10">10        </label>        <p class="scale-ends"><span>Not at all likely</span><span>Extremely likely</span></p>      </div>    </fieldset>  </div></template>

#숫자 행과 양끝 레이블

칸은 4px 간격으로 행의 너비를 균등하게 나눠 씁니다. 숫자가 5개든 11개든 주어진 열을 가득 채우며, 각 칸의 높이는 버튼과 같은 38px이므로 주변 입력 필드와 높이가 맞습니다. 칸의 너비는 최소 28px이며, 한 행에 모두 들어갈 공간이 없으면 두 번째 줄로 넘어갑니다.

숫자만으로는 무엇을 뜻하는지 알 수 없습니다. scale-ends는 숫자 행 아래에서 양끝에 각각 레이블을 붙이는 줄입니다. 척도 안에서 마지막 칸 뒤에 배치합니다. 질문은 위 예시처럼 fieldset의 legend에 작성하거나, role="radiogroup"을 지정한 척도의 aria-label에 작성합니다.

5점 척도

<div class="scale w-full max-w(280)" role="radiogroup" aria-label="How hard was it to set up?">  <label class="scale-option">    <input class="scale-input" type="radio" name="effort" value="1">1  </label>  <label class="scale-option">    <input class="scale-input" type="radio" name="effort" value="2" checked>2  </label>  <label class="scale-option">    <input class="scale-input" type="radio" name="effort" value="3">3  </label>  <label class="scale-option">    <input class="scale-input" type="radio" name="effort" value="4">4  </label>  <label class="scale-option">    <input class="scale-input" type="radio" name="effort" value="5">5  </label>  <p class="scale-ends"><span>Very easy</span><span>Very hard</span></p></div>
<div className="scale w-full max-w(280)" role="radiogroup" aria-label="How hard was it to set up?">  <label className="scale-option">    <input className="scale-input" type="radio" name="effort" value="1" />1  </label>  <label className="scale-option">    <input className="scale-input" type="radio" name="effort" value="2" defaultChecked />2  </label>  <label className="scale-option">    <input className="scale-input" type="radio" name="effort" value="3" />3  </label>  <label className="scale-option">    <input className="scale-input" type="radio" name="effort" value="4" />4  </label>  <label className="scale-option">    <input className="scale-input" type="radio" name="effort" value="5" />5  </label>  <p className="scale-ends"><span>Very easy</span><span>Very hard</span></p></div>
<div class="scale w-full max-w(280)" role="radiogroup" aria-label="How hard was it to set up?">  <label class="scale-option">    <input class="scale-input" type="radio" name="effort" value="1">1  </label>  <label class="scale-option">    <input class="scale-input" type="radio" name="effort" value="2" checked>2  </label>  <label class="scale-option">    <input class="scale-input" type="radio" name="effort" value="3">3  </label>  <label class="scale-option">    <input class="scale-input" type="radio" name="effort" value="4">4  </label>  <label class="scale-option">    <input class="scale-input" type="radio" name="effort" value="5">5  </label>  <p class="scale-ends"><span>Very easy</span><span>Very hard</span></p></div>
<template>  <div class="scale w-full max-w(280)" role="radiogroup" aria-label="How hard was it to set up?">    <label class="scale-option">      <input class="scale-input" type="radio" name="effort" value="1">1    </label>    <label class="scale-option">      <input class="scale-input" type="radio" name="effort" value="2" checked>2    </label>    <label class="scale-option">      <input class="scale-input" type="radio" name="effort" value="3">3    </label>    <label class="scale-option">      <input class="scale-input" type="radio" name="effort" value="4">4    </label>    <label class="scale-option">      <input class="scale-input" type="radio" name="effort" value="5">5    </label>    <p class="scale-ends"><span>Very easy</span><span>Very hard</span></p>  </div></template>

#척도, 세그먼트 컨트롤, 별점, 슬라이더

척도는 양끝 사이의 값에 별도 이름을 붙이지 않고 정도를 나타냅니다. 이름이 붙은 옵션 2~5개로 보기를 전환하려면 세그먼트 컨트롤을 사용합니다. 몇 개의 별로 점수를 매길 때는 별점을 사용합니다. 넓은 범위에서 대략적인 값을 고를 때는 슬라이더를 사용합니다. 전체 응답 결과를 보여 주는 투표에는 설문 투표를 사용합니다.

#접근성

  • 라디오 버튼은 같은 name을 공유합니다. 브라우저는 그룹 전체를 Tab 키로 이동할 때 하나의 포커스 지점으로 처리하며, 그룹 안에서는 방향키로 이동할 수 있습니다.
  • 칸에 표시된 숫자가 라디오 버튼의 레이블입니다. 양끝의 레이블은 개별 칸에 연결되지 않으므로 질문에서 숫자의 의미를 설명합니다. 예를 들어 "가능성이 전혀 없으면 0, 매우 높으면 10을 기준으로 0부터 10까지의 숫자 중 하나를 골라 주세요"라고 안내할 수 있습니다.
  • 포커스 윤곽선은 칸 둘레에 표시됩니다. 터치 화면에서도 칸 높이는 38px로 유지되며, 터치 영역은 칸 위아래로 확장되어 전체 높이가 44px이 됩니다. 칸 11개를 편하게 누르려면 약 320px의 너비가 필요합니다.
  • 척도가 비활성화되어도 선택된 칸은 한층 옅은 색으로 표시되어 기존 응답을 확인할 수 있습니다.

#클래스

클래스설명
scalefieldset 또는 role="radiogroup"이 지정된 요소에서 셀이 행의 너비를 나눠 쓰며, 셀 사이의 간격은 4px입니다.
scale-option레이블에 숫자 하나를 표시합니다. 평평한 표면의 높이는 38px, 최소 너비는 28px입니다. 한 행에 셀이 모두 들어가지 않으면 다음 행으로 줄바꿈합니다. 누르면 셀이 오목하게 들어가고, 선택하면 셀이 전경색으로 채워집니다.
scale-input셀 안의 네이티브 라디오 버튼입니다. 셀 전체를 덮으며 화면에는 표시되지 않습니다
scale-ends행 아래 한 줄에 양쪽 끝을 각각 나타내는 이름을 표시합니다.

#사용자 지정 속성

속성기본값설명
--scale-gap.25rem셀 사이 간격

#소스

@master/ui/components/scale.css
/* * Scale: one answer on a row of numbers, from one end to the other. * How likely, how satisfied, how much: each number is a <label> around a native radio, so the group keeps the * arrow keys and the form keeps the value. The cells share the row's width. At rest a cell is a flat face on * one contour; the chosen one is a mark of ink, as a chosen day of a calendar is. * scale-ends is a line under the row that names its two ends, since a number alone says nothing. * Geometry: cells are 38px tall, as a button is, 4px apart, with a small control's corner. On a touch screen a * cell's target reaches 44px above and below it. */@layer components.ui {  .scale {    --scale-gap: .25rem;    display: flex;    flex-wrap: wrap;    gap: var(--scale-gap);    min-width: 0;    margin: 0;    padding: 0;    border: 0;  }  /* One number. */  .scale-option {    position: relative;    display: grid;    flex: 1 1 0;    place-items: center;    /* A cell is never narrower than 28px: in a row too narrow for them all, the cells wrap. */    min-width: 1.75rem;    height: 2.375rem;    border-radius: calc(var(--radius-control-sm) * var(--corner-scale));    corner-shape: var(--corner-shape);    background: var(--color-surface-raised);    color: var(--color-text-body);    box-shadow: var(--shadow-flat);    font: var(--font-weight-control) .84375rem/1 var(--font-family-sans);    font-feature-settings: inherit;    font-variant-numeric: tabular-nums;    cursor: pointer;    touch-action: manipulation;    user-select: none;    -webkit-user-select: none;    -webkit-tap-highlight-color: transparent;    transition: box-shadow var(--duration-quick) var(--easing-glide);    @media (hover: hover) {      &:hover:not(:has(:checked, :disabled)) {        color: var(--color-text-strong);        box-shadow: 0 0 0 .5px var(--color-line-mark);      }    }    /* Pressed: the cell sinks into a well before it turns to ink. */    &:active:not(:has(:checked, :disabled)) {      background: var(--color-surface-inset);      box-shadow: var(--shadow-pressed);      transition-duration: var(--duration-press);    }    /* Chosen: ink. The face swaps at once; only its shadow eases. */    &:has(.scale-input:checked) {      background: var(--color-surface-inverse);      color: var(--color-text-inverse);      box-shadow: var(--shadow-ink-mark);    }    &:has(.scale-input:focus-visible) {      @apply --focus-ring;    }    &:has(.scale-input:disabled) {      background: var(--color-surface-inset);      color: var(--color-text-disabled);      cursor: not-allowed;    }    &:has(.scale-input:checked:disabled) {      background: var(--color-text-disabled);      color: var(--color-surface-raised);      box-shadow: none;    }    /* Cells stand 4px apart, so on touch a target grows only above and below. */    @media (pointer: coarse) {      &::after {        @apply --touch-target-block;      }    }    @media (forced-colors: active) {      outline: 1px solid CanvasText;      outline-offset: -1px;      /* Kept out of forced colors, the chosen cell drops the theme's ink edge and shade along with its face. */      &:has(.scale-input:checked) {        background: Highlight;        color: HighlightText;        box-shadow: none;        forced-color-adjust: none;      }      /* A cell that cannot be chosen, chosen or not, is in the system's gray. */      &:has(.scale-input:disabled) {        outline-color: GrayText;        color: GrayText;      }      &:has(.scale-input:checked:disabled) {        background: GrayText;        color: Canvas;      }      /* The chosen cell is kept out of forced colors and is where the keys stand: its ring is given the system's color. */      &:has(.scale-input:focus-visible) {        outline: 2px solid Highlight;        outline-offset: 2px;      }    }  }  /* The native radio covers its cell and is not drawn: the cell is its face. */  .scale-input {    position: absolute;    inset: 0;    width: 100%;    height: 100%;    margin: 0;    padding: 0;    border: 0;    opacity: 0;    appearance: none;    cursor: inherit;  }  /* What the two ends mean: a line under the row, one name at each end. */  .scale-ends {    display: flex;    flex: none;    justify-content: space-between;    gap: 1rem;    order: 1;    width: 100%;    margin: .125rem 0 0;    color: var(--color-text-muted);    font-size: .78125rem;    line-height: 1.25rem;  }}