React-Planet: Build Circular & Orbital Navigation Menus
Semantic core (clustered keywords)
Below is an expanded semantic core derived from the provided seed keywords. Use these naturally through headings, code captions and alt text.
Main clusters
- react-planet, react-planet installation, react-planet setup, react-planet getting started, react-planet tutorial, react-planet example, react-planet customization
- React circular menu, React circular navigation menu, React circular UI, React orbital navigation, React planet menu, React floating menu
- React navigation component, React navigation patterns, radial menu React, orbital menu React
Secondary / LSI / modifiers
- radial menu, circular nav, orbital UI, floating menu, ring navigation
- radius, rotation, items, children, props, callback, onOpen, onClose, animation, ease-in-out
- npm package, GitHub repo, demo, code example, accessibility, keyboard navigation, SSR compatibility
Intent tagging: Most queries are informational (how to build, examples, tutorials), mixed with transactional/navigational (installation, npm, GitHub, demos). Target content should satisfy both quick-snippet answers and deeper code examples.
What react-planet is and when to use it
React-planet is a lightweight UI component pattern (and available npm package) that arranges child items around a central point — think of menu items orbiting a planet. It’s perfect when you want a memorable, space-themed or radial navigation: floating action menus, tool palettes, or playful dashboards.
This component pattern differs from a standard dropdown: it leverages geometry (radius, angles) and animation to create a spatial relationship between center and items. Use it when space and discoverability are design goals; avoid it when you need compact, dense information lists or strict enterprise UIs where novelty distracts users.
From an SEO and product perspective, queries like “react-planet tutorial” and “React circular menu” are typically from developers seeking implementation steps and examples. Provide concise installation steps, a minimal working example, and clear guidance on customization and accessibility to rank well for these intents.
Installation & getting started
Installation is trivial: install via npm or yarn and import the component where you need it. Example commands (run in your project root):
npm install react-planet
# or
yarn add react-planet
After installing, import the component and render a minimal setup. The typical API exposes a wrapper (often <Planet />, <PlanetItem /> or similar) with props like radius, rotation, and isOpen:
import React from 'react'
import { Planet, PlanetItem } from 'react-planet'
export default function App(){
return (
<Planet radius={120} rotation={0} isOpen>
<PlanetItem>A</PlanetItem>
<PlanetItem>B</PlanetItem>
<PlanetItem>C</PlanetItem>
</Planet>
)
}
For authoritative reference and examples, check the package page on npm and community tutorials such as the linked Dev.to walkthrough: Building Circular Navigation Menus with react-planet.
Core concepts: radius, rotation, items and animation
Radius controls the distance from the center to each item. It’s usually a number in pixels and can be static or responsive (computed from container size). If your container is fluid, calculate radius in JS and pass it as a prop to keep the layout consistent across breakpoints.
Rotation is the start angle offset. Combine rotation with the number of items to distribute them evenly: angle = rotation + index * (360 / items.length). Use radians internally for trig calculations but present the prop in degrees for developer clarity.
Animations: most implementations animate position and opacity. For smooth hardware-accelerated motion, animate transforms (translate/rotate) and opacity rather than top/left. Provide CSS transition or use the library’s animation props. For advanced motion, pair react-planet with a motion library (Framer Motion) for keyframed easing and staggered entrances.
Minimal working example and customization
Here’s a compact example for a radial menu with a toggle and custom icons. The markup is intentionally simple so you can adapt it quickly.
import React, {useState} from 'react'
import { Planet, PlanetItem } from 'react-planet'
import { FaHome, FaSearch, FaUser } from 'react-icons/fa'
function RadialMenu(){
const [open, setOpen] = useState(false)
return (
<div style={{position:'relative', width:240, height:240}}>
<Planet radius={90} rotation={-90} isOpen={open} onClickOutside={()=>setOpen(false)}>
<PlanetItem onClick={()=>alert('home')}><FaHome /></PlanetItem>
<PlanetItem onClick={()=>alert('search')}><FaSearch /></PlanetItem>
<PlanetItem onClick={()=>alert('profile')}><FaUser /></PlanetItem>
</Planet>
<button onClick={()=>setOpen(!open)} aria-expanded={open}>Toggle</button>
</div>
)
}
Customization tips:
- Style items via className or CSS variables exposed by the component.
- Use SVG icons for crisp scaling and apply transform-origin for smoother rotation.
To adjust the spacing between items, tweak radius or compute a min-angle. For dense item sets prefer multiple rings (two concentric planets) rather than cramming items at tiny radii; that improves touch targets and accessibility.
Animations, performance and accessibility
Animations should be snappy but performant: use CSS transforms (translate3d) and opacity, and keep durations short (200–400ms) with cubic-bezier easing. If you use JS-based animation libraries, limit reflows and prefer requestAnimationFrame-friendly APIs.
For performance on low-end devices, reduce the number of animated elements and avoid heavy shadow or filter effects. Defer offscreen work and avoid layout thrashing in resize handlers. Consider debouncing recalculations for radius/position on resize.
Accessibility: ensure keyboard focusability and ARIA attributes. Provide a visible focus ring, meaningful aria-labels on items, and a way to open/close via keyboard (Space/Enter). Announce state changes with aria-expanded and use aria-hidden appropriately when closed.
Integration tips, SSR and bundling
When integrating react-planet into larger apps, keep the component self-contained. Pass pure data arrays as props and avoid coupling heavy layout logic inside the component. That keeps server-side rendering predictable and hydration clean.
For SSR: compute radius on the client or use CSS clamp to avoid mismatched rendering. If the library relies on window/document on mount, guard usage with checks (typeof window !== ‘undefined’) or lazy-load the component with dynamic import.
Bundling: the library is typically small. If you integrate icon libraries, tree-shake (import specific icons) to keep bundle size reasonable. Use code-splitting for infrequently used UI like large radial menus that appear only on certain routes.
Troubleshooting & common pitfalls
Issue: items overlap or are off-center. Fix: verify container dimensions and that radius is computed relative to the container center. Ensure parent has position:relative and a defined width/height when using absolute positioned children.
Issue: jitter on resize. Fix: debounce resize handlers, and avoid layout querying inside animation loops. Recalculate positions after resize end to reduce layout thrash.
Issue: focus is lost when toggling. Fix: manage focus programmatically — when opening, focus the first item or a logical control; when closing, return focus to the toggle button.
References & further reading
Primary package page: react-planet on npm. Community tutorial: Dev.to walkthrough. For animation patterns, the React docs and Framer Motion docs are useful: React docs, Framer Motion.
If you need a production-ready radial navigation with advanced motion, consider pairing react-planet’s layout with Framer Motion for staggered entrance and exit animations.
Top user questions (extracted intent) and final FAQ
From typical “People Also Ask” style queries and developer forums, common questions include installation steps, customization (radius/animation), dynamic items handling, and accessibility/keyboard support. Below are the three most relevant for a compact FAQ.
FAQ
How do I install react-planet?
Install with npm or yarn: npm install react-planet or yarn add react-planet. Then import the component in your code: import { Planet } from 'react-planet'. See the npm page for version notes and changelog: react-planet on npm.
How to customize animations and radius in react-planet?
Use exposed props like radius and rotation for geometry. For animation, either rely on the library’s animation props or wrap items with a motion library (e.g., Framer Motion) to control timing, stagger and easing. Prefer CSS transforms for performance.
Can react-planet handle dynamic items and keyboard navigation?
Yes. Feed an array of items and map them to PlanetItem (or equivalent). Manage focus and keyboard handlers in parent state — provide aria attributes and keyboard listeners for Arrow keys/Tab/Enter to ensure accessible navigation.
