Skip to content

Commit 5c2dba7

Browse files
committed
Add option for horizontal stepper
1 parent 31db280 commit 5c2dba7

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

src/components/Steps.tsx

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,51 @@ import React from "react";
44
type Props = {
55
children: React.ReactNode;
66
className?: string;
7+
horizontal?: boolean;
78
};
8-
export default function Steps({ children, className }: Props) {
9-
return <div className={cn("pt-4", className)}>{children}</div>;
9+
export default function Steps({
10+
children,
11+
className,
12+
horizontal = false,
13+
}: Readonly<Props>) {
14+
return (
15+
<div className={cn("pt-4", horizontal && "flex", className)}>
16+
{children}
17+
</div>
18+
);
1019
}
1120

1221
type StepProps = {
1322
children: React.ReactNode;
1423
step: number;
1524
line?: boolean;
1625
center?: boolean;
26+
horizontal?: boolean;
1727
};
1828

19-
const Step = ({ children, step, line = true, center = false }: StepProps) => {
29+
const Step = ({
30+
children,
31+
step,
32+
line = true,
33+
center = false,
34+
horizontal,
35+
}: StepProps) => {
2036
return (
2137
<div
2238
className={cn(
23-
"flex gap-4 items-start min-w-full justify-start relative pb-6 -mx-1.5 group px-[2px]",
39+
"flex gap-4 items-start justify-start relative pb-6 -mx-1.5 group px-[2px]",
2440
center && "items-center",
41+
horizontal ? "flex-col items-center" : "min-w-full",
2542
)}
2643
>
2744
{line && (
2845
<span
29-
className={
30-
"h-full w-[2px] bg-nb-gray-100 dark:bg-nb-gray-800 absolute left-0 ml-[18px] z-0 transition-all"
31-
}
46+
className={cn(
47+
"bg-nb-gray-100 dark:bg-nb-gray-800 z-0 transition-all",
48+
horizontal
49+
? "w-full h-[2px] absolute mt-[16px] transform translate-x-1/2"
50+
: "h-full w-[2px] absolute left-0 ml-[18px]",
51+
)}
3252
></span>
3353
)}
3454

0 commit comments

Comments
 (0)