Menu

Navigation menu item component with routing support, focus management, and remote control interaction.

Import

import { Menu } from '@smart-tv/ui';

Basic Usage

Create a simple menu item with click handler.

<Menu
focusKey="home-menu"
onEnterPress={() => console.log('Home selected')}
>
Home
</Menu>

With Navigation (href)

Menu items can navigate to routes using the href prop. This integrates with your router automatically.

<Menu
focusKey="movies-menu"
href="/movies"
>
Movies
</Menu>
<Menu
focusKey="shows-menu"
href="/shows"
>
TV Shows
</Menu>

External Links

Open external links in a new window with target and rel props.

<Menu
focusKey="external-menu"
href="https://example.com"
target="_blank"
rel="noopener noreferrer"
>
External Site
</Menu>

Styled Menu Items

Customize menu appearance and focus states.

<Menu
focusKey="styled-menu"
className="px-4 py-3 text-gray-700 dark:text-gray-200"
active="bg-blue-500 text-white font-bold"
href="/profile"
>
Profile
</Menu>

Menu with Icons

Include icons or other elements within menu items.

<Menu
focusKey="settings-menu"
className="flex items-center gap-3 px-4 py-3"
active="bg-blue-500 text-white"
href="/settings"
>
<SettingsIcon />
<span>Settings</span>
</Menu>

Render Props Pattern

Dynamically render menu content based on focus state.

<Menu
focusKey="dynamic-menu"
href="/movies"
>
{({ focused }) => (
<div className={`flex items-center gap-2 ${focused ? 'text-blue-500' : ''}`}>
{focused && '▶'}
<span>Movies</span>
</div>
)}
</Menu>

Mouse Hover Support

Enable hover support for hybrid TV/web apps.

<Menu
focusKey="hover-menu"
hover={true}
href="/search"
>
Search
</Menu>

Props

PropTypeDefaultDescription
focusKeystring-Required. Unique identifier for navigation
hrefstring-URL to navigate to on Enter press
targetstring-Link target (_blank, _self, etc.)
relstring-Link relationship (noopener, etc.)
onEnterPressfunction-Called when Enter/OK is pressed
onEnterReleasefunction-Called when Enter/OK is released
onFocusfunction-Called when menu receives focus
onBlurfunction-Called when menu loses focus
onArrowPressfunction-Called when arrow keys are pressed
classNamestring-CSS classes for the menu
activestring-CSS classes when focused
disabledbooleanfalseDisable menu interactions
hoverbooleanfalseEnable mouse hover support
payloadany-Data passed to event handlers
childrenReactNode | function-Menu content or render function

Best Practices

  • Use unique focusKey values for each menu item
  • Provide clear visual feedback with the active prop
  • Use href for navigation to integrate with your router
  • Group related menu items in a Navbar or Sidebar component
  • Make menu items large enough for easy remote control selection (min 48px height)