Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What needs to be added to path @/lib/utils when trying to use shadcn/ui components?

I am trying to use the shadcn dropdown component in my react application. I am not using Tailwind. I followed their docs and chose the path to add the code manually, but now I get an error:

Module not found: Can't resolve '@/lib/utils'
  3 | import { CheckIcon, ChevronRightIcon, DotFilledIcon } from "@radix-ui/react-icons";
  4 |
> 5 | import { cn } from "@/lib/utils";
  6 |
  7 | const DropdownMenu = DropdownMenuPrimitive.Root;

Please guide me on what needs to be added to folder @/lib/utils.

like image 507
Pawan Avatar asked Jan 28 '26 06:01

Pawan


1 Answers

cn() can be found in the shadcn git repo:

import * as React from "react"
import { clsx, type ClassValue } from "clsx"
import { twMerge } from "tailwind-merge"

export function cn(...inputs: ClassValue[]) {
    return twMerge(clsx(inputs))
} 

source: https://github.com/shadcn-ui/ui/blob/bebc2843f0e0daa4e508def74fb3ba8a08e98f6f/apps/www/lib/utils.ts#L5C1-L6C1

like image 170
ybmeng Avatar answered Jan 30 '26 10:01

ybmeng



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!