ナビゲーション

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 は 360 の 1 ステップ手前で止まります。

角度

<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 個の等しいステップに分ける細い線を描きます。ノブではステップ数より 1 本多く、両端に 1 本ずつ描かれ、円周全体ではステップ数と同じ本数になります。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 分の 1 で、数値の大きさはトラックに合わせて変わります。つまみはどのポインターでもスライダーと同じ 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" はフォームコントロールではないため、ダイヤルは hidden input を内包します。ビヘイビアは変更のたびに、ダイヤル内の最初の <input type="hidden"> に値を書き込み、フォームはその値を input の name で送信します。ダイヤルの input と change イベントは、ネイティブのコントロールと同様にフォームまでバブリングします。フォームのリセットは hidden input に影響しないため、ダイヤルはリセット直前の位置に留まります。リセットで値を戻す必要がある場合は、ページ側で値を設定し直します。

フォームでの使用

<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" でタブ移動の順序から外し、フォームが値を送信しないように hidden input にも 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 を持ちます。外部からダイヤルを回すには 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 が渡された場合)、hidden input に書き込みます。適用時には最初の値を同じ方法で書き込み、属性を読み取れないブラウザーのために、aria-valuemin と aria-valuemax を --dial-min と --dial-max にコピーします。
  • 値は、aria-valuemin を起点とするステップの位置に揃い、aria-valuemin と aria-valuemax の間に収まります。省略時の既定値は、最小値が 0、最大値が 100 です。円周全体の場合は、範囲を越えると反対側に戻ります。
  • ドラッグ pointerdown でポインターをキャプチャし、ダイヤルの中心から見たポインターの角度を読み取ります。その角度を、スタイルシートの描画と同じ --dial-start と --dial-sweep を使って値に変換します。回転範囲が 360 度のダイヤルは、dial-full の有無にかかわらず、範囲を越えると反対側に戻ります。中心付近の数値の上を押しても値は動きません。
  • キー操作 矢印キーで 1 ステップ、Page Up と Page Down でより大きな単位だけ回し、Home と End で両端に移動します。
  • ホイールは、有効にした場合、1 ノッチごとにダイヤルを 1 ステップ回します。ただし、Alt(Option)キーを押している間に限ります。ページをスクロールしてダイヤルの上を通過しても、ダイヤルが回ることはありません。
  • イベント ルートは、値が変わるたびに input を、ドラッグが終わったときやキー・ホイールで回したときに change を発行します。どちらもバブリングします。
  • 無効 aria-disabled="true" を指定したダイヤルは、キー、ポインター、ホイールのいずれの操作も受け付けません。
オプション設定する内容
step矢印キーで値が動く量と、ドラッグ時に値を丸める単位。既定値は 1 です
pagePage Up と Page Down で値が動く量。既定値は範囲の 10 分の 1 で、ステップの位置に揃えます
text値を受け取り、その文言を返す関数。dial-value と aria-valuetext に書き込まれます
wheeltrue にすると、Alt キーを押している間ホイールでダイヤルを回せます。既定値は false です

attach() はオプションを渡しません。オプションが必要なダイヤルには、attach() の実行後に個別にビヘイビアを適用します。このプレビューのスクリプトのように、1 つのルートに対する 2 回目の呼び出しは最初の呼び出しを置き換えます。MasterUI はプレビューが読み込むバンドルです。プロジェクトでは、上の例のように dial をインポートします。

ステップ、文言、ホイール

<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>
キー操作 1 回とホイール 1 ノッチがそれぞれ 15 度です。Alt(Option)キーを押しながらダイヤルの上でスクロールすると回ります。

ビヘイビアを適用しない場合、ダイヤルは最初の値を表示し、回りません。型付きの attr() に対応したブラウザーでは属性から、それ以外では --dial-value から値を取得します。

#キーボード操作

キー操作
ArrowUp, ArrowRight値を 1 ステップ上げます。書字方向にかかわらず時計回りです。完全な円では、最大値を超えると最小値に戻ります。
ArrowDown, ArrowLeft値を 1 ステップ下げます。反時計回りです。完全な円では、最小値を下回ると最大値に戻ります。
PageUp, PageDown値を大きなステップで上げ下げします。ページが別の値を指定しない限り、範囲の 10 分の 1 です。
Home, Endaria-valuemin または aria-valuemax に移動します。完全な円では、End は値が一周して戻る直前の最後のステップに移動します。

#アクセシビリティ

  • ルートは、フォーカス可能な role="slider" です。aria-label または aria-labelledby でアクセシブルな名前を付け、aria-valuemin と aria-valuemax の間の値を aria-valuenow に示します。円周上ではスライダーの向きに意味がないため、aria-orientation は指定しません。
  • 数値を理解するのに単位や文言が必要な場合は、「135°」「21 degrees」「Loud」のように aria-valuetext を記述します。ビヘイビアはこれを値と同期させます。
  • スライダー内の数値、目盛り、目印はすべて視覚的な表示で、支援技術には個別の要素として公開されません。ドラッグでできることはすべてキー操作でもでき、トラックを 1 回押すだけでも値を設定できるため、ドラッグして回すことが唯一の手段になることはありません。
  • フォーカスリングは、スライダーと同様につまみの周囲に表示されます。タッチスクリーンではダイヤル全体が指の操作を受け取り、ページをスクロールせずに回るため、つまみのサイズは変わりません。
  • 動きを抑える設定では、つかんだつまみが大きくなりません。強制カラーモードでは、塗りはシステムのハイライト色、トラックと目盛りはシステムのグレー、つまみはボタンのテキスト色になります。

#React、Svelte、Vue

dial コンポーネントはビヘイビアを適用し、値の受け渡しを行います。目盛りと目印はデータから描画し、name が渡された場合は hidden input も描画します。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ダイヤル本体で、直径 120px です。アクセシブルネーム、aria-valuenow、aria-valuemin、aria-valuemax を持つフォーカス可能な role="slider" に指定します。円形のトラックを始点から値までインク色で塗ります。既定では 270 度のノブで、下側が開いています。
dial-full上端から始まる完全な円です。角度に使い、最大値を超えると一周して戻ります。dial と併用します
dial-sm直径 88px のダイヤルです。既定は 120px です。dial と併用します
dial-lg直径 160px のダイヤルです。既定は 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;      }    }  }}