Skip to content

GradientEditorBar ​

GradientEditorBar is the draggable bar primitive used inside gradient editors.

Props ​

PropDefaultType
stops*
Current gradient stops.
—GradientStop[]
activeStopIndex*
Active stop index.
—number
barBackground*
CSS background string for the bar.
—string

Events ​

EventPayloadDescription
selectStop
Emitted when a stop is selected.
index: numberEmitted when a stop is selected.
dragStop
Emitted while a stop is dragged.
index: number, position: numberEmitted while a stop is dragged.

Slots ​

SlotPropsDescription
default
Full gradient bar render contract.
bar state + drag handlersFull gradient bar render contract.

Default slot props ​

ts
{
  stops: GradientStop[]
  activeStopIndex: number
  barBackground: string
  barRef: (el: unknown) => void
  onStopPointerDown: (index: number, event: PointerEvent) => void
  onPointerMove: (event: PointerEvent) => void
  onPointerUp: () => void
  draggingIndex: number | null
}

Example ​

vue
<GradientEditorBar
  :stops="stops"
  :active-stop-index="activeStopIndex"
  :bar-background="barBackground"
  @select-stop="selectStop"
  @drag-stop="dragStop"
  v-slot="ctx"
>
  <MyGradientBar v-bind="ctx" />
</GradientEditorBar>

Released under the MIT License.