Resizable Split PaneLoading saved progress…

Resizable Split Pane

A split pane lets someone give more room to one of two adjacent regions. Build the React version with a pointer-draggable, keyboard-operable separator whose left-pane percentage stays between 20 and 80.

Signature

Implement the App component in App.tsx. It receives no props and starts with the Editor and Preview panes at 50% / 50%.

Examples

  • Dragging the separator right updates both the pane width and label; a raw 92% position stops at 80% / 20%.
  • Releasing the pointer anywhere ends the drag because pointermove and pointerup live on window only for the active drag.
  • With the separator focused, ArrowLeft or ArrowDown subtracts one point, while ArrowRight or ArrowUp adds one.
  • Home moves directly to 20% / 80%; End moves to 80% / 20%.

Notes

  • One state value. Keep leftPct in useState; pane width, visible label, and aria-valuenow must all read that value.
  • Pointer math. Measure the split with its ref, compute Math.round((clientX - rect.left) / rect.width * 100), then clamp to 20..80.
  • Window lifecycle. Add pointermove and pointerup on pointerdown and remove those exact function references on pointerup. The active class supplies the resize affordance.
  • Keyboard contract. Prevent default for the six handled keys and pass pointer and keyboard results through the same clamp.
  • Accessible separator. Keep the provided role="separator", vertical orientation, focusability, controlled pane IDs, min/max, and live value attributes synchronized.
  • Starting shell. Markup, persistent CSS, initial state, and empty handlers are provided. Complete the state transitions and listener lifecycle.
WE’RE LISTENING

Help make UIReady better

Found a bug or have an idea? Tell us about it.

Up to 3 files · 5 MiB each · JPG, PNG, WebP, MP4, WebM, MP3, M4A or WAV