forked from coder/coder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStack.tsx
More file actions
41 lines (38 loc) · 894 Bytes
/
Stack.tsx
File metadata and controls
41 lines (38 loc) · 894 Bytes
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
31
32
33
34
35
36
37
38
39
40
41
import { forwardRef } from "react";
import type { CSSObject } from "@emotion/react";
export type StackProps = {
className?: string;
direction?: "column" | "row";
spacing?: number;
alignItems?: CSSObject["alignItems"];
justifyContent?: CSSObject["justifyContent"];
wrap?: CSSObject["flexWrap"];
} & React.HTMLProps<HTMLDivElement>;
export const Stack = forwardRef<HTMLDivElement, StackProps>((props, ref) => {
const {
children,
direction = "column",
spacing = 2,
alignItems,
justifyContent,
wrap,
...divProps
} = props;
return (
<div
{...divProps}
ref={ref}
css={{
display: "flex",
flexDirection: direction,
gap: spacing * 8,
alignItems: alignItems,
justifyContent: justifyContent,
flexWrap: wrap,
maxWidth: "100%",
}}
>
{children}
</div>
);
});