mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-07-01 00:24:20 +00:00
Fix incorrect named import syntax for Next.js Link component.
Changed from:
import { Link } from "next/link"
To correct default import:
import Link from "next/link"
Next.js Link is a default export, not a named export. The incorrect
syntax causes TypeScript error:
'Module "next/link" has no exported member "Link"'
Affected files:
- Button component docs
- Badge component docs
- Breadcrumb component docs (v4 and www)
- Navigation Menu component docs
Fixes issue where users copying code snippets get immediate errors.
Co-authored-by: serhatx1 <armonikadijital@gmail.com>
72 lines
1.2 KiB
Plaintext
72 lines
1.2 KiB
Plaintext
---
|
|
title: Badge
|
|
description: Displays a badge or a component that looks like a badge.
|
|
component: true
|
|
---
|
|
|
|
<ComponentPreview
|
|
name="badge-demo"
|
|
title="Badge"
|
|
description="A default badge"
|
|
/>
|
|
|
|
## Installation
|
|
|
|
<CodeTabs>
|
|
|
|
<TabsList>
|
|
<TabsTrigger value="cli">CLI</TabsTrigger>
|
|
<TabsTrigger value="manual">Manual</TabsTrigger>
|
|
</TabsList>
|
|
<TabsContent value="cli">
|
|
|
|
```bash
|
|
npx shadcn@latest add badge
|
|
```
|
|
|
|
</TabsContent>
|
|
|
|
<TabsContent value="manual">
|
|
|
|
<Steps>
|
|
|
|
<Step>Copy and paste the following code into your project.</Step>
|
|
|
|
<ComponentSource name="badge" title="components/ui/badge.tsx" />
|
|
|
|
<Step>Update the import paths to match your project setup.</Step>
|
|
|
|
</Steps>
|
|
|
|
</TabsContent>
|
|
|
|
</CodeTabs>
|
|
|
|
## Usage
|
|
|
|
```tsx
|
|
import { Badge } from "@/components/ui/badge"
|
|
```
|
|
|
|
```tsx
|
|
<Badge variant="default |outline | secondary | destructive">Badge</Badge>
|
|
```
|
|
|
|
### Link
|
|
|
|
You can use the `asChild` prop to make another component look like a badge. Here's an example of a link that looks like a badge.
|
|
|
|
```tsx showLineNumbers
|
|
import Link from "next/link"
|
|
|
|
import { Badge } from "@/components/ui/badge"
|
|
|
|
export function LinkAsBadge() {
|
|
return (
|
|
<Badge asChild>
|
|
<Link href="/">Badge</Link>
|
|
</Badge>
|
|
)
|
|
}
|
|
```
|