Skip to content

Instantly share code, notes, and snippets.

@arn4v
Created March 20, 2022 15:32
Show Gist options
  • Save arn4v/20021b487736713e9aeab4dc27940c3d to your computer and use it in GitHub Desktop.
Save arn4v/20021b487736713e9aeab4dc27940c3d to your computer and use it in GitHub Desktop.

Option A

import { Tabs } from "ui-library";
import { css } from "ui-library/stitches.config";
import { useRouter } from "next/router";

export function OptionA() {
  const router = useRouter();

  return (
    <Tabs>
      {[
        {
          label: "Home",
          href: "/home",
          isActive: router.pathname === "/href",
        },
        {
          label: "Settings",
          href: "/settings",
          isActive: router.pathname === "/settings",
        },
      ].map((tab, idx) =>  <Tabs.Item key={idx} {...tab} />)}
    </Tabs>
  );
}

Option B

import { Tabs } from "ui-library";
import { css } from "ui-library/stitches.config";
import { useRouter } from "next/router";

export function OptionB() {
  const router = useRouter();

  return (
    <Tabs
      items={[
        {
          label: "Home",
          href: "/home",
          isActive: router.pathname === "/href",
        },
        {
          label: "Settings",
          href: "/settings",
          isActive: router.pathname === "/settings",
        },
      ]}
    />
  );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment