그라데이션
그라데이션을 만드는 편집기입니다. 막대에서 색상 지점의 위치를 조절하고, 색상 선택기에서 선택한 지점의 색상을 바꾸고, 유형·각도·중심을 설정합니다.
이 페이지의 내용
그라데이션 편집기는 그라데이션을 만듭니다. 막대 위에 색상 지점을 배치하고, 선택한 지점의 색상을 색상 선택기에 표시하며, 유형, 각도, 중심을 설정합니다. 편집기 안의 모든 컨트롤은 라이브러리의 컴포넌트입니다. 색상 선택기, 색상 지점의 위치를 정하는 슬라이더와 숫자 입력, 유형을 고르는 세그먼트 컨트롤, 각도를 정하는 다이얼, 중심을 정하는 숫자 입력으로 구성됩니다. 편집기는 여기에 색상 지점을 표시하는 막대와 미리보기를 더하고, 이 모두를 동기화하는 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>#값
그라데이션은 네 부분으로 이루어진 값입니다.
| 부분 | 내용 |
|---|---|
type | linear, radial, conic 중 하나 |
angle | 선형 및 원뿔형 그라데이션의 각도(도) |
center | 방사형 및 원뿔형 그라데이션의 중심을 나타내는 두 백분율 |
stops | 각 색상 지점에 고정된 id, 0부터 100까지의 offset, color가 있습니다. |
색상은 색상 선택기가 작성하는 방식대로 불투명도를 포함한 sRGB 16진수로 작성합니다. gradientCss(value)는 그라데이션을 CSS로 작성하며, 미리보기와 복사되는 텍스트 모두 이 함수에서 나옵니다. 브라우저에 보간 색 공간을 지정할 수 있으면 OKLab에서 보간하고, 지정할 수 없는 브라우저를 위해 그 앞에 폴백을 둡니다.
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"를 지정하면 편집기가 비활성 상태로 표시됩니다. 손잡이는 제자리에 머물고 컨트롤은 비활성화됩니다.
#동작
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에서 확인할 수 있습니다.
#클래스
| 클래스 | 설명 |
|---|---|
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에서 보간하는 줄이 옵니다. |
#사용자 지정 속성
| 속성 | 기본값 | 설명 |
|---|---|---|
--gradient | none | 동작이 작성하는, OKLab에서 보간한 그라데이션 |
--gradient-fallback | none | 보간 방식을 지정할 수 없는 브라우저를 위한, sRGB에서 보간한 그라데이션 |
--gradient-bar | 막대를 칠하는 값으로, 유형과 관계없이 모든 정지점을 시작부터 끝까지 sRGB로 보간한 직선 그라데이션으로 그리며 동작이 작성합니다gradient에 설정합니다 | |
--gradient-ratio | 미리보기의 비율. 기본값은 16 / 9입니다gradient-preview에 설정합니다 | |
--gradient-offset | 막대에서 손잡이의 위치로, 0부터 100까지이며 동작이 작성합니다gradient-stop에 설정합니다 | |
--gradient-color | 손잡이에 해당하는 정지점의 색상으로, 동작이 작성합니다gradient-stop에 설정합니다 |
#관련 항목
- 색상 선택기영역에서 명도와 채도를 고르고 색상과 불투명도를 조절하거나, 색을 직접 입력할 수 있습니다.
- 다이얼원을 따라 손잡이를 돌려 값을 정합니다. 노브처럼 조절하는 레벨, 각도, 방향 등에 씁니다.
- 슬라이더얇은 오목한 영역에 진주빛 손잡이를 배치한 네이티브 범위 입력 요소입니다.
- 세그먼트 컨트롤하나의 오목한 영역에 몇 가지 옵션을 배치하고, 솟아오른 표면이 현재 옵션으로 부드럽게 이동합니다.
- 색상 견본가장자리를 섬세하게 다듬은 원형 견본으로 색상을 표시하거나 선택할 수 있습니다.