Dev Helpers
← Back

Reset only typography controls

Place this file at components/ResetOnlyTypographyControls.tsx in an App Router project.

Open this example in the interactive library

Source code

"use client";

// components/ResetOnlyTypographyControls.tsx

import { Suspense } from "react";

import Link from "next/link";

import { useSearchParams, usePathname } from "next/navigation";

function ResetOnlyTypographyControlsContent() {
  const q = new URLSearchParams(useSearchParams());
  for (const key of ["size", "width", "font"]) q.delete(key);
  const path = usePathname();
  return (
    <Link href={path + (q.size ? "?" + q : "")} replace scroll={false}>
      Restore default typography
    </Link>
  );
}

export default function ResetOnlyTypographyControls() {
  return (
    <Suspense fallback={<span>Loading view…</span>}>
      <ResetOnlyTypographyControlsContent />
    </Suspense>
  );
}