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
selectStopindex: numberEmitted when a stop is selected.
dragStopindex: number, position: numberEmitted while a stop is dragged.

Slots

SlotPropsDescription
defaultbar 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.