server/assets/js/react/components/Container.tsx

24 lines
574 B
TypeScript
Raw Permalink Normal View History

import * as React from "react"
import clsx from "clsx"
2023-12-02 14:21:05 +00:00
type ContainerProps<T extends React.ElementType> = {
as?: T
className?: string
children: React.ReactNode
}
2023-12-02 14:21:05 +00:00
export function Container<T extends React.ElementType = "div">({
as,
className,
children,
}: Omit<React.ComponentPropsWithoutRef<T>, keyof ContainerProps<T>> &
ContainerProps<T>) {
let Component = as ?? "div"
2023-12-02 14:21:05 +00:00
return (
<Component className={clsx("mx-auto max-w-7xl px-6 lg:px-8", className)}>
<div className="mx-auto max-w-2xl lg:max-w-none">{children}</div>
</Component>
)
2023-12-02 14:21:05 +00:00
}