Navigation Menu
solid-ui/navigation-menuFreeComponent
A navigation 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/navigation-menu.jsonSource
1import type { JSX, ValidComponent } from "solid-js"2import { splitProps } from "solid-js"34import type { PolymorphicProps } from "@kobalte/core"5import * as NavigationMenuPrimitive from "@kobalte/core/navigation-menu"67import { cn } from "~/lib/utils"89const NavigationMenuItem = NavigationMenuPrimitive.Menu1011type NavigationMenuProps<T extends ValidComponent = "ul"> =12 NavigationMenuPrimitive.NavigationMenuRootProps<T> & {13 class?: string | undefined14 children?: JSX.Element15 }1617const NavigationMenu = <T extends ValidComponent = "ul">(18 props: PolymorphicProps<T, NavigationMenuProps<T>>19) => {20 const [local, others] = splitProps(props as NavigationMenuProps, ["class", "children"])21 return (22 <NavigationMenuPrimitive.Root23 gutter={6}24 class={cn(25 "group/menu flex w-max flex-1 list-none items-center justify-center data-[orientation=vertical]:flex-col [&>li]:w-full",26 local.class27 )}28 {...others}29 >30 {local.children}31 <NavigationMenuViewport />32 </NavigationMenuPrimitive.Root>33 )34}3536type NavigationMenuTriggerProps<T extends ValidComponent = "button"> =37 NavigationMenuPrimitive.NavigationMenuTriggerProps<T> & {38 class?: string | undefined39 }4041const NavigationMenuTrigger = <T extends ValidComponent = "button">(42 props: PolymorphicProps<T, NavigationMenuTriggerProps<T>>43) => {44 const [local, others] = splitProps(props as NavigationMenuTriggerProps, ["class"])45 return (46 <NavigationMenuPrimitive.Trigger47 class={cn(48 "group/trigger inline-flex h-10 w-full items-center justify-center whitespace-nowrap rounded-md bg-background px-4 py-2 text-sm font-medium transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground focus:outline-none disabled:pointer-events-none disabled:opacity-50 data-[active]:bg-accent/50 data-[expanded]:bg-accent/50",49 local.class50 )}51 {...others}52 />53 )54}55const NavigationMenuIcon = () => {56 return (57 <NavigationMenuPrimitive.Icon aria-hidden="true">58 <svg59 xmlns="http://www.w3.org/2000/svg"60 viewBox="0 0 24 24"61 fill="none"62 stroke="currentColor"63 stroke-width="2"64 stroke-linecap="round"65 stroke-linejoin="round"66// … 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 |
