탐색

v2.1.0
폼

그라데이션

그라데이션을 만드는 편집기입니다. 막대에서 색상 지점의 위치를 조절하고, 색상 선택기에서 선택한 지점의 색상을 바꾸고, 유형·각도·중심을 설정합니다.

이 페이지의 내용

그라데이션 편집기는 그라데이션을 만듭니다. 막대 위에 색상 지점을 배치하고, 선택한 지점의 색상을 색상 선택기에 표시하며, 유형, 각도, 중심을 설정합니다. 편집기 안의 모든 컨트롤은 라이브러리의 컴포넌트입니다. 색상 선택기, 색상 지점의 위치를 정하는 슬라이더와 숫자 입력, 유형을 고르는 세그먼트 컨트롤, 각도를 정하는 다이얼, 중심을 정하는 숫자 입력으로 구성됩니다. 편집기는 여기에 색상 지점을 표시하는 막대와 미리보기를 더하고, 이 모두를 동기화하는 gradient 동작을 제공합니다.

그라데이션

<div class="gradient max-w(640) mx-auto" id="sunrise" role="group" aria-label="Background gradient" style="--gradient-ratio: 3 / 1">  <div class="gradient-preview" aria-hidden="true"></div>  <div class="gradient-bar"></div>  <div class="flex flex-wrap items-center gap-xs">    <button type="button" class="btn btn-sm gradient-add">      <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">        <path d="M3 8L13 8" /><path d="M8 3L8 13" />      </svg>Add a stop    </button>    <button type="button" class="btn btn-sm gradient-remove">      <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">        <path d="M3 8L13 8" />      </svg>Remove    </button>    <button type="button" class="btn btn-sm btn-quiet gradient-reverse">      <svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">        <path d="M8 1.6667L8 14.3333" /><path d="M5.6667 6.3298L5.6667 11.45A0.55 0.55 0 0 1 5.1167 12L2.5566 12A0.55 0.55 0 0 1 2.0647 11.204L4.6248 6.0839A0.55 0.55 0 0 1 5.6667 6.3298Z" /><path d="M10.3333 6.3298L10.3333 11.45A0.55 0.55 0 0 0 10.8833 12L13.4434 12A0.55 0.55 0 0 0 13.9353 11.204L11.3752 6.0839A0.55 0.55 0 0 0 10.3333 6.3298Z" />      </svg>Reverse    </button>  </div>  <div class="gradient-fields">    <fieldset class="gradient-color">      <legend class="mb(6) text-xs font-medium fg-text-muted">Color of the stop</legend>      <div class="color-picker" style="--color-picker-lightness: .7; --color-picker-chroma: .19; --color-picker-hue: 50">        <div class="color-picker-area">          <div class="color-picker-thumb" role="slider" tabindex="0" aria-label="Lightness and chroma" aria-valuemin="0" aria-valuemax="100" aria-valuenow="70"></div>        </div>        <span class="swatch swatch-lg color-picker-swatch"></span>        <input type="range" class="slider color-picker-hue" min="0" max="360" value="50" aria-label="Hue">        <input type="range" class="slider color-picker-alpha" min="0" max="100" value="100" aria-label="Opacity">        <div class="color-picker-fields">          <select class="select select-sm color-picker-format" aria-label="Format">            <option value="hex" selected>Hex</option>            <option value="rgb">RGB</option>            <option value="oklch">OKLCH</option>          </select>          <input class="input input-sm color-picker-text" value="#ff6a00" aria-label="Color" spellcheck="false" autocomplete="off">        </div>      </div>    </fieldset>    <div class="flex flex-col gap-md min-w(0)">      <fieldset class="gradient-offset">        <legend class="mb(6) text-xs font-medium fg-text-muted">Position</legend>        <input type="range" class="slider" min="0" max="100" step="1" value="0" aria-label="Position of the stop">        <input type="number" class="input input-sm w(72)" min="0" max="100" step="1" value="0" aria-label="Position of the stop, in percent">      </fieldset>      <fieldset class="gradient-type">        <legend class="mb(6) text-xs font-medium fg-text-muted">Type</legend>        <div class="segmented segmented-sm" role="radiogroup" aria-label="Type">          <label class="segmented-item">            <input type="radio" class="segmented-input" name="sunrise-type" value="linear" checked>Linear          </label>          <label class="segmented-item">            <input type="radio" class="segmented-input" name="sunrise-type" value="radial">Radial          </label>          <label class="segmented-item">            <input type="radio" class="segmented-input" name="sunrise-type" value="conic">Conic          </label>        </div>      </fieldset>      <div class="flex flex-wrap items-start gap-lg">        <fieldset class="gradient-angle">          <legend class="mb(6) text-xs font-medium fg-text-muted">Angle</legend>          <div class="dial dial-sm dial-full" role="slider" tabindex="0" aria-label="Angle" aria-valuenow="135" aria-valuemin="0" aria-valuemax="360" aria-valuetext="135°" style="--dial-value: 135">            <span class="dial-value">135°</span>            <span class="dial-thumb"></span>          </div>        </fieldset>        <fieldset class="gradient-center">          <legend class="mb(6) text-xs font-medium fg-text-muted">Center</legend>          <input type="number" class="input input-sm w(72)" min="0" max="100" value="50" aria-label="Center across, in percent">          <input type="number" class="input input-sm w(72)" min="0" max="100" value="50" aria-label="Center down, in percent">        </fieldset>      </div>    </div>  </div>  <pre class="code-block gradient-css" role="region" tabindex="0" aria-label="The gradient as CSS"></pre></div><script>addEventListener('DOMContentLoaded', function () {MasterUI.gradient(document.getElementById('sunrise'), { value: { type: 'linear', angle: 135, center: [50, 50], stops: [  { id: 'dawn', offset: 0, color: '#ff6a00' },  { id: 'noon', offset: 55, color: '#ee0979' },  { id: 'dusk', offset: 100, color: '#4f46e5' }] } })})</script><script type="module">  import { attach } from '@master/ui/behaviors'  attach()</script>
import { useEffect, useRef } from 'react'import { attach, gradient } from '@master/ui/behaviors'import PlusIcon from '@master/icons-react/native/16/soft/plus'import MinusIcon from '@master/icons-react/native/16/soft/minus'import FlipHorizontalIcon from '@master/icons-react/native/16/soft/flip-horizontal'export function Example() {  const root = useRef<HTMLDivElement>(null)  useEffect(() => {    const detach = [      attach(root.current!),      gradient(document.getElementById('sunrise')!, { value: { type: 'linear', angle: 135, center: [50, 50], stops: [        { id: 'dawn', offset: 0, color: '#ff6a00' },        { id: 'noon', offset: 55, color: '#ee0979' },        { id: 'dusk', offset: 100, color: '#4f46e5' }      ] } }),    ]    return () => detach.forEach(stop => stop())  }, [])  return (    <div ref={root} className="gradient max-w(640) mx-auto" id="sunrise" role="group" aria-label="Background gradient" style={{ '--gradient-ratio': '3 / 1' } as React.CSSProperties}>      <div className="gradient-preview" aria-hidden="true"></div>      <div className="gradient-bar"></div>      <div className="flex flex-wrap items-center gap-xs">        <button type="button" className="btn btn-sm gradient-add">          <PlusIcon className="icon" />Add a stop        </button>        <button type="button" className="btn btn-sm gradient-remove">          <MinusIcon className="icon" />Remove        </button>        <button type="button" className="btn btn-sm btn-quiet gradient-reverse">          <FlipHorizontalIcon className="icon" />Reverse        </button>      </div>      <div className="gradient-fields">        <fieldset className="gradient-color">          <legend className="mb(6) text-xs font-medium fg-text-muted">Color of the stop</legend>          <div className="color-picker" style={{ '--color-picker-lightness': '.7', '--color-picker-chroma': '.19', '--color-picker-hue': '50' } as React.CSSProperties}>            <div className="color-picker-area">              <div className="color-picker-thumb" role="slider" tabIndex={0} aria-label="Lightness and chroma" aria-valuemin={0} aria-valuemax={100} aria-valuenow={70}></div>            </div>            <span className="swatch swatch-lg color-picker-swatch"></span>            <input type="range" className="slider color-picker-hue" min="0" max="360" defaultValue="50" aria-label="Hue" />            <input type="range" className="slider color-picker-alpha" min="0" max="100" defaultValue="100" aria-label="Opacity" />            <div className="color-picker-fields">              <select className="select select-sm color-picker-format" aria-label="Format" defaultValue="hex">                <option value="hex">Hex</option>                <option value="rgb">RGB</option>                <option value="oklch">OKLCH</option>              </select>              <input className="input input-sm color-picker-text" defaultValue="#ff6a00" aria-label="Color" spellCheck="false" autoComplete="off" />            </div>          </div>        </fieldset>        <div className="flex flex-col gap-md min-w(0)">          <fieldset className="gradient-offset">            <legend className="mb(6) text-xs font-medium fg-text-muted">Position</legend>            <input type="range" className="slider" min="0" max="100" step="1" defaultValue="0" aria-label="Position of the stop" />            <input type="number" className="input input-sm w(72)" min="0" max="100" step="1" defaultValue="0" aria-label="Position of the stop, in percent" />          </fieldset>          <fieldset className="gradient-type">            <legend className="mb(6) text-xs font-medium fg-text-muted">Type</legend>            <div className="segmented segmented-sm" role="radiogroup" aria-label="Type">              <label className="segmented-item">                <input type="radio" className="segmented-input" name="sunrise-type" value="linear" defaultChecked />Linear              </label>              <label className="segmented-item">                <input type="radio" className="segmented-input" name="sunrise-type" value="radial" />Radial              </label>              <label className="segmented-item">                <input type="radio" className="segmented-input" name="sunrise-type" value="conic" />Conic              </label>            </div>          </fieldset>          <div className="flex flex-wrap items-start gap-lg">            <fieldset className="gradient-angle">              <legend className="mb(6) text-xs font-medium fg-text-muted">Angle</legend>              <div className="dial dial-sm dial-full" role="slider" tabIndex={0} aria-label="Angle" aria-valuenow={135} aria-valuemin={0} aria-valuemax={360} aria-valuetext="135°" style={{ '--dial-value': '135' } as React.CSSProperties}>                <span className="dial-value">135°</span>                <span className="dial-thumb"></span>              </div>            </fieldset>            <fieldset className="gradient-center">              <legend className="mb(6) text-xs font-medium fg-text-muted">Center</legend>              <input type="number" className="input input-sm w(72)" min="0" max="100" defaultValue="50" aria-label="Center across, in percent" />              <input type="number" className="input input-sm w(72)" min="0" max="100" defaultValue="50" aria-label="Center down, in percent" />            </fieldset>          </div>        </div>      </div>      <pre className="code-block gradient-css" role="region" tabIndex={0} aria-label="The gradient as CSS">{``}</pre>    </div>  )}
<script>  import { attach, gradient } from '@master/ui/behaviors'  import PlusIcon from '@master/icons-svelte/native/16/soft/plus'  import MinusIcon from '@master/icons-svelte/native/16/soft/minus'  import FlipHorizontalIcon from '@master/icons-svelte/native/16/soft/flip-horizontal'  function mounted(root) {    const detach = [      attach(root),      gradient(document.getElementById('sunrise'), { value: { type: 'linear', angle: 135, center: [50, 50], stops: [        { id: 'dawn', offset: 0, color: '#ff6a00' },        { id: 'noon', offset: 55, color: '#ee0979' },        { id: 'dusk', offset: 100, color: '#4f46e5' }      ] } }),    ]    return () => detach.forEach(stop => stop())  }</script><div class="gradient max-w(640) mx-auto" id="sunrise" role="group" aria-label="Background gradient" style="--gradient-ratio: 3 / 1" {@attach mounted}>  <div class="gradient-preview" aria-hidden="true"></div>  <div class="gradient-bar"></div>  <div class="flex flex-wrap items-center gap-xs">    <button type="button" class="btn btn-sm gradient-add">      <PlusIcon class="icon" />Add a stop    </button>    <button type="button" class="btn btn-sm gradient-remove">      <MinusIcon class="icon" />Remove    </button>    <button type="button" class="btn btn-sm btn-quiet gradient-reverse">      <FlipHorizontalIcon class="icon" />Reverse    </button>  </div>  <div class="gradient-fields">    <fieldset class="gradient-color">      <legend class="mb(6) text-xs font-medium fg-text-muted">Color of the stop</legend>      <div class="color-picker" style="--color-picker-lightness: .7; --color-picker-chroma: .19; --color-picker-hue: 50">        <div class="color-picker-area">          <div class="color-picker-thumb" role="slider" tabindex="0" aria-label="Lightness and chroma" aria-valuemin="0" aria-valuemax="100" aria-valuenow="70"></div>        </div>        <span class="swatch swatch-lg color-picker-swatch"></span>        <input type="range" class="slider color-picker-hue" min="0" max="360" value="50" aria-label="Hue">        <input type="range" class="slider color-picker-alpha" min="0" max="100" value="100" aria-label="Opacity">        <div class="color-picker-fields">          <select class="select select-sm color-picker-format" aria-label="Format">            <option value="hex" selected>Hex</option>            <option value="rgb">RGB</option>            <option value="oklch">OKLCH</option>          </select>          <input class="input input-sm color-picker-text" value="#ff6a00" aria-label="Color" spellcheck="false" autocomplete="off">        </div>      </div>    </fieldset>    <div class="flex flex-col gap-md min-w(0)">      <fieldset class="gradient-offset">        <legend class="mb(6) text-xs font-medium fg-text-muted">Position</legend>        <input type="range" class="slider" min="0" max="100" step="1" value="0" aria-label="Position of the stop">        <input type="number" class="input input-sm w(72)" min="0" max="100" step="1" value="0" aria-label="Position of the stop, in percent">      </fieldset>      <fieldset class="gradient-type">        <legend class="mb(6) text-xs font-medium fg-text-muted">Type</legend>        <div class="segmented segmented-sm" role="radiogroup" aria-label="Type">          <label class="segmented-item">            <input type="radio" class="segmented-input" name="sunrise-type" value="linear" checked>Linear          </label>          <label class="segmented-item">            <input type="radio" class="segmented-input" name="sunrise-type" value="radial">Radial          </label>          <label class="segmented-item">            <input type="radio" class="segmented-input" name="sunrise-type" value="conic">Conic          </label>        </div>      </fieldset>      <div class="flex flex-wrap items-start gap-lg">        <fieldset class="gradient-angle">          <legend class="mb(6) text-xs font-medium fg-text-muted">Angle</legend>          <div class="dial dial-sm dial-full" role="slider" tabindex="0" aria-label="Angle" aria-valuenow="135" aria-valuemin="0" aria-valuemax="360" aria-valuetext="135°" style="--dial-value: 135">            <span class="dial-value">135°</span>            <span class="dial-thumb"></span>          </div>        </fieldset>        <fieldset class="gradient-center">          <legend class="mb(6) text-xs font-medium fg-text-muted">Center</legend>          <input type="number" class="input input-sm w(72)" min="0" max="100" value="50" aria-label="Center across, in percent">          <input type="number" class="input input-sm w(72)" min="0" max="100" value="50" aria-label="Center down, in percent">        </fieldset>      </div>    </div>  </div>  <pre class="code-block gradient-css" role="region" tabindex="0" aria-label="The gradient as CSS"></pre></div>
<script setup>import { onMounted, onUnmounted, ref } from 'vue'import { attach, gradient } from '@master/ui/behaviors'import PlusIcon from '@master/icons-vue/native/16/soft/plus'import MinusIcon from '@master/icons-vue/native/16/soft/minus'import FlipHorizontalIcon from '@master/icons-vue/native/16/soft/flip-horizontal'const root = ref(null)let detach = []onMounted(() => {  detach = [    attach(root.value),    gradient(document.getElementById('sunrise'), { value: { type: 'linear', angle: 135, center: [50, 50], stops: [      { id: 'dawn', offset: 0, color: '#ff6a00' },      { id: 'noon', offset: 55, color: '#ee0979' },      { id: 'dusk', offset: 100, color: '#4f46e5' }    ] } }),  ]})onUnmounted(() => detach.forEach(stop => stop()))</script><template>  <div ref="root" class="gradient max-w(640) mx-auto" id="sunrise" role="group" aria-label="Background gradient" style="--gradient-ratio: 3 / 1">    <div class="gradient-preview" aria-hidden="true"></div>    <div class="gradient-bar"></div>    <div class="flex flex-wrap items-center gap-xs">      <button type="button" class="btn btn-sm gradient-add">        <PlusIcon class="icon" />Add a stop      </button>      <button type="button" class="btn btn-sm gradient-remove">        <MinusIcon class="icon" />Remove      </button>      <button type="button" class="btn btn-sm btn-quiet gradient-reverse">        <FlipHorizontalIcon class="icon" />Reverse      </button>    </div>    <div class="gradient-fields">      <fieldset class="gradient-color">        <legend class="mb(6) text-xs font-medium fg-text-muted">Color of the stop</legend>        <div class="color-picker" style="--color-picker-lightness: .7; --color-picker-chroma: .19; --color-picker-hue: 50">          <div class="color-picker-area">            <div class="color-picker-thumb" role="slider" tabindex="0" aria-label="Lightness and chroma" aria-valuemin="0" aria-valuemax="100" aria-valuenow="70"></div>          </div>          <span class="swatch swatch-lg color-picker-swatch"></span>          <input type="range" class="slider color-picker-hue" min="0" max="360" value="50" aria-label="Hue">          <input type="range" class="slider color-picker-alpha" min="0" max="100" value="100" aria-label="Opacity">          <div class="color-picker-fields">            <select class="select select-sm color-picker-format" aria-label="Format">              <option value="hex" selected>Hex</option>              <option value="rgb">RGB</option>              <option value="oklch">OKLCH</option>            </select>            <input class="input input-sm color-picker-text" value="#ff6a00" aria-label="Color" spellcheck="false" autocomplete="off">          </div>        </div>      </fieldset>      <div class="flex flex-col gap-md min-w(0)">        <fieldset class="gradient-offset">          <legend class="mb(6) text-xs font-medium fg-text-muted">Position</legend>          <input type="range" class="slider" min="0" max="100" step="1" value="0" aria-label="Position of the stop">          <input type="number" class="input input-sm w(72)" min="0" max="100" step="1" value="0" aria-label="Position of the stop, in percent">        </fieldset>        <fieldset class="gradient-type">          <legend class="mb(6) text-xs font-medium fg-text-muted">Type</legend>          <div class="segmented segmented-sm" role="radiogroup" aria-label="Type">            <label class="segmented-item">              <input type="radio" class="segmented-input" name="sunrise-type" value="linear" checked>Linear            </label>            <label class="segmented-item">              <input type="radio" class="segmented-input" name="sunrise-type" value="radial">Radial            </label>            <label class="segmented-item">              <input type="radio" class="segmented-input" name="sunrise-type" value="conic">Conic            </label>          </div>        </fieldset>        <div class="flex flex-wrap items-start gap-lg">          <fieldset class="gradient-angle">            <legend class="mb(6) text-xs font-medium fg-text-muted">Angle</legend>            <div class="dial dial-sm dial-full" role="slider" tabindex="0" aria-label="Angle" aria-valuenow="135" aria-valuemin="0" aria-valuemax="360" aria-valuetext="135°" style="--dial-value: 135">              <span class="dial-value">135°</span>              <span class="dial-thumb"></span>            </div>          </fieldset>          <fieldset class="gradient-center">            <legend class="mb(6) text-xs font-medium fg-text-muted">Center</legend>            <input type="number" class="input input-sm w(72)" min="0" max="100" value="50" aria-label="Center across, in percent">            <input type="number" class="input input-sm w(72)" min="0" max="100" value="50" aria-label="Center down, in percent">          </fieldset>        </div>      </div>    </div>    <pre class="code-block gradient-css" role="region" tabindex="0" aria-label="The gradient as CSS"></pre>  </div></template>
색상 지점을 드래그하거나, 선택한 뒤 방향키로 옮겨 보세요. 유형을 바꾸고 각도를 돌려 볼 수도 있습니다.

