탐색

v2.1.0
폼

다이얼

원을 따라 손잡이를 돌려 값을 정합니다. 노브처럼 조절하는 레벨, 각도, 방향 등에 씁니다.

이 페이지의 내용

다이얼은 원을 따라 손잡이를 돌려 값을 정합니다. 노브처럼 돌려 정하는 레벨, 각도, 방향에 사용합니다. 다이얼은 게이지의 입력용 짝입니다. 채움 색과 같은 잉크를 옅게 깐 둥근 트랙이 시작 지점부터 값까지 잉크로 채워지고, 그 위 값의 각도에 슬라이더와 같은 진주빛 손잡이가 놓입니다. 가운데에는 값이 자릿수마다 폭이 같은 숫자로 표시됩니다. 이에 해당하는 네이티브 요소가 없으므로 다이얼은 role="slider"가 있는 요소이며, dial 동작이 다이얼을 돌립니다.

다이얼

<div class="dial" role="slider" tabindex="0" aria-label="Volume" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="--dial-value: 40">  <span class="dial-value">40%</span>  <span class="dial-thumb"></span></div><script type="module">  import { attach } from '@master/ui/behaviors'  attach()</script>
import { useEffect, useRef } from 'react'import { attach } from '@master/ui/behaviors'export function Example() {  const root = useRef<HTMLDivElement>(null)  useEffect(() => attach(root.current!), [])  return (    <div ref={root} className="dial" role="slider" tabIndex={0} aria-label="Volume" aria-valuenow={40} aria-valuemin={0} aria-valuemax={100} style={{ '--dial-value': '40' } as React.CSSProperties}>      <span className="dial-value">40%</span>      <span className="dial-thumb"></span>    </div>  )}
<script>  import { attach } from '@master/ui/behaviors'</script><div class="dial" role="slider" tabindex="0" aria-label="Volume" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="--dial-value: 40" {@attach attach}>  <span class="dial-value">40%</span>  <span class="dial-thumb"></span></div>
<script setup>import { onMounted, onUnmounted, ref } from 'vue'import { attach } from '@master/ui/behaviors'const root = ref(null)let detachonMounted(() => { detach = attach(root.value) })onUnmounted(() => detach?.())</script><template>  <div ref="root" class="dial" role="slider" tabindex="0" aria-label="Volume" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" style="--dial-value: 40">    <span class="dial-value">40%</span>    <span class="dial-thumb"></span>  </div></template>
손잡이를 원을 따라 드래그하거나, 트랙의 아무 곳이나 누르거나, 다이얼에 포커스를 두고 방향키, Page Up, Page Down, Home, End 키를 사용해 보세요.

기본적으로 다이얼은 노브입니다. 아래쪽이 트인 270도 범위로, 왼쪽 아래의 최솟값부터 오른쪽 아래의 최댓값까지 이어집니다. 트랙을 누르면 값이 그 위치로 이동하고, 손잡이를 누르면 현재 위치에서 손잡이를 잡으므로 값이 튀지 않고 돌아갑니다. 드래그가 한쪽 끝을 넘어가면 포인터가 돌아올 때까지 값은 아래쪽 틈을 지나는 동안에도 그 끝에 머무릅니다.

#각도

dial-full은 위쪽에서 시작하는 원 전체로, aria-valuemin 0부터 aria-valuemax 360까지의 각도나 방향에 사용합니다. 최댓값을 넘어가면 키로 조작하든 위쪽을 지나 드래그하든 다시 최솟값으로 돌아오며, 360은 같은 위치인 0으로 작성됩니다. End 키는 그보다 한 단계 앞에서 멈춥니다.

각도

<div class="dial dial-full" role="slider" tabindex="0" aria-label="Gradient angle" aria-valuenow="135" aria-valuemin="0" aria-valuemax="360" aria-valuetext="135°" style="--dial-value: 135; --dial-max: 360">  <span class="dial-value">135°</span>  <span class="dial-thumb"></span></div><script type="module">  import { attach } from '@master/ui/behaviors'  attach()</script>
import { useEffect, useRef } from 'react'import { attach } from '@master/ui/behaviors'export function Example() {  const root = useRef<HTMLDivElement>(null)  useEffect(() => attach(root.current!), [])  return (    <div ref={root} className="dial dial-full" role="slider" tabIndex={0} aria-label="Gradient angle" aria-valuenow={135} aria-valuemin={0} aria-valuemax={360} aria-valuetext="135°" style={{ '--dial-value': '135', '--dial-max': '360' } as React.CSSProperties}>      <span className="dial-value">135°</span>      <span className="dial-thumb"></span>    </div>  )}
<script>  import { attach } from '@master/ui/behaviors'</script><div class="dial dial-full" role="slider" tabindex="0" aria-label="Gradient angle" aria-valuenow="135" aria-valuemin="0" aria-valuemax="360" aria-valuetext="135°" style="--dial-value: 135; --dial-max: 360" {@attach attach}>  <span class="dial-value">135°</span>  <span class="dial-thumb"></span></div>
<script setup>import { onMounted, onUnmounted, ref } from 'vue'import { attach } from '@master/ui/behaviors'const root = ref(null)let detachonMounted(() => { detach = attach(root.value) })onUnmounted(() => detach?.())</script><template>  <div ref="root" class="dial dial-full" role="slider" tabindex="0" aria-label="Gradient angle" aria-valuenow="135" aria-valuemin="0" aria-valuemax="360" aria-valuetext="135°" style="--dial-value: 135; --dial-max: 360">    <span class="dial-value">135°</span>    <span class="dial-thumb"></span>  </div></template>
위쪽을 지나도록 돌리거나, 359에서 위쪽 방향키를 눌러 보세요.

레이블과 aria-valuetext는 숫자 주위에 작성된 문구를 그대로 유지하므로, 페이지에 별도 스크립트를 작성하지 않아도 "135°"가 "136°"로 바뀝니다. 다른 형태의 문구가 필요하면 동작에서 보듯이 동작에 text 함수를 전달하세요.

#눈금과 표시

dial-ticks 요소는 회전 범위를 --dial-ticks개의 같은 간격으로 나누어, 손잡이가 지나는 경로 바로 바깥에 가는 선으로 그립니다. 노브에서는 양 끝에 하나씩 있으므로 눈금이 간격 수보다 하나 많고, 원 전체에서는 간격 수와 같습니다. dial-mark는 테두리에 놓이는 짧은 단어나 숫자로, 스타일시트가 --dial-at에 지정된 값의 위치에 배치합니다. 둘 다 다이얼 상자 안쪽의 테두리 공간을 차지하므로 트랙은 그만큼 작아집니다. 표시가 있는 다이얼에는 큰 크기를 사용하세요.

눈금과 표시

