Skip to content

Spatial Menu (WIP)

A collection of keyboard-navigable items, that can be displayed in a grid.

Oldboy
Oldboy
Moon
Moon
The Dark Knight
The Dark Knight
The Truman Show
The Truman Show
Gladiator
Gladiator
The Prestige
The Prestige
Interstellar
Interstellar
Drive
Drive
Zootopia
Zootopia
Spirited Away
Spirited Away
Gone Girl
Gone Girl
Prisoners
Prisoners
Arrival
Arrival
The Hunt
The Hunt
Logan
Logan
Get Out
Get Out
Inglourious Basterds
Inglourious Basterds
Captain Fantastic
Captain Fantastic
Three Billboards Outside Ebbing, Missouri
Three Billboards Outside Ebbing, Missouri
Children of Men
Children of Men
Black Dynamite
Black Dynamite
Parasite
Parasite
Marriage Story
Marriage Story
Jojo Rabbit
Jojo Rabbit
Inside Out
Inside Out
Monty Python and the Holy Grail
Monty Python and the Holy Grail
Hereditary
Hereditary
Up
Up
WALL·E
WALL·E
Your Name.
Your Name.
Akira
Akira
Knives Out
Knives Out
Fantastic Mr. Fox
Fantastic Mr. Fox
Portrait of a Lady on Fire
Portrait of a Lady on Fire
The Lighthouse
The Lighthouse
Monsters, Inc.
Monsters, Inc.
Django Unchained
Django Unchained
Kill Bill: Vol. 2
Kill Bill: Vol. 2
Kill Bill: Vol. 1
Kill Bill: Vol. 1
Sound of Metal
Sound of Metal
The Fly
The Fly
Minari
Minari
Soul
Soul
Princess Mononoke
Princess Mononoke
Spider-Man: No Way Home
Spider-Man: No Way Home
Dead Poets Society
Dead Poets Society
Oppenheimer
Oppenheimer
The Substance
The Substance
Schindler's List
Schindler's List
Fight Club
Fight Club
Eternal Sunshine of the Spotless Mind
Eternal Sunshine of the Spotless Mind
Into the Wild
Into the Wild
Short Term 12
Short Term 12
Whiplash
Whiplash
Shutter Island
Shutter Island
Black Swan
Black Swan
The Wave
The Wave
Se7en
Se7en
The Intouchables
The Intouchables
Pan's Labyrinth
Pan's Labyrinth
Ex Machina
Ex Machina
John Wick
John Wick
Hacksaw Ridge
Hacksaw Ridge
The Skin I Live In
The Skin I Live In
The Shining
The Shining
Memento
Memento
Blade Runner
Blade Runner
Blade Runner 2049
Blade Runner 2049
Annihilation
Annihilation
Lady Bird
Lady Bird
The Big Sick
The Big Sick
Spider-Man: Into the Spider-Verse
Spider-Man: Into the Spider-Verse
Iron Man
Iron Man
Hell or High Water
Hell or High Water
Love, Simon
Love, Simon
Snowpiercer
Snowpiercer
The Incredibles
The Incredibles
Spider-Man: Homecoming
Spider-Man: Homecoming
Bacurau
Bacurau
The Girl with the Dragon Tattoo
The Girl with the Dragon Tattoo
Coraline
Coraline
Hunt for the Wilderpeople
Hunt for the Wilderpeople
Klaus
Klaus
Coherence
Coherence
Coco
Coco
The Butterfly Effect
The Butterfly Effect
The Matrix
The Matrix
Nightcrawler
Nightcrawler
The Father
The Father
The Thing
The Thing
Everything Everywhere All at Once
Everything Everywhere All at Once
Moneyball
Moneyball
Nope
Nope
Judas and the Black Messiah
Judas and the Black Messiah
Puss in Boots: The Last Wish
Puss in Boots: The Last Wish
The Notebook
The Notebook

Props


  • 💪 It works

TODO

Constructor Props

The props that are passed when calling
new SpatialMenu()
    export type SpatialMenuProps<T> = {
    /**
    * The currently highlighted value.
    */
    highlighted?: MaybeGetter<T | null | undefined>;
    /**
    * Called when the highlighted value changes.
    */
    onHighlightChange?: (highlighted: T | null) => void;
    onSelect?: (value: T) => void;
    /**
    * Whether navigation should wrap around when reaching the edges.
    * @default false
    */
    wrap?: MaybeGetter<boolean>;
    /**
    * Scroll behavior when highlighting an item with the keyboard.
    * `null` to disable scrolling.
    *
    * @default "smooth"
    */
    scrollBehavior?: MaybeGetter<"smooth" | "instant" | "auto" | null>;
    /**
    * The maximum distance a the centerX of an item can be in relation
    * to the highlighted item when navigating vertically with the keyboard.
    *
    * Set to `null` to disable.
    *
    * @default null
    */
    maxDistanceX?: MaybeGetter<number | null>;
    /**
    * The maximum distance a the centerY of an item can be in relation
    * to the highlighted item when navigating horizontally with the keyboard.
    *
    * Set to `null` to disable.
    *
    * @default 16
    */
    maxDistanceY?: MaybeGetter<number | null>;
    };

Methods

The methods returned from
new SpatialMenu()
  • getItem

    (
    value: T,
    options?: Pick<SpatialMenuItemProps<T>, "onSelect"> | undefined,
    ) => SpatialMenuItem<T>

Properties

The properties returned from
new SpatialMenu()
  • onSelect

    ((value: T) => void) | undefined
  • wrap

    boolean
  • scrollBehavior

    "auto" | "smooth" | "instant" | null
  • maxDistanceX

    number | null
  • maxDistanceY

    number | null
  • selectionMode

    "keyboard" | "mouse"
  • highlighted

    T | null
  • root

    {
    readonly [x: symbol]: (node: HTMLElement) => () => void
    readonly "data-melt-spatial-menu-root": ""
    readonly tabindex: 0
    readonly onkeydown: (e: KeyboardEvent) => void
    }
    The root element.
  • input

    {
    readonly [x: symbol]: (node: HTMLInputElement) => () => void
    readonly "data-melt-spatial-menu-input": ""
    readonly onkeydown: (e: KeyboardEvent) => void
    }