#값

그라데이션은 네 부분으로 이루어진 값입니다.

부분내용
typelinear, radial, conic 중 하나
angle선형 및 원뿔형 그라데이션의 각도(도)
center방사형 및 원뿔형 그라데이션의 중심을 나타내는 두 백분율
stops각 색상 지점에 고정된 id, 0부터 100까지의 offset, color가 있습니다.

색상은 색상 선택기가 작성하는 방식대로 불투명도를 포함한 sRGB 16진수로 작성합니다. gradientCss(value)는 그라데이션을 CSS로 작성하며, 미리보기와 복사되는 텍스트 모두 이 함수에서 나옵니다. 브라우저에 보간 색 공간을 지정할 수 있으면 OKLab에서 보간하고, 지정할 수 없는 브라우저를 위해 그 앞에 폴백을 둡니다.

copied.css
background-image: linear-gradient(90deg, #ff6a00 0%, #ee0979 100%);background-image: linear-gradient(in oklab 90deg, #ff6a00 0%, #ee0979 100%);

CSS를 다시 읽어 들이지는 않습니다. 편집기는 값을 보유하며, 애플리케이션도 텍스트가 아니라 값을 저장합니다.

#색상 지점

  • 색상 지점의 손잡이는 슬라이더입니다. 지점의 위치를 값으로 가지며, 막대 위에 해당 색상의 원으로 표시됩니다. 누르면 지점이 선택되고, 드래그하면 이동합니다. 방향키로 1씩, Shift와 함께 누르면 10씩 이동하며, Home과 End로 양 끝으로 이동합니다. 선택한 지점에는 aria-current="true"가 지정되며, 손잡이가 살짝 앞으로 나오고 전경색 테두리가 표시됩니다.
  • 색상 지점은 서로 지나칠 수 있습니다. 다른 지점을 지나쳐도 이동한 지점의 id와 손잡이의 포커스는 유지됩니다. 그라데이션은 위치 순서대로 각 지점의 색상을 적용합니다. 두 지점이 같은 위치에 있으면 그곳에서 색상이 뚜렷하게 갈리며, 두 지점의 순서는 유지됩니다.
  • 추가하면 선택한 지점과 같은 색상의 지점이 현재 위치에 10을 더한 곳에 생깁니다. 새 지점의 위치는 100을 넘지 않습니다. 버튼이나 Delete로 삭제하면 포커스가 막대의 다음 지점으로 이동합니다. 다음 지점이 없으면 이전 지점으로 이동합니다. 지점은 최소 두 개이며, 두 개일 때는 삭제가 비활성화됩니다.
  • 반전하면 색상 지점의 순서가 뒤집히고, 각 지점의 새 위치는 100에서 기존 위치를 뺀 값이 됩니다.

드래그 외에도 슬라이더와 그 옆의 숫자 입력으로 위치를 조절할 수 있습니다. Tab 키로 모든 색상 지점에 포커스를 옮길 수 있습니다.

#상태

루트에 aria-readonly="true"를 지정하면 변경할 수 없는 그라데이션을, aria-disabled="true"를 지정하면 편집기가 비활성 상태로 표시됩니다. 손잡이는 제자리에 머물고 컨트롤은 비활성화됩니다.

#동작

app.js
import { gradient, gradientCss } from '@master/ui/behaviors/gradient.js'const editor = gradient(document.querySelector('.gradient'), {  value: { type: 'linear', angle: 90, center: [50, 50], stops: [    { id: 'from', offset: 0, color: '#ff6a00' },    { id: 'to', offset: 100, color: '#ee0979' },  ] },})editor.value                     // the value as abovegradientCss(editor.value).text   // the two lines to copy

독자가 조작하는 동안에는 input 이벤트가, 조작이 끝나면 change 이벤트가 발행됩니다. value를 설정하면 다른 그라데이션을 표시하며 이벤트는 발행되지 않습니다. 동작은 값으로 손잡이를 작성하므로, 손잡이를 직접 작성하는 프레임워크는 draw를 지정합니다. 동작은 루트에 그라데이션을 --gradient와 --gradient-fallback으로, 각 손잡이에 색상 지점의 위치와 색상을 --gradient-offset과 --gradient-color로 출력합니다. 편집기가 표시하는 그라데이션 자체가 콘텐츠이며, 스타일시트가 각 요소의 위치를 정합니다.

#키보드

키동작
Tab막대에서 선택한 정지점으로 이동한 뒤 컨트롤을 차례로 이동합니다. 다른 정지점은 포인터로 선택하거나 막대의 Tab 키 이동 순서에서 해당 위치로 이동해 선택합니다.
ArrowRight, ArrowUp정지점에서: 끝 방향으로 1만큼, Shift와 함께 누르면 10만큼 이동합니다. 오른쪽에서 왼쪽으로 쓰는 페이지에서는 ArrowRight가 왼쪽으로 이동합니다.
ArrowLeft, ArrowDown정지점에서: 시작 방향으로 1만큼, Shift와 함께 누르면 10만큼 이동합니다
PageUp, PageDown정지점에서: 10만큼 이동합니다
Home, End정지점에서: 0 또는 100 위치로 이동합니다
Delete, Backspace정지점에서: 정지점이 두 개보다 많으면 삭제하고 이웃한 정지점으로 포커스를 넘깁니다

#접근성

  • 각 손잡이의 이름에는 해당 색상 지점이 몇 번째인지가 포함되며, aria-valuetext로 위치와 색상을 알려 줍니다.
  • 미리보기는 값을 그림으로 보여 줄 뿐입니다. 색상 지점과 CSS가 같은 내용을 전달하므로 보조 기술에서 숨기세요.
  • 강제 색상 모드에서도 그라데이션은 콘텐츠이므로 고유한 색상을 유지하며, 손잡이와 막대에는 시스템 색상의 윤곽선이 표시됩니다.

#React, Svelte 및 Vue

gradient 컴포넌트는 값으로 손잡이와 컨트롤을 작성하고 동작을 연결합니다. npx master-ui add gradient로 프로젝트에 복사하세요. 컴포넌트의 구성과 사용법은 React, Svelte 및 Vue에서 확인할 수 있습니다.

ui/gradient.tsx
'use client'import { useId, useState, type ComponentProps, type CSSProperties } from 'react'import { colorPickerState } from '@master/ui/behaviors/color-picker.js'import { gradient, gradientCss, gradientStops, gradientValue, type GradientValue } from '@master/ui/behaviors/gradient.js'import { useBehavior } from './use-behavior'export type { GradientValue }/** What the controls are called, in the page's words. */export interface GradientLabels {  add?: string  remove?: string  reverse?: string  color?: string  position?: string  type?: string  linear?: string  radial?: string  conic?: string  angle?: string  center?: string  centerX?: string  centerY?: string  css?: string}export interface GradientProps extends Omit<ComponentProps<'div'>, 'defaultValue' | 'children' | 'ref'> {  value?: GradientValue  defaultValue?: GradientValue  onValueChange?: (value: GradientValue) => void  /** The gradient is shown and cannot be changed. */  readOnly?: boolean  disabled?: boolean  labels?: GradientLabels}const icon = (...paths: string[]) => <svg className="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">{paths.map(d => <path key={d} d={d} />)}</svg>/** * A gradient editor. React writes the controls and a handle for each stop from the value, so the first HTML * holds the gradient; the behavior moves every state and asks for the stops again when they change. */export function Gradient({ value, defaultValue, onValueChange, readOnly, disabled, labels = {}, className, style, ...root }: GradientProps) {  const id = useId()  const [first] = useState(() => gradientValue(value ?? defaultValue))  const [shown, setShown] = useState(first)  const words = { add: 'Add a stop', remove: 'Remove', reverse: 'Reverse', color: 'Color of the stop', position: 'Position', type: 'Type', linear: 'Linear', radial: 'Radial', conic: 'Conic', angle: 'Angle', center: 'Centre', centerX: 'Centre across, in percent', centerY: 'Centre down, in percent', css: 'The gradient as CSS', ...labels }  const ref = useBehavior(gradient, { value: first, draw: setShown }, { value, defaultValue, onValueChange })  const css = gradientCss(first)  const color = colorPickerState(first.stops[0]!.color)!  return (    <div className={className ? `gradient ${className}` : 'gradient'} ref={ref} aria-readonly={readOnly || undefined} aria-disabled={disabled || undefined} style={{ '--gradient': css.css, '--gradient-fallback': css.fallback, ...style } as CSSProperties} {...root}>      <div className="gradient-preview" aria-hidden="true" />      <div className="gradient-bar">        {gradientStops(shown.stops).map((stop, index, all) => (          <span className="gradient-stop" role="slider" data-id={stop.id} aria-label={`Stop ${index + 1} of ${all.length}`} aria-valuemin={0} aria-valuemax={100} aria-valuenow={stop.offset} style={{ '--gradient-offset': stop.offset, '--gradient-color': stop.color } as CSSProperties} key={stop.id} />        ))}      </div>      <div className="flex flex-wrap items-center gap-xs">        <button type="button" className="btn btn-sm gradient-add">{icon('M3 8L13 8', 'M8 3L8 13')}{words.add}</button>        <button type="button" className="btn btn-sm gradient-remove">{icon('M3 8L13 8')}{words.remove}</button>        <button type="button" className="btn btn-sm btn-quiet gradient-reverse">{icon('M8 1.6667L8 14.3333', 'M5.6667 6.3298L5.6667 11.45A0.55 0.55 0 0 1 5.1167 12L2.5566 12A0.55 0.55 0 0 1 2.0647 11.204L4.6248 6.0839A0.55 0.55 0 0 1 5.6667 6.3298Z', 'M10.3333 6.3298L10.3333 11.45A0.55 0.55 0 0 0 10.8833 12L13.4434 12A0.55 0.55 0 0 0 13.9353 11.204L11.3752 6.0839A0.55 0.55 0 0 0 10.3333 6.3298Z')}{words.reverse}</button>      </div>      <div className="gradient-fields">        <fieldset className="gradient-color">          <legend className="mb(6) text-xs font-medium fg-text-muted">{words.color}</legend>          <div className="color-picker" style={color.properties as CSSProperties}>            <div className="color-picker-area">              <div className="color-picker-thumb" role="slider" tabIndex={0} aria-label="Lightness and chroma" aria-valuemin={0} aria-valuemax={100} aria-valuenow={color.valueNow} aria-valuetext={color.valueText} />            </div>            <span className="swatch swatch-lg color-picker-swatch" />            <input type="range" className="slider color-picker-hue" min={0} max={360} defaultValue={color.hue} aria-label="Hue" />            <input type="range" className="slider color-picker-alpha" min={0} max={100} defaultValue={color.alpha * 100} aria-label="Opacity" />            <div className="color-picker-fields">              <select className="select select-sm color-picker-format" defaultValue="hex" aria-label="Format">                <option value="hex">Hex</option>                <option value="rgb">RGB</option>                <option value="oklch">OKLCH</option>              </select>              <input className="input input-sm color-picker-text" defaultValue={color.value} aria-label={words.color} spellCheck={false} autoComplete="off" />            </div>          </div>        </fieldset>        <div className="flex flex-col gap-md min-w(0)">          <fieldset className="gradient-offset">            <legend className="mb(6) text-xs font-medium fg-text-muted">{words.position}</legend>            <input type="range" className="slider" min={0} max={100} step={1} defaultValue={first.stops[0]!.offset} aria-label={words.position} />            <input type="number" className="input input-sm w(72)" min={0} max={100} step={0.1} defaultValue={first.stops[0]!.offset} aria-label={`${words.position}, %`} />          </fieldset>          <fieldset className="gradient-type">            <legend className="mb(6) text-xs font-medium fg-text-muted">{words.type}</legend>            <div className="segmented segmented-sm" role="radiogroup" aria-label={words.type}>              {(['linear', 'radial', 'conic'] as const).map(type => (                <label className="segmented-item" key={type}><input type="radio" className="segmented-input" name={`${id}type`} value={type} defaultChecked={first.type === type} />{words[type]}</label>              ))}            </div>          </fieldset>          <div className="flex flex-wrap items-start gap-lg">            <fieldset className="gradient-angle">              <legend className="mb(6) text-xs font-medium fg-text-muted">{words.angle}</legend>              <div className="dial dial-sm dial-full" role="slider" tabIndex={0} aria-label={words.angle} aria-valuenow={first.angle} aria-valuemin={0} aria-valuemax={360} aria-valuetext={`${first.angle}°`} style={{ '--dial-value': first.angle } as CSSProperties}>                <span className="dial-value">{`${first.angle}°`}</span>                <span className="dial-thumb" />              </div>            </fieldset>            <fieldset className="gradient-center">              <legend className="mb(6) text-xs font-medium fg-text-muted">{words.center}</legend>              <input type="number" className="input input-sm w(72)" min={0} max={100} defaultValue={first.center[0]} aria-label={words.centerX} />              <input type="number" className="input input-sm w(72)" min={0} max={100} defaultValue={first.center[1]} aria-label={words.centerY} />            </fieldset>          </div>        </div>      </div>      <pre className="code-block gradient-css" aria-label={words.css}>{css.text}</pre>    </div>  )}
ui/Gradient.svelte
<script lang="ts" module>  import type { HTMLAttributes } from 'svelte/elements'  import type { GradientValue } from '@master/ui/behaviors/gradient.js'  export type { GradientValue }  /** What the controls are called, in the page's words. */  export interface GradientLabels {    add?: string    remove?: string    reverse?: string    color?: string    position?: string    type?: string    linear?: string    radial?: string    conic?: string    angle?: string    center?: string    centerX?: string    centerY?: string    css?: string  }  export interface GradientProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {    /** The gradient. Bind it, or leave it out: two stops, black to white. */    value?: GradientValue    onValueChange?: (value: GradientValue) => void    /** The gradient is shown and cannot be changed. */    readOnly?: boolean    disabled?: boolean    labels?: GradientLabels  }</script><script lang="ts">  import { untrack } from 'svelte'  import { colorPickerState } from '@master/ui/behaviors/color-picker.js'  import { gradient, gradientCss, gradientStops, gradientValue } from '@master/ui/behaviors/gradient.js'  import { behavior } from './behavior.svelte.js'  let { value = $bindable(), onValueChange, readOnly, disabled, labels = {}, class: className, style, ...root }: GradientProps = $props()  const id = $props.id()  const first = untrack(() => gradientValue(value))  let shown = $state(first)  const words = $derived({ add: 'Add a stop', remove: 'Remove', reverse: 'Reverse', color: 'Color of the stop', position: 'Position', type: 'Type', linear: 'Linear', radial: 'Radial', conic: 'Conic', angle: 'Angle', center: 'Centre', centerX: 'Centre across, in percent', centerY: 'Centre down, in percent', css: 'The gradient as CSS', ...labels })  const css = gradientCss(first)  // Svelte writes a style again whenever its owner changes it, so it writes the gradient the behavior holds.  const painted = $derived(gradientCss(shown))  const color = colorPickerState(first.stops[0]!.color)!  const attach = behavior(gradient, () => ({ value: first, draw: (next: GradientValue) => { shown = next } }), {    value: () => value,    change: (next) => { value = next; onValueChange?.(next) },  })  const types = ['linear', 'radial', 'conic'] as const  const pickerStyle = Object.entries(color.properties).map(([name, text]) => `${name}: ${text}`).join('; ')</script><!--  @component  A gradient editor. Svelte writes the controls and a handle for each stop from the value, so the first HTML  holds the gradient; the behavior moves every state and asks for the stops again when they change.--><div class={['gradient', className]} aria-readonly={readOnly || undefined} aria-disabled={disabled || undefined} {style} style:--gradient={painted.css} style:--gradient-fallback={painted.fallback} {@attach attach} {...root}>  <div class="gradient-preview" aria-hidden="true"></div>  <div class="gradient-bar">    {#each gradientStops(shown.stops) as stop, index (stop.id)}      <span class="gradient-stop" role="slider" data-id={stop.id} aria-label="Stop {index + 1} of {shown.stops.length}" aria-valuemin={0} aria-valuemax={100} aria-valuenow={stop.offset} style="--gradient-offset: {stop.offset}; --gradient-color: {stop.color}"></span>    {/each}  </div>  <div class="flex flex-wrap items-center gap-xs">    <button type="button" class="btn btn-sm gradient-add"><svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 8L13 8" /><path d="M8 3L8 13" /></svg>{words.add}</button>    <button type="button" class="btn btn-sm gradient-remove"><svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 8L13 8" /></svg>{words.remove}</button>    <button type="button" class="btn btn-sm btn-quiet gradient-reverse"><svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 1.6667L8 14.3333" /><path d="M5.6667 6.3298L5.6667 11.45A0.55 0.55 0 0 1 5.1167 12L2.5566 12A0.55 0.55 0 0 1 2.0647 11.204L4.6248 6.0839A0.55 0.55 0 0 1 5.6667 6.3298Z" /><path d="M10.3333 6.3298L10.3333 11.45A0.55 0.55 0 0 0 10.8833 12L13.4434 12A0.55 0.55 0 0 0 13.9353 11.204L11.3752 6.0839A0.55 0.55 0 0 0 10.3333 6.3298Z" /></svg>{words.reverse}</button>  </div>  <div class="gradient-fields">    <fieldset class="gradient-color">      <legend class="mb(6) text-xs font-medium fg-text-muted">{words.color}</legend>      <div class="color-picker" style={pickerStyle}>        <div class="color-picker-area">          <div class="color-picker-thumb" role="slider" tabindex="0" aria-label="Lightness and chroma" aria-valuemin={0} aria-valuemax={100} aria-valuenow={color.valueNow} aria-valuetext={color.valueText}></div>        </div>        <span class="swatch swatch-lg color-picker-swatch"></span>        <input type="range" class="slider color-picker-hue" min="0" max="360" value={color.hue} aria-label="Hue" />        <input type="range" class="slider color-picker-alpha" min="0" max="100" value={color.alpha * 100} aria-label="Opacity" />        <div class="color-picker-fields">          <select class="select select-sm color-picker-format" aria-label="Format">            <option value="hex" selected>Hex</option>            <option value="rgb">RGB</option>            <option value="oklch">OKLCH</option>          </select>          <input class="input input-sm color-picker-text" value={color.value} aria-label={words.color} spellcheck="false" autocomplete="off" />        </div>      </div>    </fieldset>    <div class="flex flex-col gap-md min-w(0)">      <fieldset class="gradient-offset">        <legend class="mb(6) text-xs font-medium fg-text-muted">{words.position}</legend>        <input type="range" class="slider" min="0" max="100" step="1" value={first.stops[0]!.offset} aria-label={words.position} />        <input type="number" class="input input-sm w(72)" min="0" max="100" step="0.1" value={first.stops[0]!.offset} aria-label="{words.position}, %" />      </fieldset>      <fieldset class="gradient-type">        <legend class="mb(6) text-xs font-medium fg-text-muted">{words.type}</legend>        <div class="segmented segmented-sm" role="radiogroup" aria-label={words.type}>          {#each types as type (type)}            <label class="segmented-item"><input type="radio" class="segmented-input" name="{id}type" value={type} checked={first.type === type} />{words[type]}</label>          {/each}        </div>      </fieldset>      <div class="flex flex-wrap items-start gap-lg">        <fieldset class="gradient-angle">          <legend class="mb(6) text-xs font-medium fg-text-muted">{words.angle}</legend>          <div class="dial dial-sm dial-full" role="slider" tabindex="0" aria-label={words.angle} aria-valuenow={first.angle} aria-valuemin={0} aria-valuemax={360} aria-valuetext="{first.angle}°" style="--dial-value: {first.angle}">            <span class="dial-value">{first.angle}°</span>            <span class="dial-thumb"></span>          </div>        </fieldset>        <fieldset class="gradient-center">          <legend class="mb(6) text-xs font-medium fg-text-muted">{words.center}</legend>          <input type="number" class="input input-sm w(72)" min="0" max="100" value={first.center[0]} aria-label={words.centerX} />          <input type="number" class="input input-sm w(72)" min="0" max="100" value={first.center[1]} aria-label={words.centerY} />        </fieldset>      </div>    </div>  </div>  <pre class="code-block gradient-css" aria-label={words.css}>{css.text}</pre></div>
ui/Gradient.vue
<script lang="ts">import type { GradientValue } from '@master/ui/behaviors/gradient.js'export type { GradientValue }/** What the controls are called, in the page's words. */export interface GradientLabels {  add?: string  remove?: string  reverse?: string  color?: string  position?: string  type?: string  linear?: string  radial?: string  conic?: string  angle?: string  center?: string  centerX?: string  centerY?: string  css?: string}</script><script setup lang="ts">import { computed, shallowRef, useId, useTemplateRef } from 'vue'import { colorPickerState } from '@master/ui/behaviors/color-picker.js'import { gradient, gradientCss, gradientStops, gradientValue } from '@master/ui/behaviors/gradient.js'import { useBehavior } from './use-behavior'defineOptions({ inheritAttrs: false })const { readOnly, disabled, labels = {} } = defineProps<{  /** The gradient is shown and cannot be changed. */  readOnly?: boolean  disabled?: boolean  labels?: GradientLabels}>()/** The gradient: `v-model`. Two stops, black to white, by default. */const model = defineModel<GradientValue>()/* * A gradient editor. Vue writes the controls and a handle for each stop from the value, so the first HTML holds * the gradient; the behavior moves every state and asks for the stops again when they change. */const id = useId()const first = gradientValue(model.value)const shown = shallowRef<GradientValue>(first)const words = computed(() => ({ add: 'Add a stop', remove: 'Remove', reverse: 'Reverse', color: 'Color of the stop', position: 'Position', type: 'Type', linear: 'Linear', radial: 'Radial', conic: 'Conic', angle: 'Angle', center: 'Centre', centerX: 'Centre across, in percent', centerY: 'Centre down, in percent', css: 'The gradient as CSS', ...labels }))const css = gradientCss(first)// Vue writes a style again each time it renders, so it writes the gradient the behavior holds, not the first one.const painted = computed(() => gradientCss(shown.value))const color = colorPickerState(first.stops[0]!.color)!const types = ['linear', 'radial', 'conic'] as constconst root = useTemplateRef<HTMLDivElement>('root')useBehavior(root, gradient, () => ({ value: first, draw: (next: GradientValue) => { shown.value = next } }), model)</script><template>  <div class="gradient" ref="root" :aria-readonly="readOnly || undefined" :aria-disabled="disabled || undefined" :style="{ '--gradient': painted.css, '--gradient-fallback': painted.fallback }" v-bind="$attrs">    <div class="gradient-preview" aria-hidden="true"></div>    <div class="gradient-bar">      <span v-for="(stop, index) in gradientStops(shown.stops)" :key="stop.id" class="gradient-stop" role="slider" :data-id="stop.id" :aria-label="`Stop ${index + 1} of ${shown.stops.length}`" :aria-valuemin="0" :aria-valuemax="100" :aria-valuenow="stop.offset" :style="{ '--gradient-offset': stop.offset, '--gradient-color': stop.color }"></span>    </div>    <div class="flex flex-wrap items-center gap-xs">      <button type="button" class="btn btn-sm gradient-add"><svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 8L13 8" /><path d="M8 3L8 13" /></svg>{{ words.add }}</button>      <button type="button" class="btn btn-sm gradient-remove"><svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M3 8L13 8" /></svg>{{ words.remove }}</button>      <button type="button" class="btn btn-sm btn-quiet gradient-reverse"><svg class="icon" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M8 1.6667L8 14.3333" /><path d="M5.6667 6.3298L5.6667 11.45A0.55 0.55 0 0 1 5.1167 12L2.5566 12A0.55 0.55 0 0 1 2.0647 11.204L4.6248 6.0839A0.55 0.55 0 0 1 5.6667 6.3298Z" /><path d="M10.3333 6.3298L10.3333 11.45A0.55 0.55 0 0 0 10.8833 12L13.4434 12A0.55 0.55 0 0 0 13.9353 11.204L11.3752 6.0839A0.55 0.55 0 0 0 10.3333 6.3298Z" /></svg>{{ words.reverse }}</button>    </div>    <div class="gradient-fields">      <fieldset class="gradient-color">        <legend class="mb(6) text-xs font-medium fg-text-muted">{{ words.color }}</legend>        <div class="color-picker" :style="color.properties">          <div class="color-picker-area">            <div class="color-picker-thumb" role="slider" tabindex="0" aria-label="Lightness and chroma" :aria-valuemin="0" :aria-valuemax="100" :aria-valuenow="color.valueNow" :aria-valuetext="color.valueText"></div>          </div>          <span class="swatch swatch-lg color-picker-swatch"></span>          <input type="range" class="slider color-picker-hue" min="0" max="360" :value.attr="color.hue" aria-label="Hue" />          <input type="range" class="slider color-picker-alpha" min="0" max="100" :value.attr="color.alpha * 100" aria-label="Opacity" />          <div class="color-picker-fields">            <select class="select select-sm color-picker-format" aria-label="Format">              <option value="hex" selected>Hex</option>              <option value="rgb">RGB</option>              <option value="oklch">OKLCH</option>            </select>            <input class="input input-sm color-picker-text" :value.attr="color.value" :aria-label="words.color" spellcheck="false" autocomplete="off" />          </div>        </div>      </fieldset>      <div class="flex flex-col gap-md min-w(0)">        <fieldset class="gradient-offset">          <legend class="mb(6) text-xs font-medium fg-text-muted">{{ words.position }}</legend>          <input type="range" class="slider" min="0" max="100" step="1" :value.attr="first.stops[0]!.offset" :aria-label="words.position" />          <input type="number" class="input input-sm w(72)" min="0" max="100" step="0.1" :value.attr="first.stops[0]!.offset" :aria-label="`${words.position}, %`" />        </fieldset>        <fieldset class="gradient-type">          <legend class="mb(6) text-xs font-medium fg-text-muted">{{ words.type }}</legend>          <div class="segmented segmented-sm" role="radiogroup" :aria-label="words.type">            <label v-for="type in types" :key="type" class="segmented-item"><input type="radio" class="segmented-input" :name="`${id}-type`" :value="type" :checked="first.type === type" />{{ words[type] }}</label>          </div>        </fieldset>        <div class="flex flex-wrap items-start gap-lg">          <fieldset class="gradient-angle">            <legend class="mb(6) text-xs font-medium fg-text-muted">{{ words.angle }}</legend>            <div class="dial dial-sm dial-full" role="slider" tabindex="0" :aria-label="words.angle" :aria-valuenow="first.angle" :aria-valuemin="0" :aria-valuemax="360" :aria-valuetext="`${first.angle}°`" :style="{ '--dial-value': shown.angle }">              <span class="dial-value">{{ first.angle }}°</span>              <span class="dial-thumb"></span>            </div>          </fieldset>          <fieldset class="gradient-center">            <legend class="mb(6) text-xs font-medium fg-text-muted">{{ words.center }}</legend>            <input type="number" class="input input-sm w(72)" min="0" max="100" :value.attr="first.center[0]" :aria-label="words.centerX" />            <input type="number" class="input input-sm w(72)" min="0" max="100" :value.attr="first.center[1]" :aria-label="words.centerY" />          </fieldset>        </div>      </div>    </div>    <pre class="code-block gradient-css" :aria-label="words.css">{{ css.text }}</pre>  </div></template>

#클래스

클래스설명
gradient편집기입니다. 미리보기, 정지점 막대, 컨트롤로 구성됩니다. gradient 동작이 정지점의 손잡이를 작성하고 그라데이션을 출력합니다. 변경되지 않게 하려면 aria-readonly="true" 또는 aria-disabled="true"를 지정하세요.
gradient-preview체크무늬 위에 표시되는 그라데이션으로, --gradient-ratio로 지정하지 않으면 16 : 9입니다. 정지점과 CSS가 같은 내용을 전달하므로 aria-hidden으로 숨기세요.
gradient-bar유형과 관계없이 시작부터 끝까지의 정지점을 보여 주는 짧은 오목한 영역으로, 그 위에 손잡이가 놓입니다
gradient-stop동작이 작성하는 정지점의 손잡이입니다. 막대를 따라 --gradient-offset 위치에 진주색 테두리가 있는 정지점 색상의 원으로 표시되며, 위치를 값으로 갖는 슬라이더이고 이름에는 정지점 중 몇 번째인지가 포함됩니다.
gradient-fields컨트롤입니다. 한 열로 배치되며, 공간이 충분하면 두 열로 나란히 배치됩니다.
gradient-color선택한 정지점의 color-picker를 담습니다. gradient 동작이 색상 선택기를 연결합니다.
gradient-offset선택한 정지점의 위치를 0부터 100까지 지정하는 범위 입력과 숫자 입력을 담습니다
gradient-type유형을 고르는 linear, radial, conic 라디오 버튼을 담는 세그먼트 컨트롤입니다
gradient-angle선형 및 원뿔형 그라데이션의 각도를 0도부터 360도까지 지정하는 다이얼을 담습니다
gradient-center방사형 및 원뿔형 그라데이션의 중심 x, y를 백분율로 지정하는 숫자 입력 두 개를 담습니다
gradient-add선택한 정지점의 색상으로 새 정지점을 그보다 10만큼 뒤에, 최대 100 위치에 추가합니다
gradient-remove선택한 정지점을 삭제합니다. 정지점이 두 개일 때는 비활성화됩니다.
gradient-reverse정지점의 순서를 뒤집습니다
gradient-css동작이 작성하는 복사용 CSS입니다. 폴백 다음에 OKLab에서 보간하는 줄이 옵니다.

#사용자 지정 속성

속성기본값설명
--gradientnone동작이 작성하는, OKLab에서 보간한 그라데이션
--gradient-fallbacknone보간 방식을 지정할 수 없는 브라우저를 위한, sRGB에서 보간한 그라데이션
--gradient-bar막대를 칠하는 값으로, 유형과 관계없이 모든 정지점을 시작부터 끝까지 sRGB로 보간한 직선 그라데이션으로 그리며 동작이 작성합니다gradient에 설정합니다
--gradient-ratio미리보기의 비율. 기본값은 16 / 9입니다gradient-preview에 설정합니다
--gradient-offset막대에서 손잡이의 위치로, 0부터 100까지이며 동작이 작성합니다gradient-stop에 설정합니다
--gradient-color손잡이에 해당하는 정지점의 색상으로, 동작이 작성합니다gradient-stop에 설정합니다

#소스

@master/ui/components/gradient.css
/* * Gradient: a gradient being made. A preview of it, a bar of its stops, and the controls of the stop in hand and * of the whole gradient, which are the library's own: a color picker, a range and a number, a segmented * control for the type, a dial for the angle, numbers for the centre. * * What the gradient looks like is its content, not a material: the gradient behavior publishes it as * --gradient (interpolated in OKLab) and --gradient-fallback on the root, and each stop's place and color as * --gradient-offset and --gradient-color on its handle. The stylesheet paints the preview and the bar from * them over a checkerboard, so a stop's opacity shows, and places each handle along the bar. * * The bar is a short pressed track as wide as the gradient; a handle is a disc of its stop's color with a * pearl ring, standing on the bar where its stop is, its middle on the stop. The stop in hand rises and takes an * ink ring; a handle the keys are on draws the focus ring as well. Handles keep their place in the DOM as they * move, so the one in hand never loses focus when it passes another. */@layer components.ui {  .gradient {    --gradient: none;    --gradient-fallback: none;    --gradient-handle: 1.25rem;    --gradient-check: color-mix(in oklab, var(--color-text-strong) 9%, transparent);    container: gradient / inline-size;    display: grid;    gap: 1rem;    min-width: 0;    &[aria-disabled="true"] {      opacity: .6;    }  }  /*   * The preview: the gradient on a face with a large control's corner, over a checkerboard, so transparency   * reads as such. Its size is the page's to give; it keeps a 16 : 9 shape by default.   */  .gradient-preview {    aspect-ratio: var(--gradient-ratio, 16 / 9);    min-height: 0;    border-radius: calc(var(--radius-control-lg) * var(--corner-scale));    corner-shape: var(--corner-shape);    background:      var(--gradient-fallback),      repeating-conic-gradient(var(--gradient-check) 0 25%, transparent 0 50%) 0 0 / 16px 16px,      var(--color-surface-raised);    box-shadow: inset 0 0 0 .5px var(--color-line-image-strong);    @supports (background-image: linear-gradient(in oklab, white, black)) {      background:        var(--gradient),        repeating-conic-gradient(var(--gradient-check) 0 25%, transparent 0 50%) 0 0 / 16px 16px,        var(--color-surface-raised);    }    @media (forced-colors: active) {      forced-color-adjust: none;      outline: 1px solid CanvasText;    }  }  /*   * The bar: the stops from start to end, whatever the type, as a short well. The handles stand on it, half   * a handle in from its ends at 0 and 100, so they never hang outside the gradient. Only a handle takes the   * press, so the bar leaves a finger to scroll the page; each handle reaches 44px on touch itself.   */  .gradient-bar {    position: relative;    /* The stop in hand comes forward within the bar, never over the page around it. */    isolation: isolate;    height: .75rem;    margin-inline: calc(var(--gradient-handle) / 2);    border-radius: 999px;    corner-shape: round;    background:      var(--gradient-bar, var(--gradient-fallback)),      repeating-conic-gradient(var(--gradient-check) 0 25%, transparent 0 50%) 0 0 / 8px 8px,      var(--color-surface-raised);    box-shadow: var(--shadow-pressed);    @media (forced-colors: active) {      forced-color-adjust: none;      outline: 1px solid CanvasText;    }  }  /* A stop's handle: a disc of its color in a pearl ring, its middle on the stop. */  .gradient-stop {    position: absolute;    top: 50%;    inset-inline-start: calc(var(--gradient-offset, 0) * 1%);    width: var(--gradient-handle);    height: var(--gradient-handle);    translate: -50% -50%;    border-radius: 999px;    corner-shape: round;    background: linear-gradient(var(--gradient-color, transparent), var(--gradient-color, transparent)), repeating-conic-gradient(var(--gradient-check) 0 25%, transparent 0 50%) 0 0 / 6px 6px, var(--color-surface-raised);    box-shadow: 0 0 0 2px var(--color-thumb-high), 0 0 0 2.5px var(--color-line-strong), 0 1px 3px 1px var(--color-shade-1), 0 2px 6px var(--color-shade-2);    cursor: grab;    touch-action: none;    -webkit-tap-highlight-color: transparent;    transition-property: box-shadow, scale;    transition-duration: var(--duration-quick);    transition-timing-function: var(--easing-glide);    &:dir(rtl) {      translate: 50% -50%;    }    /* The stop in hand stands a little forward, ringed in ink. */    &[aria-current="true"] {      z-index: 1;      scale: 1.12;      box-shadow: 0 0 0 2px var(--color-thumb-high), 0 0 0 3.5px var(--color-text-strong), 0 2px 6px 1px var(--color-shade-1), 0 4px 10px var(--color-shade-2);    }    &:active {      cursor: grabbing;    }    &:focus-visible {      @apply --focus-ring;      outline-offset: 4px;    }    /* Locked: as heavy as :active, and later, so a press shows no grip either. */    &[aria-disabled="true"] {      cursor: not-allowed;    }    /* On touch the target reaches 44px around the handle, which keeps its size. */    @media (pointer: coarse) {      &::after {        @apply --touch-target;      }    }    @media (prefers-reduced-motion: reduce) {      transition-property: box-shadow;      &[aria-current="true"] {        scale: none;      }    }    @media (forced-colors: active) {      forced-color-adjust: none;      outline: 2px solid ButtonText;      &[aria-current="true"] {        outline-color: Highlight;        outline-width: 3px;      }      /* Opted out of forced colors, the focus ring would keep the theme's ink: it takes the system's own. */      &:focus-visible {        outline-color: Highlight;      }      &[aria-disabled="true"] {        outline-color: GrayText;      }    }  }  /*   * The controls: the stop in hand (its color, its offset, remove and add) and the gradient (its type, angle and   * centre, reverse), in a column that becomes two side by side when the room allows.   */  .gradient-fields {    display: grid;    gap: .75rem 1.25rem;    align-items: start;  }  @container gradient (width >= 34rem) {    .gradient-fields {      grid-template-columns: auto minmax(0, 1fr);    }  }  /* A labelled group of the gradient's controls: a row of a label over its control. */  .gradient-color, .gradient-offset, .gradient-type, .gradient-angle, .gradient-center {    display: grid;    gap: .375rem;    min-width: 0;    margin: 0;    padding: 0;    border: 0;  }  .gradient-offset, .gradient-center {    grid-template-columns: minmax(0, 1fr) auto;    align-items: center;  }  .gradient-add, .gradient-remove, .gradient-reverse {    flex: none;  }  /* The CSS of the gradient, as it is copied: the fallback, then the OKLab line. A code block scrolls it. */  .gradient-css {    min-width: 0;    margin: 0;  }}