2026-03-24 20:24:08 +00:00
|
|
|
|
---
|
|
|
|
|
|
title: GradientEditorStop
|
2026-07-13 20:41:04 +00:00
|
|
|
|
description: Accessible primitive for a selected or draggable gradient stop.
|
2026-03-24 20:24:08 +00:00
|
|
|
|
---
|
|
|
|
|
|
|
2026-07-13 20:41:04 +00:00
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
|
import { data } from './gradient-editor-stop.data'
|
|
|
|
|
|
</script>
|
2026-03-24 20:24:08 +00:00
|
|
|
|
|
2026-07-13 20:41:04 +00:00
|
|
|
|
# GradientEditorStop
|
2026-03-24 20:24:08 +00:00
|
|
|
|
|
2026-07-13 20:41:04 +00:00
|
|
|
|
`GradientEditorStop` renders a polymorphic gradient stop with documented selection and dragging
|
|
|
|
|
|
state. Interactive stops use the slider role and expose their percentage position through ARIA.
|
2026-03-24 20:24:08 +00:00
|
|
|
|
|
2026-07-13 20:41:04 +00:00
|
|
|
|
Use interactive stops on the gradient bar. Arrow keys nudge by `positionStep`; holding Shift uses a
|
|
|
|
|
|
10× step. Home and End move to either boundary, while Delete and Backspace emit `remove` when the
|
|
|
|
|
|
stop is removable. Handled keys stop propagation so editor-level deletion and movement shortcuts
|
|
|
|
|
|
do not run. Native Tab order cycles between stops.
|
2026-03-24 20:24:08 +00:00
|
|
|
|
|
2026-07-13 20:41:04 +00:00
|
|
|
|
Set `interactive="false"` when reusing the primitive around a composite stop row. The row still
|
|
|
|
|
|
exposes slot actions and `data-selected`/`data-dragging`, but does not enter the slider tab order.
|
2026-03-24 20:24:08 +00:00
|
|
|
|
|
2026-07-13 20:41:04 +00:00
|
|
|
|
```vue twoslash
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
|
import type { GradientStop } from '@open-pencil/scene-graph'
|
|
|
|
|
|
import { GradientEditorStop } from '@open-pencil/vue'
|
2026-03-24 20:24:08 +00:00
|
|
|
|
|
2026-07-13 20:41:04 +00:00
|
|
|
|
const stop: GradientStop = {
|
|
|
|
|
|
color: { r: 0.4, g: 0.2, b: 0.9, a: 1 },
|
|
|
|
|
|
position: 0.5
|
2026-03-24 20:24:08 +00:00
|
|
|
|
}
|
2026-07-13 20:41:04 +00:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
|
<GradientEditorStop
|
|
|
|
|
|
:stop="stop"
|
|
|
|
|
|
:index="0"
|
|
|
|
|
|
active
|
|
|
|
|
|
label="Middle gradient stop"
|
|
|
|
|
|
@update-position="(_index, position) => console.log(position)"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</template>
|
2026-03-24 20:24:08 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-07-13 20:41:04 +00:00
|
|
|
|
## Generated API reference
|
2026-03-24 20:24:08 +00:00
|
|
|
|
|
2026-07-13 20:41:04 +00:00
|
|
|
|
<SdkComponentAPI :components="data.components" />
|
2026-03-24 20:24:08 +00:00
|
|
|
|
|
|
|
|
|
|
## Related APIs
|
|
|
|
|
|
|
|
|
|
|
|
- [GradientEditorRoot](./gradient-editor-root)
|
|
|
|
|
|
- [GradientEditorBar](./gradient-editor-bar)
|
2026-07-13 20:41:04 +00:00
|
|
|
|
- [useColorModel](../composables/use-color-model)
|