Skip to content

UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.

fix: update sidebar styles

Dillion Vermac85d164c51c8
diff --git a/components/sidebar-nav.tsx b/components/sidebar-nav.tsx
index 309f175c..5d541369 100644
--- a/components/sidebar-nav.tsx
+++ b/components/sidebar-nav.tsx
@@ -7,6 +7,7 @@ import { usePathname } from "next/navigation";
import posthog from "posthog-js";
import { cn } from "@/lib/utils";
+import { motion } from "motion/react";
export interface DocsSidebarNavProps {
items: SidebarNavItem[];
@@ -28,11 +29,7 @@ export function DocsSidebarNav({ items }: DocsSidebarNavProps) {
)}
</h4>
{item?.items?.length && (
- <DocsSidebarNavItems
- items={item.items}
- pathname={pathname}
- groupId={`group-${index}`}
- />
+ <DocsSidebarNavItems items={item.items} pathname={pathname} />
)}
</div>
))}
@@ -43,13 +40,11 @@ export function DocsSidebarNav({ items }: DocsSidebarNavProps) {
interface DocsSidebarNavItemsProps {
items: SidebarNavItem[];
pathname: string | null;
- groupId: string;
}
export function DocsSidebarNavItems({
items,
pathname,
- groupId,
}: DocsSidebarNavItemsProps) {
return items?.length ? (
<div className="relative grid grid-flow-row auto-rows-max gap-0.5 text-sm">
@@ -60,7 +55,7 @@ export function DocsSidebarNavItems({
href={item.href}
onClick={() => item.event && posthog.capture(item.event)}
className={cn(
- "group flex h-8 w-full items-center rounded-lg px-2 font-normal text-foreground underline-offset-2 hover:bg-accent hover:text-accent-foreground",
+ "group relative flex h-8 w-full items-center rounded-lg px-2 font-normal text-foreground underline-offset-2 hover:bg-accent hover:text-accent-foreground",
item.disabled && "cursor-not-allowed opacity-60",
pathname === item.href &&
"bg-accent font-medium text-accent-foreground",
@@ -68,6 +63,20 @@ export function DocsSidebarNavItems({
target={item.external ? "_blank" : ""}
rel={item.external ? "noreferrer" : ""}
>
+ {pathname === item.href && (
+ <motion.div
+ layoutId="sidebar-nav-active"
+ className="absolute inset-0 rounded-lg bg-accent text-accent-foreground"
+ initial={false}
+ transition={{
+ type: "spring",
+ stiffness: 350,
+ damping: 30,
+ mass: 1,
+ velocity: 200,
+ }}
+ />
+ )}
<span className="relative z-10 shrink-0">{item.title}</span>
{item.label && (
<span className="relative z-10 ml-2 rounded-md bg-[#FFBD7A] px-1.5 py-0.5 text-xs leading-none text-[#000000] no-underline group-hover:no-underline">