<div class="dial dial-lg" role="slider" tabindex="0" aria-label="Volume" aria-valuenow="6" aria-valuemin="0" aria-valuemax="10" style="--dial-value: 6; --dial-max: 10">  <span class="dial-ticks" style="--dial-ticks: 10"></span>  <span class="dial-mark" style="--dial-at: 0">0</span>  <span class="dial-mark" style="--dial-at: 5">5</span>  <span class="dial-mark" style="--dial-at: 10">10</span>  <span class="dial-value">6</span>  <span class="dial-thumb"></span></div><div class="dial dial-lg dial-full" role="slider" tabindex="0" aria-label="Wind direction" aria-valuenow="225" aria-valuemin="0" aria-valuemax="360" aria-valuetext="225°" style="--dial-value: 225; --dial-max: 360">  <span class="dial-ticks" style="--dial-ticks: 12"></span>  <span class="dial-mark" style="--dial-at: 0">N</span>  <span class="dial-mark" style="--dial-at: 90">E</span>  <span class="dial-mark" style="--dial-at: 180">S</span>  <span class="dial-mark" style="--dial-at: 270">W</span>  <span class="dial-value">225°</span>  <span class="dial-thumb"></span></div><script type="module">  import { attach } from '@master/ui/behaviors'  attach()</script>
import { useEffect, useRef } from 'react'import { attach } from '@master/ui/behaviors'export function Example() {  const root = useRef<HTMLDivElement>(null)  useEffect(() => attach(root.current!), [])  return (    <div ref={root}>      <div className="dial dial-lg" role="slider" tabIndex={0} aria-label="Volume" aria-valuenow={6} aria-valuemin={0} aria-valuemax={10} style={{ '--dial-value': '6', '--dial-max': '10' } as React.CSSProperties}>        <span className="dial-ticks" style={{ '--dial-ticks': '10' } as React.CSSProperties}></span>        <span className="dial-mark" style={{ '--dial-at': '0' } as React.CSSProperties}>0</span>        <span className="dial-mark" style={{ '--dial-at': '5' } as React.CSSProperties}>5</span>        <span className="dial-mark" style={{ '--dial-at': '10' } as React.CSSProperties}>10</span>        <span className="dial-value">6</span>        <span className="dial-thumb"></span>      </div>      <div className="dial dial-lg dial-full" role="slider" tabIndex={0} aria-label="Wind direction" aria-valuenow={225} aria-valuemin={0} aria-valuemax={360} aria-valuetext="225°" style={{ '--dial-value': '225', '--dial-max': '360' } as React.CSSProperties}>        <span className="dial-ticks" style={{ '--dial-ticks': '12' } as React.CSSProperties}></span>        <span className="dial-mark" style={{ '--dial-at': '0' } as React.CSSProperties}>N</span>        <span className="dial-mark" style={{ '--dial-at': '90' } as React.CSSProperties}>E</span>        <span className="dial-mark" style={{ '--dial-at': '180' } as React.CSSProperties}>S</span>        <span className="dial-mark" style={{ '--dial-at': '270' } as React.CSSProperties}>W</span>        <span className="dial-value">225°</span>        <span className="dial-thumb"></span>      </div>    </div>  )}
<script>  import { attach } from '@master/ui/behaviors'</script><div {@attach attach}>  <div class="dial dial-lg" role="slider" tabindex="0" aria-label="Volume" aria-valuenow="6" aria-valuemin="0" aria-valuemax="10" style="--dial-value: 6; --dial-max: 10">    <span class="dial-ticks" style="--dial-ticks: 10"></span>    <span class="dial-mark" style="--dial-at: 0">0</span>    <span class="dial-mark" style="--dial-at: 5">5</span>    <span class="dial-mark" style="--dial-at: 10">10</span>    <span class="dial-value">6</span>    <span class="dial-thumb"></span>  </div>  <div class="dial dial-lg dial-full" role="slider" tabindex="0" aria-label="Wind direction" aria-valuenow="225" aria-valuemin="0" aria-valuemax="360" aria-valuetext="225°" style="--dial-value: 225; --dial-max: 360">    <span class="dial-ticks" style="--dial-ticks: 12"></span>    <span class="dial-mark" style="--dial-at: 0">N</span>    <span class="dial-mark" style="--dial-at: 90">E</span>    <span class="dial-mark" style="--dial-at: 180">S</span>    <span class="dial-mark" style="--dial-at: 270">W</span>    <span class="dial-value">225°</span>    <span class="dial-thumb"></span>  </div></div>
<script setup>import { onMounted, onUnmounted, ref } from 'vue'import { attach } from '@master/ui/behaviors'const root = ref(null)let detachonMounted(() => { detach = attach(root.value) })onUnmounted(() => detach?.())</script><template>  <div ref="root">    <div class="dial dial-lg" role="slider" tabindex="0" aria-label="Volume" aria-valuenow="6" aria-valuemin="0" aria-valuemax="10" style="--dial-value: 6; --dial-max: 10">      <span class="dial-ticks" style="--dial-ticks: 10"></span>      <span class="dial-mark" style="--dial-at: 0">0</span>      <span class="dial-mark" style="--dial-at: 5">5</span>      <span class="dial-mark" style="--dial-at: 10">10</span>      <span class="dial-value">6</span>      <span class="dial-thumb"></span>    </div>    <div class="dial dial-lg dial-full" role="slider" tabindex="0" aria-label="Wind direction" aria-valuenow="225" aria-valuemin="0" aria-valuemax="360" aria-valuetext="225°" style="--dial-value: 225; --dial-max: 360">      <span class="dial-ticks" style="--dial-ticks: 12"></span>      <span class="dial-mark" style="--dial-at: 0">N</span>      <span class="dial-mark" style="--dial-at: 90">E</span>      <span class="dial-mark" style="--dial-at: 180">S</span>      <span class="dial-mark" style="--dial-at: 270">W</span>      <span class="dial-value">225°</span>      <span class="dial-thumb"></span>    </div>  </div></template>

눈금과 표시는 그림일 뿐입니다. role="slider" 안에서는 안내되지 않으므로, 표시가 전달하는 모든 내용을 값과 그 문구로 전달해야 합니다.

#크기

다이얼의 지름은 120px입니다. dial-sm은 88px로 컨트롤이 나란히 놓인 행에 사용하고, dial-lg는 160px로 패널의 중심이 되는 하나의 값이나 표시가 있는 다이얼에 사용합니다. 트랙은 너비의 1/20이며 숫자는 트랙에 맞춰 크기가 바뀝니다. 손잡이는 포인터 종류와 관계없이 슬라이더와 같은 18px 크기를 유지합니다.

크기

<div class="dial dial-sm" role="slider" tabindex="0" aria-label="Treble" aria-valuenow="30" aria-valuemin="0" aria-valuemax="100" style="--dial-value: 30">  <span class="dial-value">30</span>  <span class="dial-thumb"></span></div><div class="dial" role="slider" tabindex="0" aria-label="Mid" aria-valuenow="55" aria-valuemin="0" aria-valuemax="100" style="--dial-value: 55">  <span class="dial-value">55</span>  <span class="dial-thumb"></span></div><div class="dial dial-lg" role="slider" tabindex="0" aria-label="Bass" aria-valuenow="70" aria-valuemin="0" aria-valuemax="100" style="--dial-value: 70">  <span class="dial-value">70</span>  <span class="dial-thumb"></span></div><script type="module">  import { attach } from '@master/ui/behaviors'  attach()</script>
import { useEffect, useRef } from 'react'import { attach } from '@master/ui/behaviors'export function Example() {  const root = useRef<HTMLDivElement>(null)  useEffect(() => attach(root.current!), [])  return (    <div ref={root}>      <div className="dial dial-sm" role="slider" tabIndex={0} aria-label="Treble" aria-valuenow={30} aria-valuemin={0} aria-valuemax={100} style={{ '--dial-value': '30' } as React.CSSProperties}>        <span className="dial-value">30</span>        <span className="dial-thumb"></span>      </div>      <div className="dial" role="slider" tabIndex={0} aria-label="Mid" aria-valuenow={55} aria-valuemin={0} aria-valuemax={100} style={{ '--dial-value': '55' } as React.CSSProperties}>        <span className="dial-value">55</span>        <span className="dial-thumb"></span>      </div>      <div className="dial dial-lg" role="slider" tabIndex={0} aria-label="Bass" aria-valuenow={70} aria-valuemin={0} aria-valuemax={100} style={{ '--dial-value': '70' } as React.CSSProperties}>        <span className="dial-value">70</span>        <span className="dial-thumb"></span>      </div>    </div>  )}
<script>  import { attach } from '@master/ui/behaviors'</script><div {@attach attach}>  <div class="dial dial-sm" role="slider" tabindex="0" aria-label="Treble" aria-valuenow="30" aria-valuemin="0" aria-valuemax="100" style="--dial-value: 30">    <span class="dial-value">30</span>    <span class="dial-thumb"></span>  </div>  <div class="dial" role="slider" tabindex="0" aria-label="Mid" aria-valuenow="55" aria-valuemin="0" aria-valuemax="100" style="--dial-value: 55">    <span class="dial-value">55</span>    <span class="dial-thumb"></span>  </div>  <div class="dial dial-lg" role="slider" tabindex="0" aria-label="Bass" aria-valuenow="70" aria-valuemin="0" aria-valuemax="100" style="--dial-value: 70">    <span class="dial-value">70</span>    <span class="dial-thumb"></span>  </div></div>
<script setup>import { onMounted, onUnmounted, ref } from 'vue'import { attach } from '@master/ui/behaviors'const root = ref(null)let detachonMounted(() => { detach = attach(root.value) })onUnmounted(() => detach?.())</script><template>  <div ref="root">    <div class="dial dial-sm" role="slider" tabindex="0" aria-label="Treble" aria-valuenow="30" aria-valuemin="0" aria-valuemax="100" style="--dial-value: 30">      <span class="dial-value">30</span>      <span class="dial-thumb"></span>    </div>    <div class="dial" role="slider" tabindex="0" aria-label="Mid" aria-valuenow="55" aria-valuemin="0" aria-valuemax="100" style="--dial-value: 55">      <span class="dial-value">55</span>      <span class="dial-thumb"></span>    </div>    <div class="dial dial-lg" role="slider" tabindex="0" aria-label="Bass" aria-valuenow="70" aria-valuemin="0" aria-valuemax="100" style="--dial-value: 70">      <span class="dial-value">70</span>      <span class="dial-thumb"></span>    </div>  </div></template>

#폼에서 사용하기

role="slider"는 폼 컨트롤이 아니므로 다이얼은 숨겨진 입력 요소를 담습니다. 동작은 값이 바뀔 때마다 다이얼 안의 첫 번째 <input type="hidden">에 값을 작성하며, 폼은 그 입력 요소의 name으로 값을 제출합니다. 다이얼의 input과 change 이벤트는 네이티브 컨트롤처럼 폼까지 버블링됩니다. 폼을 초기화해도 숨겨진 입력 요소에는 영향이 없으므로 다이얼은 그대로 있습니다. 초기화할 때 다이얼도 움직여야 한다면 페이지에서 값을 다시 설정하세요.

폼에서 사용하기

<form class="flex flex-col items-center gap-sm">  <span class="text-sm fg-text-strong" id="heating-label">Heating</span>  <div class="dial" role="slider" tabindex="0" aria-labelledby="heating-label" aria-valuenow="21" aria-valuemin="16" aria-valuemax="30" style="--dial-value: 21; --dial-min: 16; --dial-max: 30">    <span class="dial-value">21°</span>    <span class="dial-thumb"></span>    <input type="hidden" name="temperature" value="21">  </div>  <span class="text-xs fg-text-muted">16° to 30°</span></form><script type="module">  import { attach } from '@master/ui/behaviors'  attach()</script>
import { useEffect, useRef } from 'react'import { attach } from '@master/ui/behaviors'export function Example() {  const root = useRef<HTMLFormElement>(null)  useEffect(() => attach(root.current!), [])  return (    <form ref={root} className="flex flex-col items-center gap-sm">      <span className="text-sm fg-text-strong" id="heating-label">Heating</span>      <div className="dial" role="slider" tabIndex={0} aria-labelledby="heating-label" aria-valuenow={21} aria-valuemin={16} aria-valuemax={30} style={{ '--dial-value': '21', '--dial-min': '16', '--dial-max': '30' } as React.CSSProperties}>        <span className="dial-value">21°</span>        <span className="dial-thumb"></span>        <input type="hidden" name="temperature" value="21" />      </div>      <span className="text-xs fg-text-muted">16° to 30°</span>    </form>  )}
<script>  import { attach } from '@master/ui/behaviors'</script><form class="flex flex-col items-center gap-sm" {@attach attach}>  <span class="text-sm fg-text-strong" id="heating-label">Heating</span>  <div class="dial" role="slider" tabindex="0" aria-labelledby="heating-label" aria-valuenow="21" aria-valuemin="16" aria-valuemax="30" style="--dial-value: 21; --dial-min: 16; --dial-max: 30">    <span class="dial-value">21°</span>    <span class="dial-thumb"></span>    <input type="hidden" name="temperature" value="21">  </div>  <span class="text-xs fg-text-muted">16° to 30°</span></form>
<script setup>import { onMounted, onUnmounted, ref } from 'vue'import { attach } from '@master/ui/behaviors'const root = ref(null)let detachonMounted(() => { detach = attach(root.value) })onUnmounted(() => detach?.())</script><template>  <form ref="root" class="flex flex-col items-center gap-sm">    <span class="text-sm fg-text-strong" id="heating-label">Heating</span>    <div class="dial" role="slider" tabindex="0" aria-labelledby="heating-label" aria-valuenow="21" aria-valuemin="16" aria-valuemax="30" style="--dial-value: 21; --dial-min: 16; --dial-max: 30">      <span class="dial-value">21°</span>      <span class="dial-thumb"></span>      <input type="hidden" name="temperature" value="21">    </div>    <span class="text-xs fg-text-muted">16° to 30°</span>  </form></template>

화면에 보이는 레이블은 별도의 요소로 두고 aria-labelledby로 가리킵니다. <label>은 폼 컨트롤에만 이름을 붙이기 때문입니다. 숫자만으로 범위가 분명하지 않다면 다이얼 옆에 범위를 문구로 표시하세요.

#비활성화

aria-disabled="true"를 설정하면 다이얼이 흐려지고 키, 포인터, 휠 입력을 모두 받지 않습니다. tabindex="-1"로 탭 순서에서 제외하고, 폼이 값을 제출하지 않도록 숨겨진 입력 요소에도 disabled를 설정하세요.

비활성화

