グラデーション
作成中のグラデーション。バー上のカラーストップ、カラーピッカーで編集中のストップ、種類、角度、中心を扱います。
このページの内容
グラデーションエディターでは、グラデーションを作成します。バー上にカラーストップを並べ、編集中のストップの色をカラーピッカーで選び、種類、角度、中心を設定します。中のコントロールはすべてこのライブラリーのものです。カラーピッカー、ストップの位置を指定するスライダーと数値入力、種類を選ぶセグメントコントロール、角度を指定するダイヤル、中心を指定する数値入力です。グラデーションが加えるのは、ストップを並べたバー、プレビュー、そしてこれらすべてを同期させる 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>#値
グラデーションは 4 つの部分からなる値です。
| 部分 | 内容 |
|---|---|
type | linear、radial、conic のいずれか |
angle | 角度(度)。線形と円錐形のグラデーションで使います |
center | 2 つのパーセント値。放射状と円錐形のグラデーションで使います |
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 を保ち、そのハンドルはフォーカスを保ちます。グラデーションは位置の順に描画されます。同じ位置にある 2 つのストップは境界のはっきりした色の切り替わりになり、順序は保たれます。
- 追加すると、編集中のストップの 10 ポイント後ろ(最大 100)に、同じ色のストップが加わります。ボタンまたは Delete で削除すると、バー上の次のストップに、なければ前のストップにフォーカスが移ります。ストップは最低 2 つ必要で、2 つのときは削除が無効になります。
- 反転すると、ストップの並びが逆になります。各位置は 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 | バー上の編集中のストップに移動し、続けてコントロールを移動します。ほかのストップには、ポインターで編集対象にするか、バーのタブ順序にあるそれぞれの位置から移動します |
| ArrowRight, ArrowUp | ストップ上:終点の方向に 1 ポイント移動します。Shift キーを押すと 10 ポイントです。右から左へ書くページでは、ArrowRight で左に移動します |
| ArrowLeft, ArrowDown | ストップ上:始点の方向に 1 ポイント移動します。Shift キーを押すと 10 ポイントです |
| PageUp, PageDown | ストップ上:10 ポイント移動します |
| Home, End | ストップ上:0 または 100 に移動します |
| Delete, Backspace | ストップ上:ストップが 3 つ以上あれば削除し、隣のストップにフォーカスを移します |
#アクセシビリティ
- 各ハンドルには、ストップの中での順番を含む名前を付け、
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 | コントロール。1 列に並び、余裕があれば 2 列で横に並びます |
gradient-color | 編集中のストップの color-picker を保持します。gradient ビヘイビアがピッカーを適用します |
gradient-offset | 編集中のストップの位置を 0 から 100 で指定する、範囲スライダーと数値入力を保持します |
gradient-type | 種類(linear、radial、conic)を選ぶラジオボタンを保持します。セグメントコントロールです |
gradient-angle | 線形と円錐形のグラデーションで使う、0 から 360 度の角度のダイヤルを保持します |
gradient-center | 放射状と円錐形のグラデーションで使う、中心の x と y をパーセントで指定する 2 つの数値入力を保持します |
gradient-add | 編集中のストップの 10 ポイント後ろ(最大 100)に、同じ色のストップを追加します |
gradient-remove | 編集中のストップを削除します。ストップが 2 つのときは無効です |
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 |
#関連項目
- カラーピッカー明度とクロマのフィールド、色相、不透明度で選ぶか、入力して指定する任意の色。
- ダイヤル円周に沿ってつまみを回して値を設定します。ノブのように調整するレベル、角度、方向などに。
- スライダー細くくぼんだトラックに、真珠調のつまみを備えたネイティブの範囲入力。
- セグメントコントロールくぼんだトラックに少数の選択肢を並べ、選択された項目へハイライトが滑らかに移動します。
- スウォッチ色の表示や選択に使う、縁取りのある円形の色見本です。