Components / Navigation
Radial Menu
A floating action button that springs its actions out in an arc.
Installation
Requires React 18+ and Tailwind CSS.
- 1
Install dependencies
$ npm install motion - 2
Add the component
Copy the code from the Code tab above into
components/ui/radial-menu.tsx. - 3
Use it
example.tsximport { RadialMenu } from "@/components/ui/radial-menu"; const icon = (d: string) => ( <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"> <path d={d} /> </svg> ); const items = [ { label: "Camera", icon: icon("M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2zM12 17a4 4 0 1 0 0-8 4 4 0 0 0 0 8z") }, { label: "Message", icon: icon("M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z") }, { label: "Share", icon: icon("M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8M16 6l-4-4-4 4M12 2v13") }, { label: "Like", icon: icon("M20.8 4.6a5.5 5.5 0 0 0-7.8 0L12 5.7l-1-1.1a5.5 5.5 0 0 0-7.8 7.8l1 1.1L12 21l7.8-7.5 1-1.1a5.5 5.5 0 0 0 0-7.8z") }, ]; export default function RadialMenuDemo() { return ( <div className="pt-24"> <RadialMenu items={items} /> </div> ); }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| items | { label: string; icon: ReactNode; onClick?: () => void }[] | — | Menu actions. |
| radius | number | 100 | Distance of items from the button (px). |
| startAngle | number | -180 | Angle of the first item (0 = right, -90 = up). |
| spread | number | 180 | Arc the items cover, in degrees. |