<div class="dial" role="slider" tabindex="-1" aria-label="Volume" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" aria-disabled="true" style="--dial-value: 40">  <span class="dial-value">40%</span>  <span class="dial-thumb"></span>  <input type="hidden" name="volume" value="40" disabled></div><script type="module">  import { attach } from '@master/ui/behaviors'  attach()</script>
import { useEffect, useRef } from 'react'import { attach } from '@master/ui/behaviors'export function Example() {  const root = useRef<HTMLDivElement>(null)  useEffect(() => attach(root.current!), [])  return (    <div ref={root} className="dial" role="slider" tabIndex={-1} aria-label="Volume" aria-valuenow={40} aria-valuemin={0} aria-valuemax={100} aria-disabled="true" style={{ '--dial-value': '40' } as React.CSSProperties}>      <span className="dial-value">40%</span>      <span className="dial-thumb"></span>      <input type="hidden" name="volume" value="40" disabled />    </div>  )}
<script>  import { attach } from '@master/ui/behaviors'</script><div class="dial" role="slider" tabindex="-1" aria-label="Volume" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" aria-disabled="true" style="--dial-value: 40" {@attach attach}>  <span class="dial-value">40%</span>  <span class="dial-thumb"></span>  <input type="hidden" name="volume" value="40" disabled></div>
<script setup>import { onMounted, onUnmounted, ref } from 'vue'import { attach } from '@master/ui/behaviors'const root = ref(null)let detachonMounted(() => { detach = attach(root.value) })onUnmounted(() => detach?.())</script><template>  <div ref="root" class="dial" role="slider" tabindex="-1" aria-label="Volume" aria-valuenow="40" aria-valuemin="0" aria-valuemax="100" aria-disabled="true" style="--dial-value: 40">    <span class="dial-value">40%</span>    <span class="dial-thumb"></span>    <input type="hidden" name="volume" value="40" disabled>  </div></template>

#회전 방향

어떤 쓰기 방향에서든 시계 방향이 값을 늘리는 방향입니다. 다이얼은 시계나 기기의 노브처럼 돌아가며, 이런 것들은 오른쪽에서 왼쪽으로 쓰는 언어에서도 좌우가 반전되지 않습니다. 따라서 다이얼도 반전되지 않으며, 방향키의 의미도 바뀌지 않습니다. →와 ↑ 키는 항상 값을 올립니다. 시선이 처음 닿는 다이얼의 위쪽에서는 시계 방향이 오른쪽이며, 그 위치에서 값을 올리는 방향키도 오른쪽 방향키입니다.

#동작

dial은 dial 클래스가 있는 루트 요소를 받아, 연결한 동작을 해제하는 함수를 반환합니다. 이 함수에는 숫자인 value가 있습니다. 외부에서 다이얼을 돌리려면 이 값을 설정하세요. 이때는 이벤트가 발생하지 않습니다.

app.js
import { dial } from '@master/ui/behaviors/dial.js'const root = document.querySelector('.dial')const turn = dial(root, { step: 15, text: (value) => `${value}°` })root.addEventListener('change', () => save(turn.value))
  • 값이 바뀔 때마다 루트의 aria-valuenow와 --dial-value, dial-value의 텍스트, aria-valuetext가 있거나 text가 지정된 경우 aria-valuetext, 그리고 숨겨진 입력 요소에 값을 작성합니다. 연결할 때도 같은 방식으로 첫 값을 작성하며, 속성을 읽지 못하는 브라우저를 위해 aria-valuemin과 aria-valuemax를 --dial-min과 --dial-max에 복사합니다.
  • 값은 aria-valuemin부터 단계 간격에 맞춰지며, aria-valuemin과 aria-valuemax 사이에 머무릅니다. 두 속성을 생략하면 0과 100입니다. 원 전체에서는 범위를 넘으면 반대쪽 끝으로 돌아옵니다.
  • 드래그. pointerdown에서 포인터를 캡처하고 다이얼 중심을 기준으로 포인터의 각도를 읽은 뒤, 스타일시트가 그릴 때 사용하는 것과 같은 --dial-start와 --dial-sweep으로 그 각도를 값으로 바꿉니다. 회전 범위가 360도인 다이얼은 dial-full 여부와 관계없이 끝에서 반대쪽 끝으로 돌아옵니다. 가운데의 숫자 근처를 눌러도 값은 바뀌지 않습니다.
  • 키. 방향키는 한 단계씩, Page Up과 Page Down 키는 더 큰 단계로 돌리며, Home과 End 키는 양 끝으로 이동합니다.
  • 휠은 요청한 경우에만, 그리고 Alt(Option) 키를 누르고 있는 동안에만 한 칸마다 다이얼을 한 단계씩 돌립니다. 페이지를 스크롤하다 다이얼 위를 지나가도 다이얼이 돌아가지는 않습니다.
  • 이벤트. 루트는 값이 바뀔 때마다 input을 발생시키고, 드래그가 끝나거나 키나 휠로 값을 돌렸을 때 change를 발생시킵니다. 두 이벤트 모두 버블링됩니다.
  • 비활성화. aria-disabled="true"가 설정된 다이얼은 키, 포인터, 휠 입력을 받지 않습니다.
옵션설정하는 내용
step방향키 한 번으로 값이 바뀌는 크기이자, 드래그한 값을 맞추는 간격입니다. 기본값은 1입니다
pagePage Up과 Page Down 키로 값이 바뀌는 크기입니다. 기본값은 범위의 1/10이며, 단계 간격에 맞춥니다
text값을 받아 문구를 반환하는 함수로, 반환값은 dial-value와 aria-valuetext에 작성됩니다
wheeltrue이면 Alt 키를 누르고 있는 동안 휠로 다이얼을 돌릴 수 있습니다. 기본값은 false입니다

attach()는 옵션을 전달하지 않습니다. 옵션이 필요한 다이얼은 attach()가 실행된 뒤 따로 연결하세요. 한 루트에서 다시 호출하면 첫 번째 호출을 대체하며, 이 미리보기의 스크립트도 그렇게 합니다. MasterUI는 미리보기가 불러오는 번들입니다. 프로젝트에서는 위와 같이 dial을 import하세요.

단계, 문구, 휠

