← Examples Gallery

Placement Demo

Alap uses a compass-based placement engine. Click any link to see the menu appear in the specified direction. When a preferred placement doesn't fit, the engine falls back automatically.

1. DOM Adapter — Compass Rose

Each link requests a specific direction. With the trigger centered on the page, every placement fits.

NW
N
NE
W
C
E
SW
S
SE

2. Web Component — Compass Rose

Same compass grid using <alap-link> with the placement attribute.

NW
N
NE
W
C
E
SW
S
SE

3. Inline Text — Natural Flow

Placement works with inline text. Here the menu opens above (N), below (S), beside (E), or centered (C) over the trigger word. Here's a long menu inline with 20 items that should clamp without scrolling the page.

Stress Tests

Edge cases that exercise the fallback and clamping logic. Each test has a scroll to position link that puts the trigger at the viewport edge so you can see the fallback in action.

4. Horizontal Edge Flips

Links at the viewport edges. E on the right should flip to W; W on the left should flip to E.

Scroll to test position ↓

W ← wants left, no room wants right, no room → E

Same test with the web component:

W ← should flip E should flip W → E

5. Vertical Edge Flips — Top of Viewport

These links want to go above, but there's no room. Scroll so the row is at the very top of the viewport, then click.

Scroll to test position ↓

N ↑ no room above  —  NW no room above  —  NE no room above

6. Corner Stress Tests

Links pinned to each corner. Every placement requested is the worst possible for that corner.

Scroll to test position ↓

NW in top-left NE in top-right SW in bottom-left SE in bottom-right

7. Long Menu — Height Clamping

20 items. The menu can't fit fully — it should clamp to available space and scroll internally. No page scroll.

Scroll to test position ↓

SE (default below)

20 items (SE)

N (above)

20 items (N)

C (centered)

20 items (C)

E (beside)

20 items (E)

8. Long Menu Near Bottom of Viewport

A long menu near the bottom. SE overflows massively — should flip above or clamp. Scroll so the links are near the bottom of your viewport, then click.

Scroll to test position ↓ — the links should be near the bottom of your viewport after scrolling.

20 items, SE  —  20 items, S  —  20 items, SE (web component)  —  20 items, C

9. Right Edge — Forced Flips

Links pinned flush against the right viewport edge. SE and E have no room to the right.

Scroll to test position ↓

SE flush right E flush right (20 items) NE flush right E flush right (WC, 20 items)