# Glide

One highlight per list that glides from row to row: menus, pickers, trays and a palette.

Live variants: https://design.arcadia.is/components/glide

```tsx
import { Glide } from "@arcadia/ui";
```

Move the pointer over the rows, or focus the list and use the arrows.

```tsx
import { useState } from "react";
import { Glide, ListRow } from "@arcadia/ui";

function Picker() {
  const [active, setActive] = useState(0);
  const onKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {
    const step = e.key === "ArrowDown" ? 1 : e.key === "ArrowUp" ? -1 : 0;
    if (!step) return;
    e.preventDefault();
    setActive((i) => (i + step + COMMANDS.length) % COMMANDS.length);
  };
  return (
    <div
      {...sx("cmp-rows", cmp.rows, cmp.rowsWide)}
      data-width="wide"
      role="listbox"
      aria-label="Commands"
      tabIndex={0}
      aria-activedescendant={`glide-${COMMANDS[active]!.id}`}
      onKeyDown={onKeyDown}
    >
      <Glide />
      {COMMANDS.map((c, i) => (
        <ListRow
          key={c.id}
          id={`glide-${c.id}`}
          role="option"
          aria-selected={i === active}
          tabIndex={-1}
          leading={c.icon}
          label={c.label}
          description={c.description}
          emphasis
          highlighted={i === active}
          onPointerMove={() => setActive(i)}
        />
      ))}
    </div>
  );
}
```

## Accessibility

The glide is decoration: an `aria-hidden` span with no role and no focus. The list states the highlight itself, through `aria-activedescendant`, `aria-selected` or focus, so assistive tech never depends on it.

Under reduced motion it jumps to the next row instead of gliding; the short fade stays. In forced colours it draws a `Highlight` outline, since system colours replace its fill.

- ↑ ↓: In the example, move the highlight; the glide follows

## API reference

### Glide

- `items` (`string`, default `".ui-menu-item, .ui-row, .ui-tray-option"`): The rows it lands on: a selector matched inside the list. Default: menu items, list rows and tray options.
- `target` (`(list: HTMLElement, fallback: HTMLElement | null) => HTMLElement | null | undefined`): Picks the lit row where the default doesn't fit. Return a row, `null` for none, or `undefined` to fall back to the default: the row under the pointer when the pointer moved last, otherwise the row with `data-highlighted`, otherwise the row with keyboard focus. The second argument is that default row, so a navigation list can preserve it and supply its selection at rest.
- `fresh` (`string | number`): Changed when the rows are new: the next light lands whole, no glide, no fade.
- `rootStyle` (`RootStyle<GlideKnobs>`): Typed StyleX override: layout and the movement knobs.