<div class="dial dial-full" id="hue" role="slider" tabindex="0" aria-label="Hue" aria-valuenow="210" aria-valuemin="0" aria-valuemax="360" style="--dial-value: 210; --dial-max: 360">  <span class="dial-ticks" style="--dial-ticks: 24"></span>  <span class="dial-value">210°</span>  <span class="dial-thumb"></span></div><script>addEventListener('DOMContentLoaded', function () {MasterUI.dial(document.getElementById('hue'), {  step: 15,  wheel: true,  text: function (value) { return value + '°' }})})</script><script type="module">  import { attach } from '@master/ui/behaviors'  attach()</script>
import { useEffect, useRef } from 'react'import { attach, dial } from '@master/ui/behaviors'export function Example() {  const root = useRef<HTMLDivElement>(null)  useEffect(() => {    const detach = [      attach(root.current!),      dial(document.getElementById('hue')!, {        step: 15,        wheel: true,        text: function (value) { return value + '°' }      }),    ]    return () => detach.forEach(stop => stop())  }, [])  return (    <div ref={root} className="dial dial-full" id="hue" role="slider" tabIndex={0} aria-label="Hue" aria-valuenow={210} aria-valuemin={0} aria-valuemax={360} style={{ '--dial-value': '210', '--dial-max': '360' } as React.CSSProperties}>      <span className="dial-ticks" style={{ '--dial-ticks': '24' } as React.CSSProperties}></span>      <span className="dial-value">210°</span>      <span className="dial-thumb"></span>    </div>  )}
<script>  import { attach, dial } from '@master/ui/behaviors'  function mounted(root) {    const detach = [      attach(root),      dial(document.getElementById('hue'), {        step: 15,        wheel: true,        text: function (value) { return value + '°' }      }),    ]    return () => detach.forEach(stop => stop())  }</script><div class="dial dial-full" id="hue" role="slider" tabindex="0" aria-label="Hue" aria-valuenow="210" aria-valuemin="0" aria-valuemax="360" style="--dial-value: 210; --dial-max: 360" {@attach mounted}>  <span class="dial-ticks" style="--dial-ticks: 24"></span>  <span class="dial-value">210°</span>  <span class="dial-thumb"></span></div>
<script setup>import { onMounted, onUnmounted, ref } from 'vue'import { attach, dial } from '@master/ui/behaviors'const root = ref(null)let detach = []onMounted(() => {  detach = [    attach(root.value),    dial(document.getElementById('hue'), {      step: 15,      wheel: true,      text: function (value) { return value + '°' }    }),  ]})onUnmounted(() => detach.forEach(stop => stop()))</script><template>  <div ref="root" class="dial dial-full" id="hue" role="slider" tabindex="0" aria-label="Hue" aria-valuenow="210" aria-valuemin="0" aria-valuemax="360" style="--dial-value: 210; --dial-max: 360">    <span class="dial-ticks" style="--dial-ticks: 24"></span>    <span class="dial-value">210°</span>    <span class="dial-thumb"></span>  </div></template>
키를 한 번 누르거나 휠을 한 칸 굴릴 때마다 15도씩 바뀝니다. Alt(Option) 키를 누른 채 다이얼 위에서 스크롤하면 다이얼이 돌아갑니다.

동작을 연결하지 않으면 다이얼은 첫 값을 보여 줄 뿐 돌아가지 않습니다. 첫 값은 타입이 지정된 attr() 함수를 지원하는 브라우저에서는 속성에서, 그 밖의 브라우저에서는 --dial-value에서 가져옵니다.

#키보드

키동작
ArrowUp, ArrowRight값을 한 단계 올립니다. 쓰기 방향과 관계없이 시계 방향입니다. 완전한 원에서는 최댓값을 넘으면 최솟값으로 돌아옵니다.
ArrowDown, ArrowLeft값을 한 단계 내립니다. 반시계 방향입니다. 완전한 원에서는 최솟값보다 작아지면 최댓값으로 돌아옵니다.
PageUp, PageDown값을 더 큰 단계로 올리거나 내립니다. 페이지에서 따로 지정하지 않으면 범위의 10분의 1입니다.
Home, Endaria-valuemin 또는 aria-valuemax로 이동합니다. 완전한 원에서 End는 값이 처음으로 돌아오기 직전의 마지막 단계로 이동합니다.

#접근성

  • 루트는 포커스를 받을 수 있는 role="slider" 요소로, aria-label이나 aria-labelledby로 접근 가능한 이름을 가지며, aria-valuemin과 aria-valuemax 사이의 값을 aria-valuenow에 담습니다. 원을 따라 도는 슬라이더에는 의미 있는 방향이 없으므로 aria-orientation은 생략하세요.
  • 숫자만으로 이해하기 어렵고 단위나 문구가 필요하다면 aria-valuetext를 작성하세요(예: "135°", "21도", "큰 소리"). 동작이 다이얼 값에 맞춰 이 텍스트를 갱신합니다.
  • 숫자, 눈금, 표시 등 슬라이더 안의 모든 요소는 보조 기술에 대해 표현용으로만 취급됩니다. 드래그로 할 수 있는 모든 일은 키로도 할 수 있고, 트랙을 한 번 누르기만 해도 값이 설정되므로 드래그로 돌리는 것이 유일한 방법이 되는 일은 없습니다.
  • 슬라이더와 마찬가지로 포커스 링은 손잡이에 표시됩니다. 터치 화면에서는 다이얼 전체가 손가락 입력을 받아 페이지를 스크롤하는 대신 다이얼이 돌아가므로, 손잡이는 크기를 유지합니다.
  • 동작 줄이기 설정이 켜져 있으면 잡은 손잡이가 커지지 않습니다. 강제 색상 모드에서는 채움에 시스템 강조색을, 트랙과 눈금에 시스템 회색을, 손잡이에 버튼 텍스트 색을 사용합니다.

#React, Svelte, Vue

dial 컴포넌트는 동작을 연결하고, 외부에서 받은 값을 반영하며 바뀐 값을 외부로 전달합니다. 눈금과 표시는 데이터로부터 렌더링하며, name을 지정하면 숨겨진 입력 요소도 렌더링합니다. npx master-ui add dial 명령을 실행해 프로젝트에 복사하세요. 컴포넌트의 구성과 사용 방법은 React, Svelte, Vue에서 확인할 수 있습니다.

