DropIndicator
A thin bar rendered in the gap between two items of a reorderable list, marking where a dragged item will land.
- 1. Lint and typecheck
Runs on CI
- 2. Unit and integration tests
Runs on CI
- 3. Run pending migrations
Runs on Platform
- 4. Deploy to production
Runs on Platform
View code
let session = new DragSession();
let steps = [...STEPS];
// ref() fires on insert, so the subscription is set up in the browser and torn
// down with the node — the server renders the list without one.
let followDrag = ref((_node, signal) => {
session.addEventListener("change", () => void handle.update(), { signal });
});
function isGapActive(stepId: string, side: "before" | "after") {
return session.target?.key === stepId && session.target.position === side;
}
<div mix={[followDrag]}>
<Header>Release checklist</Header>
<Badge color="neutral">{session.active ? "Dragging" : "Drag a grip"}</Badge>
<ol
mix={[
// A pointer drag over text would select it instead, so the list opts out.
userSelect("none"),
dragReorder(session),
on<HTMLOListElement, "ui:reorder">("ui:reorder", (event) => {
steps = reorder(steps, event.sourceKey, event.targetKey, event.position, (s) => s.id);
void handle.update();
}),
]}
>
{steps.map((step, index) => (
<li key={step.id} data-rmx-key={step.id}>
{/* One bar per gap: the first row opens the list, and every row closes its own gap. */}
{index === 0 ? <DropIndicator isDropTarget={isGapActive(step.id, "before")} /> : null}
<Item>
<Item.Media>
<button
type="button"
data-drag-handle
aria-label={`Reorder ${step.name}`}
mix={[cursor("grab"), touchAction("none")]}
>
<GripVerticalIcon />
</button>
</Item.Media>
<Item.Content>
<Item.Title>
{index + 1}. {step.name}
</Item.Title>
<Item.Description>Runs on {step.owner}</Item.Description>
</Item.Content>
</Item>
<DropIndicator isDropTarget={isGapActive(step.id, "after")} />
</li>
))}
</ol>
</div>Demo apps
Whole pages built only from @sdxc/ui, each for an invented product with its own palette and type. They open in a new tab.
- Food deliveryBocadoBocado, an invented food delivery app: restaurants by cuisine and delivery time, search with filters, menus with options, a cart, checkout and live order tracking on a drawn map./showcase/bocado/demo
- Issue trackerCairnCairn, an invented issue tracker: grouped issue lists with filters in the address, a drag-and-drop board, projects on a roadmap, cycles with burn-up charts and an inbox./showcase/cairn/demo
- Social networkChorusChorus, an invented social network: a live timeline with pictures, link cards, polls and threads, profiles, grouped notifications, search and messages./showcase/chorus/demo
- Code hostDeltaDelta, a code host whose one repository is its own source: a file tree beside the code, line links, blame and the commits list, every file and commit read from git when the site is built./showcase/delta/demo
- Online storeHangwellHangwell, an invented poster shop: collections with facet filters, product pages with format, size and frame pickers and a room preview, a bag, a checkout that adapts to print files, order tracking, downloads and returns./showcase/hangwell/demo
- CMSInkwellInkwell, a demo CMS built from @sdxc/ui/app: posts with count tabs and quick edit, an editor with a quiet save status and a loud Publish, media and settings./showcase/inkwell/demo
- Music streamingMurmurMurmur, an invented music service: home shelves, search by genre, a library, albums, playlists and artists, with a player that keeps playing while you browse./showcase/murmur/demo
- Team chatParleyParley, an invented team chat: channels and direct messages with unread and mention badges, threads, reactions, edits, pins, search, a quick switcher and teammates who type and post live./showcase/parley/demo
- Photo and video networkPinholePinhole, an invented social network for photographs and short videos: a feed under a story tray, full-screen stories, a vertical reels feed, profiles with highlights, Explore and posts with comments./showcase/pinhole/demo
- Ops dashboardPulsePulse, an invented ops dashboard: Northwind's services with live filters, a peek sheet and a bulk bar, metrics that switch one chart, incidents, deploys and settings./showcase/pulse/demo
- Support inboxRelayRelay, an invented support inbox: mailboxes, conversations and the open conversation on one screen, with contacts, reports and settings./showcase/relay/demo
- CalendarSundialSundial, an invented calendar: day, week and month views, an agenda, events you drag, resize and create on the grid, a second time zone, and a find-a-time view across a team in five zones./showcase/sundial/demo
- Chat assistantTernTern, an invented chat assistant: conversations with streamed replies, code and tables, projects, a canvas, sharing and settings./showcase/tern/demo
- Banking & budgetsTuppenceTuppence, an invented personal bank: multi-currency accounts, a statement by day with search and splits, spending and budgets, savings pots, bills ahead, cards that freeze and a transfer flow, all with fake money./showcase/tuppence/demo
- Streaming serviceVesperVesper, an invented streaming service: profiles, a home of sideways shelves under a billboard, series with seasons and episodes, search, My List and a theater player./showcase/vesper/demo
- Travel bookingWayfernWayfern, an invented travel app: stays, flights, cars and packages from one search, results on a real map, seat maps and boarding passes, and one itinerary of trips that exports to calendars./showcase/wayfern/demo
Every demo, landings and docs sites alike, is listed in the showcase.
Installation
An ordinary dependency: install it, import the theme once, and import the component where it is used.
npm add @sdxc/ui remiximport "@sdxc/ui/theme.css";Usage
import { DropIndicator } from "@sdxc/ui/app";Renders a full-width, hairline-thick, fully rounded bar shaped for the gap
between two items in a reorderable list. The host's data-drop-target
attribute is what paints it: transparent without it, the primary solid color
with it.
Examples
Overlaid on a row edge
View code
let tasks = [
{ id: "notes", label: "Write release notes" },
{ id: "ship", label: "Ship 2.0" },
{ id: "announce", label: "Announce on the blog" },
];
let dropTargetKey = "ship";
<div role="list" aria-label="Launch tasks" mix={[vstack({ gap: 2, align: "stretch" })]}>
{tasks.map((task) => (
<div
key={task.id}
role="listitem"
mix={[relative(), pi(3), pb(2), rounded("md"), border({ color: "neutral.border", width: 1 }), text("sm")]}
>
<DropIndicator
isDropTarget={task.id === dropTargetKey}
mix={[absolute(), insIs(0), insBs("-0.0625rem")]}
/>
{task.label}
</div>
))}
</div>Props
Read from the component's own types, so every prop, every default and every allowed value is listed.
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
isDropTarget | boolean | — | No | Whether this bar marks the pointer's current drop target. Renders the host's data-drop-target attribute when true, which is what draws the bar. Defaults to DEFAULT_IS_DROP_TARGET. |
Also accepts everything in TagProps<"div">.