Position picker

Where something goes in a box: a corner, an edge, the middle. A small picture of the box, a spot at each place it can go.

Corners

The default: the four corners. The picked one is drawn as a block in its place.

top-right
<script lang="ts">
	import { PositionPicker, type Position } from '@kystdata/ui';
	let legend = $state<Position>('top-right');
</script>

<PositionPicker bind:value={legend} aria-label="Legend position" />

Any of the nine

Edges are drawn as bars, the middle as a dot. Pass the places that make sense and names where needed.

All nine
Corners and a band
Disabled
<PositionPicker
	bind:value={title}
	positions={[...CORNERS, 'top']}
	labels={{ top: 'Band across the top' }}
	aria-label="Title position"
/>

Rules

  • For where a piece goes inside something: a legend on a map, a caption on an image, a badge on a card. Not for alignment of text, which is a segmented control.
  • Offer the places that make sense, not all nine. A legend goes in a corner; a band goes along an edge.
  • Name a place by what it does when its position doesn’t say it: "Band across the top", not "Top".
  • Put it beside the field it places, on the same row, so the two read as one setting.
  • The choice applies at once. Arrow keys move between the spots as they lie.