Skip to main content

UI System

Hyperscape’s UI system features anchor-based positioning (Unity/Unreal-style), accessible drag-and-drop with @dnd-kit, responsive scaling for mobile ↔ desktop transitions, and customizable layouts.
UI code lives in packages/client/src/ui/ with core systems in src/ui/core/.

Architecture


Anchor-Based Positioning

Windows maintain their position relative to a viewport anchor point (corner, edge, or center) instead of absolute pixel positions. This ensures windows stay attached to their intended viewport edges when resizing between any screen sizes.

WindowAnchor Type

Anchor Utilities

Default Anchors


Responsive Scaling

Mobile ↔ Desktop Transitions

The UI handles transitions between mobile and desktop layouts:

Viewport Size Persistence

Window layouts are saved with viewport size for proper scaling:

Drag-and-Drop System

The UI uses @dnd-kit for accessible drag-and-drop with keyboard and pointer support.

Core Hooks

Collision Detection

Available Algorithms:
  • pointerWithin — Pointer must be inside drop zone
  • closestCenter — Closest drop zone by center distance
  • rectIntersection — Bounding box overlap

Accessibility Features


Window Management

Window State

Window Operations

Tab Combining

Windows support tab combining via drag-and-drop:

Layout Presets

Preset System

Cloud Sync


Edit Mode

The UI includes an edit mode for layout customization:

Alignment Guides


Theme System

Theme Store

Dark Theme

The default theme uses a dark color scheme with gold accents:

Responsive Breakpoints


Action Bar

The action bar supports 4-12 customizable slots with drag-and-drop:

Draggable Combat Styles

Combat styles can be dragged to the action bar:
Combat Style Icons: Each style has a unique SVG icon with active state colors:

Drag-and-Drop API

DndProvider

useDraggable

useDroppable

Drag Overlay


Window Resize Handling

useViewportResize Hook


Accessibility

Keyboard Navigation

All interactive UI elements support keyboard navigation:

ARIA Labels


Performance Optimizations

Memoization

useCallback