File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ "use client" ;
2
+
3
+ import { cn } from "@/lib/utils" ;
4
+ import { useRouter } from "next/navigation" ;
5
+
6
+
7
+ export default function BackButton ( { className, ...props } : React . ButtonHTMLAttributes < HTMLButtonElement > ) {
8
+ const router = useRouter ( ) ;
9
+
10
+ const hasHistory =
11
+ ( typeof window !== "undefined" &&
12
+ window . history ?. length &&
13
+ window . history . length > 1 ) ||
14
+ typeof window === "undefined" ;
15
+
16
+ if ( ! hasHistory ) {
17
+ return null ;
18
+ }
19
+
20
+ return (
21
+ < button
22
+ className = {
23
+ cn (
24
+ "text-slate-600 dark:text-slate-300 hover:text-black dark:hover:text-white" ,
25
+ "cursor-pointer hover:underline hover:underline-offset-4" ,
26
+ className
27
+ )
28
+ }
29
+ onClick = { router . back }
30
+ { ...props }
31
+ />
32
+ ) ;
33
+ }
You can’t perform that action at this time.
0 commit comments