ui/dial.tsx
'use client'import { useRef, useState, type ComponentProps, type CSSProperties } from 'react'import { dial } from '@master/ui/behaviors/dial.js'import { useBehavior } from './use-behavior'/** A word or figure in the rim, at a value. Without a label it shows the value. */export interface DialMark {  value: number  label?: string}export interface DialProps extends Omit<ComponentProps<'div'>, 'defaultValue' | 'children' | 'onChange' | 'role' | 'ref'> {  /** The number. */  value?: number  defaultValue?: number  /** Called as the dial turns. */  onValueChange?: (value: number) => void  /** Called once a drag ends, or a key or the wheel turned it. */  onValueCommit?: (value: number) => void  /** The least and the greatest value: 0 and 100, or 0 and 360 round a full circle. */  min?: number  max?: number  /** How far an arrow key turns the value, and what a drag rounds it to. */  step?: number  /** How far PageUp and PageDown turn it; a tenth of the range by default. */  page?: number  /** The whole circle, for an angle that comes round again. */  full?: boolean  /** The name of the dial: what it sets. */  label: string  /** The words for a value, shown in the middle and given to assistive technology. */  text?: (value: number) => string  /** The name a form submits the value under. Without it there is no field. */  name?: string  /** How many equal steps to mark with ticks. */  ticks?: number  /** Words or figures in the rim, at their values. */  marks?: DialMark[]  /** Let a wheel turn the dial while Alt (Option) is held. */  wheel?: boolean  disabled?: boolean}/** A value set by turning a thumb around a circle. */export function Dial({ value, defaultValue, onValueChange, onValueCommit, min = 0, max, step = 1, page, full, label, text, name, ticks, marks, wheel = false, disabled, className, style, ...root }: DialProps) {  const greatest = max ?? (full ? 360 : 100)  const [first] = useState(value ?? defaultValue ?? min)  /** The value the dial holds: what `text` is written for, since a `text` given later is not for the first value. */  const held = useRef(first)  const ref = useBehavior(dial, { step, page, text, wheel }, {    value,    defaultValue,    onValueChange: (next: number) => { held.current = next; onValueChange?.(next) },    // The dial says change once a drag ends or a key or the wheel turned it, after the value has come out.    on: { change: (event) => { if (event.target === event.currentTarget) onValueCommit?.(Number((event.currentTarget as Element).getAttribute('aria-valuenow'))) } },  })  return (    <div className={['dial', full && 'dial-full', className].filter(Boolean).join(' ')} role="slider" tabIndex={disabled ? -1 : 0} aria-label={label} aria-valuenow={first} aria-valuemin={min} aria-valuemax={greatest} aria-valuetext={text?.(value ?? held.current)} aria-disabled={disabled || undefined} style={{ '--dial-value': first, '--dial-min': min, '--dial-max': greatest, ...style } as CSSProperties} ref={ref} {...root}>      {ticks !== undefined && <span className="dial-ticks" style={{ '--dial-ticks': ticks } as CSSProperties} />}      {marks?.map(mark => <span className="dial-mark" key={mark.value} style={{ '--dial-at': mark.value } as CSSProperties}>{mark.label ?? String(mark.value)}</span>)}      <span className="dial-value">{text ? text(value ?? held.current) : String(value ?? held.current)}</span>      <span className="dial-thumb" />      {/* React writes a field's value with every render, so it writes the value the dial holds. */}      {name !== undefined && <input type="hidden" name={name} value={value ?? held.current} disabled={disabled} />}    </div>  )}
ui/Dial.svelte
<script lang="ts" module>  import type { HTMLAttributes } from 'svelte/elements'  /** A word or figure in the rim, at a value. Without a label it shows the value. */  export interface DialMark {    value: number    label?: string  }  export interface DialProps extends Omit<HTMLAttributes<HTMLDivElement>, 'role' | 'children'> {    /** The number. Bind it, or leave it out: it starts at `min`. */    value?: number    /** Called as the dial turns. */    onValueChange?: (value: number) => void    /** Called once a drag ends, or a key or the wheel turned it. */    onValueCommit?: (value: number) => void    /** The least and the greatest value: 0 and 100, or 0 and 360 round a full circle. */    min?: number    max?: number    /** How far an arrow key turns the value, and what a drag rounds it to. */    step?: number    /** How far PageUp and PageDown turn it; a tenth of the range by default. */    page?: number    /** The whole circle, for an angle that comes round again. */    full?: boolean    /** The name of the dial: what it sets. */    label: string    /** The words for a value, shown in the middle and given to assistive technology. */    text?: (value: number) => string    /** The name a form submits the value under. Without it there is no field. */    name?: string    /** How many equal steps to mark with ticks. */    ticks?: number    /** Words or figures in the rim, at their values. */    marks?: DialMark[]    /** Let a wheel turn the dial while Alt (Option) is held. */    wheel?: boolean    disabled?: boolean  }</script><script lang="ts">  import { untrack } from 'svelte'  import { dial } from '@master/ui/behaviors/dial.js'  import { behavior } from './behavior.svelte.js'  let { value = $bindable(), onValueChange, onValueCommit, min = 0, max, step = 1, page, full, label, text, name, ticks, marks, wheel = false, disabled, class: className, ...root }: DialProps = $props()  const greatest = $derived(max ?? (full ? 360 : 100))  const first = untrack(() => value ?? min)  // Svelte writes a style again whenever its owner changes it, so it writes the value the behavior holds.  let held = $state(first)  // The behavior writes the words over the ones Svelte rendered, so words given another way are written by it:  // it attaches again, from the value it holds, each time `text` is another function.  let written = 0  const words = $derived.by(() => {    // Reading `text` is what makes this run again when it is another function.    void text    return ++written  })  const told = (root: HTMLElement, options?: { step?: number, page?: number, text?: (value: number) => string, wheel?: boolean, words?: number }) => dial(root, { step: options?.step, page: options?.page, text: options?.text, wheel: options?.wheel })  const attach = behavior(told, () => ({ step, page, text, wheel, words }), {    value: () => value,    change: (next) => { value = held = next; onValueChange?.(next) },    settled: (next) => { held = next },    // The dial says change once a drag ends or a key or the wheel turned it, after the value has come out.    on: { change: (event) => { if (event.target === event.currentTarget) onValueCommit?.(held) } },  })</script><!--  @component  A value set by turning a thumb around a circle.--><div class={['dial', full && 'dial-full', className]} role="slider" tabindex={disabled ? -1 : 0} aria-label={label} aria-valuenow={first} aria-valuemin={min} aria-valuemax={greatest} aria-valuetext={text?.(held)} aria-disabled={disabled || undefined} style:--dial-value={held} style:--dial-min={min} style:--dial-max={greatest} {@attach attach} {...root}>  {#if ticks !== undefined}<span class="dial-ticks" style:--dial-ticks={ticks}></span>{/if}  {#each marks ?? [] as mark (mark.value)}    <span class="dial-mark" style:--dial-at={mark.value}>{mark.label ?? String(mark.value)}</span>  {/each}  <span class="dial-value">{text ? text(held) : String(held)}</span>  <span class="dial-thumb"></span>  {#if name !== undefined}<input type="hidden" {name} value={first} {disabled} />{/if}</div>
ui/Dial.vue
<script lang="ts">/** A word or figure in the rim, at a value. Without a label it shows the value. */export interface DialMark {  value: number  label?: string}</script><script setup lang="ts">import { computed, useTemplateRef } from 'vue'import { dial } from '@master/ui/behaviors/dial.js'import { useBehavior } from './use-behavior'defineOptions({ inheritAttrs: false })const { min = 0, max, step = 1, page, full, text, wheel = false } = defineProps<{  /** The least and the greatest value: 0 and 100, or 0 and 360 round a full circle. */  min?: number  max?: number  /** How far an arrow key turns the value, and what a drag rounds it to. */  step?: number  /** How far PageUp and PageDown turn it; a tenth of the range by default. */  page?: number  /** The whole circle, for an angle that comes round again. */  full?: boolean  /** The name of the dial: what it sets. */  label: string  /** The words for a value, shown in the middle and given to assistive technology. */  text?: (value: number) => string  /** The name a form submits the value under. Without it there is no field. */  name?: string  /** How many equal steps to mark with ticks. */  ticks?: number  /** Words or figures in the rim, at their values. */  marks?: DialMark[]  /** Let a wheel turn the dial while Alt (Option) is held. */  wheel?: boolean  disabled?: boolean}>()/** The number: `v-model`. It changes as the dial turns. */const model = defineModel<number>()const emit = defineEmits<{  /** The number, once a drag ends, or a key or the wheel turned it. */  valueCommit: [value: number]}>()/* A value set by turning a thumb around a circle. */const greatest = computed(() => max ?? (full ? 360 : 100))const first = model.value ?? minconst root = useTemplateRef<HTMLDivElement>('root')const current = useBehavior(root, dial, () => ({ step, page, text, wheel }), model, {  // The dial says change once a drag ends or a key or the wheel turned it, after the model has heard it.  change: (event) => { if (event.target === root.value) emit('valueCommit', held()) },})// Vue writes a style again each time it renders, so it writes the value the behavior holds, not the first one.const held = () => current() ?? first</script><template>  <div class="dial" :class="{ 'dial-full': full }" role="slider" ref="root" :tabindex="disabled ? -1 : 0" :aria-label="label" :aria-valuenow="first" :aria-valuemin="min" :aria-valuemax="greatest" :aria-valuetext="text?.(held())" :aria-disabled="disabled || undefined" :style="{ '--dial-value': held(), '--dial-min': min, '--dial-max': greatest }" v-bind="$attrs">    <span v-if="ticks !== undefined" class="dial-ticks" :style="{ '--dial-ticks': ticks }" />    <span v-for="mark in marks" :key="mark.value" class="dial-mark" :style="{ '--dial-at': mark.value }">{{ mark.label ?? String(mark.value) }}</span>    <span class="dial-value">{{ text ? text(held()) : String(held()) }}</span>    <span class="dial-thumb" />    <!-- Vue writes a field's value with every render, so it too is the value the behavior holds. -->    <input v-if="name !== undefined" type="hidden" :name="name" :value="held()" :disabled="disabled">  </div></template>

#클래스

클래스설명
dial포커스할 수 있는 role="slider" 요소에 적용하는 지름 120px의 다이얼입니다. 접근 가능한 이름, aria-valuenow, aria-valuemin, aria-valuemax를 지정하세요. 시작점부터 값까지 전경색으로 채운 원형 트랙으로 표시합니다. 기본값은 아래쪽이 열린 270도 노브입니다.
dial-full위쪽에서 시작하는 완전한 원입니다. 각도에 사용하며, 최댓값을 넘으면 다시 처음으로 돌아옵니다.적용할 클래스는 dial입니다
dial-sm지름 88px의 다이얼입니다. 기본값은 120px입니다.적용할 클래스는 dial입니다
dial-lg160px 다이얼입니다. 기본값은 120px입니다.적용할 클래스는 dial입니다
dial-thumb트랙 위 값의 각도에 놓이는 진주빛 손잡이로, 빈 요소입니다. 포커스를 받으면 링이 표시되고, 손잡이를 눌러 돌리면 값이 튀지 않고 다이얼이 돌아갑니다.
dial-value다이얼 중앙에 값을 고정폭 숫자의 텍스트로 표시합니다. 값이 바뀔 때마다 동작이 기록합니다.
dial-ticks--dial-ticks개의 균등한 간격을 손잡이 경로 바로 바깥에 가는 선으로 그리는 빈 요소입니다.
dial-mark테두리에 놓이는 짧은 단어나 숫자로, --dial-at이 나타내는 값의 위치에 표시합니다.

#사용자 지정 속성

속성기본값설명
--dial-value값입니다. 타입을 지정하는 attr()을 지원하는 환경에서는 aria-valuenow에서 가져오며, 동작도 이 값을 기록합니다.
--dial-min0최솟값입니다. 타입을 지정하는 attr()을 지원하는 환경에서는 aria-valuemin에서 가져옵니다.
--dial-max100최댓값입니다. 타입을 지정하는 attr()을 지원하는 환경에서는 aria-valuemax에서 가져옵니다.
--dial-start225deg최솟값이 놓이는 위치로, 위쪽에서 시계 방향으로 잰 각도입니다. dial-full에서는 0deg입니다. 동작은 이 값을 읽어 포인터 위치를 값으로 변환합니다.
--dial-sweep270deg트랙이 시작점에서 시계 방향으로 이어지는 범위입니다. dial-full에서는 360deg이며, 이때 값이 한 바퀴 돌아 처음으로 돌아옵니다. 동작도 이 값을 읽습니다.
--dial-size7.5rem다이얼의 지름
--dial-trackcalc(var(--dial-size) / 20)트랙의 두께
--dial-thumb1.125rem손잡이의 지름입니다. 포인터 입력은 다이얼 전체가 받습니다.
--dial-colorvar(--color-surface-inverse)채움 색상입니다. 트랙에는 같은 색을 옅게 적용합니다.
--dial-ticks10눈금이 전체 회전 범위에 표시하는 균등한 간격의 수dial-ticks에 설정합니다
--dial-at0표시가 놓이는 값dial-mark에 설정합니다

#소스

@master/ui/components/dial.css
/* * Dial: a value set by turning a thumb around a circle, the input sibling of the gauge. * An element with role="slider" draws a round track in its fill's own ink, stepped back, fills it with ink from * where it starts to the value, and carries the slider's pearl thumb at the value's angle. The figure stands in * the middle in tabular figures. By default the dial is a knob: 270 degrees, open at the foot, from its least * value at the lower left to its greatest at the lower right. dial-full is the whole circle, from the top, for * an angle that comes round again. The script reads where it starts and how far it sweeps from this stylesheet. * Clockwise is more in every writing direction: a dial turns like a clock or a knob, so it is not mirrored. * Where the browser supports typed attr(), the dial reads aria-valuenow, aria-valuemin and aria-valuemax * itself; elsewhere it reads --dial-value, which the behavior writes with every change. The fill follows the * hand at once, with no easing: an input that lags behind the pointer feels broken. * A dial is 120px across (88 small, 160 large); its track is a twentieth of that, and its thumb is the slider's * 18px at every pointer: the whole dial takes the finger. Ticks and marks take a rim outside the thumb's path, so the dial keeps its size. */@property --dial-value {  syntax: '<number>';  inherits: true;  initial-value: 0;}@property --dial-start {  syntax: '<angle>';  inherits: true;  initial-value: 225deg;}@property --dial-sweep {  syntax: '<angle>';  inherits: true;  initial-value: 270deg;}@layer components.ui {  .dial {    --dial-size: 7.5rem;    --dial-track: calc(var(--dial-size) / 20);    --dial-thumb: 1.125rem;    --dial-color: var(--color-surface-inverse);    --dial-min: 0;    --dial-max: 100;    --dial-start: 225deg;    --dial-sweep: 270deg;    /* Room between the thumb's path and the edge, for ticks and marks; none without them. */    --dial-rim: 0rem;    /* How far along the track the value is, from nothing to all of it, and the angle that puts it at. */    --dial-share: clamp(0, calc((var(--dial-value) - var(--dial-min)) / (var(--dial-max) - var(--dial-min))), 1);    --dial-angle: calc(var(--dial-start) + var(--dial-share) * var(--dial-sweep));    /* The middle of the track, where the thumb's centre runs. */    --dial-radius: calc((var(--dial-size) - var(--dial-thumb)) / 2 - var(--dial-rim));    position: relative;    /* The thumb and the figure stand over the track within the dial, never over the page around it. */    isolation: isolate;    display: inline-grid;    flex: none;    place-items: center;    box-sizing: border-box;    width: var(--dial-size);    height: var(--dial-size);    margin: 0;    /* A circle takes the pointer, so the corners of its box do not. */    border-radius: 999px;    corner-shape: round;    color: var(--color-text-strong);    font: var(--font-weight-control) calc(var(--dial-radius) * .44)/1 var(--font-family-sans);    font-feature-settings: inherit;    font-variant-numeric: tabular-nums;    letter-spacing: -.02em;    text-align: center;    vertical-align: middle;    cursor: pointer;    /* A finger that turns the dial does not scroll the page, and a drag selects no text. */    touch-action: none;    -webkit-user-select: none;    user-select: none;    -webkit-tap-highlight-color: transparent;    @supports (x: attr(x type(*))) {      &[aria-valuenow] {        --dial-value: attr(aria-valuenow type(<number>), 0);      }      &[aria-valuemin] {        --dial-min: attr(aria-valuemin type(<number>), 0);      }      &[aria-valuemax] {        --dial-max: attr(aria-valuemax type(<number>), 100);      }    }    &:focus-visible {      outline: none;    }    /* Both drawings cover the dial, cut down to the track's ring. */    &::before, &::after {      --dial-inner: calc(var(--dial-radius) - var(--dial-track) / 2);      --dial-outer: calc(var(--dial-radius) + var(--dial-track) / 2);      content: '';      position: absolute;      inset: 0;      border-radius: 999px;      corner-shape: round;      mask: radial-gradient(circle, transparent calc(var(--dial-inner) - .5px), black var(--dial-inner), black var(--dial-outer), transparent calc(var(--dial-outer) + .5px));      pointer-events: none;    }    /*     * The track: the whole sweep, with a dot at each end to round it. It is drawn in the fill's own color and     * stepped back as one layer, so the dots and the arc never add up. Around the full circle the dots meet.     */    &::before {      --dial-end: calc(var(--dial-start) + var(--dial-sweep));      background:        radial-gradient(circle at calc(50% + var(--dial-radius) * sin(var(--dial-start))) calc(50% - var(--dial-radius) * cos(var(--dial-start))), var(--dial-color) calc(var(--dial-track) / 2 - .5px), transparent calc(var(--dial-track) / 2)),        radial-gradient(circle at calc(50% + var(--dial-radius) * sin(var(--dial-end))) calc(50% - var(--dial-radius) * cos(var(--dial-end))), var(--dial-color) calc(var(--dial-track) / 2 - .5px), transparent calc(var(--dial-track) / 2)),        conic-gradient(from var(--dial-start), var(--dial-color) var(--dial-sweep), transparent 0);      opacity: .12;    }    /* The fill: the same track as far as the value. Its dots have no radius at nothing, so an empty dial is an empty track. */    &::after {      --dial-cap: calc(var(--dial-track) / 2 * min(1, var(--dial-share) * 200));      background:        radial-gradient(circle at calc(50% + var(--dial-radius) * sin(var(--dial-start))) calc(50% - var(--dial-radius) * cos(var(--dial-start))), var(--dial-color) calc(var(--dial-cap) - .5px), transparent var(--dial-cap)),        radial-gradient(circle at calc(50% + var(--dial-radius) * sin(var(--dial-angle))) calc(50% - var(--dial-radius) * cos(var(--dial-angle))), var(--dial-color) calc(var(--dial-cap) - .5px), transparent var(--dial-cap)),        conic-gradient(from var(--dial-start), var(--dial-color) calc(var(--dial-share) * var(--dial-sweep)), transparent 0);    }    /* Ticks take a narrow rim outside the thumb's path; marks a wider one, outside the ticks. */    &:has(.dial-ticks) {      --dial-rim: .5rem;    }    &:has(.dial-mark) {      --dial-rim: 1.375rem;    }    &.dial-full {      --dial-start: 0deg;      --dial-sweep: 360deg;    }    &.dial-sm {      --dial-size: 5.5rem;    }    &.dial-lg {      --dial-size: 10rem;    }    &[aria-disabled="true"] {      opacity: .5;      cursor: not-allowed;    }    @media (forced-colors: active) {      --dial-color: Highlight;      forced-color-adjust: none;      color: CanvasText;      &::before {        --dial-color: GrayText;        opacity: 1;      }      /* The dial is out of forced colors, so its figure and its marks are given the system's disabled ink too. */      &[aria-disabled="true"] {        --dial-color: GrayText;        color: GrayText;      }    }  }  /* The thumb: the slider's pearl disc, standing on the track at the value's angle. */  .dial-thumb {    position: absolute;    z-index: 1;    top: calc(50% - var(--dial-radius) * cos(var(--dial-angle)));    left: calc(50% + var(--dial-radius) * sin(var(--dial-angle)));    box-sizing: border-box;    width: var(--dial-thumb);    height: var(--dial-thumb);    translate: -50% -50%;    border-radius: 999px;    corner-shape: round;    @apply --surface-thumb;    box-shadow: 0 0 0 .5px var(--color-line-strong), 0 1px 2px -.5px var(--color-shade-1), 0 2px 4px -1px var(--color-shade-2), 0 4px 8px -4px var(--color-shade-3);    transition: scale var(--duration-quick) var(--easing-glide);    /* Held, the thumb grows a little under the finger. */    .dial:active:not([aria-disabled="true"]) & {      scale: 1.08;    }    /* Focus rings the thumb, as it does on a slider: the thumb is what the keys move. */    .dial:focus-visible & {      @apply --focus-ring;    }    @media (prefers-reduced-motion: reduce) {      transition: none;      .dial:active:not([aria-disabled="true"]) & {        scale: none;      }    }    @media (forced-colors: active) {      background: ButtonText;      box-shadow: 0 0 0 1px Canvas;      .dial:focus-visible & {        outline-color: Highlight;      }      /* Disabled, the thumb takes the system's disabled ink with the fill, as a slider's thumb does. */      .dial[aria-disabled="true"] & {        background: GrayText;      }    }  }  /* The value as text, in the dial's own figures, in the middle. */  .dial-value {    position: relative;    z-index: 1;    max-width: calc(var(--dial-radius) * 1.4);    overflow: hidden;    text-overflow: ellipsis;    white-space: nowrap;  }  /*   * Ticks: --dial-ticks equal steps across the sweep, as fine lines in the rim just outside the thumb's path.   * A knob shows one more tick than steps, at both ends; the full circle shows as many as steps.   */  .dial-ticks {    --dial-ticks: 10;    --dial-tick-inner: calc(var(--dial-size) / 2 - var(--dial-rim) + .125rem);    --dial-tick-outer: calc(var(--dial-tick-inner) + .3125rem);    position: absolute;    inset: 0;    border-radius: 999px;    corner-shape: round;    color: var(--color-line-mark);    /* Each tick is feathered at its sides: a hard stop in a conic gradient draws a jagged line. */    background: repeating-conic-gradient(from calc(var(--dial-start) - .75deg), transparent 0, currentColor .3deg 1.2deg, transparent 1.5deg calc(var(--dial-sweep) / var(--dial-ticks)));    mask:      radial-gradient(circle, transparent calc(var(--dial-tick-inner) - .5px), black var(--dial-tick-inner), black var(--dial-tick-outer), transparent calc(var(--dial-tick-outer) + .5px)),      conic-gradient(from calc(var(--dial-start) - 1deg), black calc(var(--dial-sweep) + 2deg), transparent 0);    mask-composite: intersect;    pointer-events: none;    @media (forced-colors: active) {      color: GrayText;    }  }  /* A mark: a short word or figure in the rim, at the value --dial-at stands for. */  .dial-mark {    --dial-at: 0;    --dial-mark-angle: calc(var(--dial-start) + clamp(0, calc((var(--dial-at) - var(--dial-min)) / (var(--dial-max) - var(--dial-min))), 1) * var(--dial-sweep));    --dial-mark-radius: calc(var(--dial-size) / 2 - .4375rem);    position: absolute;    top: calc(50% - var(--dial-mark-radius) * cos(var(--dial-mark-angle)));    left: calc(50% + var(--dial-mark-radius) * sin(var(--dial-mark-angle)));    translate: -50% -50%;    color: var(--color-text-muted);    font: 400 .6875rem/1 var(--font-family-sans);    font-feature-settings: inherit;    font-variant-numeric: tabular-nums;    letter-spacing: 0;    white-space: nowrap;    pointer-events: none;    @media (forced-colors: active) {      color: CanvasText;      .dial[aria-disabled="true"] & {        color: GrayText;      }    }  }}