mirror of
https://github.com/vercel/next-learn.git
synced 2026-06-11 09:51:47 +00:00
Add a link snippet
This commit is contained in:
17
snippets/link-classname-example.js
Normal file
17
snippets/link-classname-example.js
Normal file
@@ -0,0 +1,17 @@
|
||||
// Example: Adding className with <Link>
|
||||
import Link from 'next/link'
|
||||
|
||||
export default function LinkClassnameExample() {
|
||||
// To add attributes like className, target, rel, etc.
|
||||
// add them to the <a> tag, not to the <Link> tag.
|
||||
return (
|
||||
<Link href="/">
|
||||
<a className="foo" target="_blank" rel="noopener noreferrer">
|
||||
Hello World
|
||||
</a>
|
||||
</Link>
|
||||
)
|
||||
}
|
||||
|
||||
// Take a look at https://nextjs.org/docs/api-reference/next/link
|
||||
// to learn more!
|
||||
Reference in New Issue
Block a user