Context Menu
solid-ui/context-menuFreeComponent
A context menu component
Live preview
live · rendered by the registry
Rendered by solid-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://www.solid-ui.com/r/context-menu.jsonSource
1import type { Component, ComponentProps, JSX, ValidComponent } from "solid-js"2import { splitProps } from "solid-js"34import * as ContextMenuPrimitive from "@kobalte/core/context-menu"5import type { PolymorphicProps } from "@kobalte/core/polymorphic"67import { cn } from "~/lib/utils"89const ContextMenuTrigger = ContextMenuPrimitive.Trigger10const ContextMenuPortal = ContextMenuPrimitive.Portal11const ContextMenuSub = ContextMenuPrimitive.Sub12const ContextMenuGroup = ContextMenuPrimitive.Group13const ContextMenuRadioGroup = ContextMenuPrimitive.RadioGroup1415const ContextMenu: Component<ContextMenuPrimitive.ContextMenuRootProps> = (props) => {16 return <ContextMenuPrimitive.Root gutter={4} {...props} />17}1819type ContextMenuContentProps<T extends ValidComponent = "div"> =20 ContextMenuPrimitive.ContextMenuContentProps<T> & {21 class?: string | undefined22 }2324const ContextMenuContent = <T extends ValidComponent = "div">(25 props: PolymorphicProps<T, ContextMenuContentProps<T>>26) => {27 const [local, others] = splitProps(props as ContextMenuContentProps, ["class"])28 return (29 <ContextMenuPrimitive.Portal>30 <ContextMenuPrimitive.Content31 class={cn(32 "z-50 min-w-32 origin-[var(--kb-menu-content-transform-origin)] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in",33 local.class34 )}35 {...others}36 />37 </ContextMenuPrimitive.Portal>38 )39}4041type ContextMenuItemProps<T extends ValidComponent = "div"> =42 ContextMenuPrimitive.ContextMenuItemProps<T> & {43 class?: string | undefined44 }4546const ContextMenuItem = <T extends ValidComponent = "div">(47 props: PolymorphicProps<T, ContextMenuItemProps<T>>48) => {49 const [local, others] = splitProps(props as ContextMenuItemProps, ["class"])50 return (51 <ContextMenuPrimitive.Item52 class={cn(53 "relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",54 local.class55 )}56 {...others}57 />58 )59}6061const ContextMenuShortcut: Component<ComponentProps<"span">> = (props) => {62 const [local, others] = splitProps(props, ["class"])63 return <span class={cn("ml-auto text-xs tracking-widest opacity-60", local.class)} {...others} />64}6566type ContextMenuSeparatorProps<T extends ValidComponent = "hr"> =67// … truncated
What it pulls in
npm packages
Files it writes
More from solid-ui
All 55 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | solid-ui | Components | Free | 2 deps | |
| Alertalert | solid-ui | Components | Free | 3 deps | |
| Alert Dialogalert-dialog | solid-ui | Components | Free | 2 deps | |
| Aspect Ratioaspect-ratio | solid-ui | Components | Free | 1 dep | |
| Avataravatar | solid-ui | Components | Free | 2 deps | |
| Badgebadge | solid-ui | Components | Free | 2 deps | |
| Badge Deltabadge-delta | solid-ui | Components | Free | 2 deps | |
| Bar Listbar-list | solid-ui | Components | Free | 1 dep |
