티스토리 뷰

NextJS

[NextJS] Styles JSX

BIBLIYA 2022. 10. 14. 12:42

Styles JSX

import Link from "next/link";
import { useRouter } from "next/router";

export default function NavBar() {
  const router = useRouter();
  return (
    <nav>
      <Link href="/">
        <a className={router.pathname === "/" ? "active" : ""}>Home</a>
      </Link>
      <Link href="/about">
        <a className={router.pathname === "/about" ? "active" : ""}>About</a>
      </Link>
      <style jsx>{`
        a {
          text-decoration: none;
        }
        .active {
          color: ${props.color} | red;
        }
      `}</style>
    </nav>
  );
}

'NextJS' 카테고리의 다른 글

[NextJS] Redirect and Rewrite  (0) 2022.10.14
[NextJS] _app  (0) 2022.10.14
[NextJS] CSS Modules  (0) 2022.10.14
[NextJS] Routing  (0) 2022.10.14
[NextJS] Pages / Static Pre Rendering  (0) 2022.10.14
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2026/04   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30
글 보관함