Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
mastodon
GitHub Repository: mastodon/joinmastodon
Path: blob/main/components/Button.tsx
1006 views
1
import {
2
Button as HeadlessButton,
3
ButtonProps as HeadlessButtonProps,
4
} from "@headlessui/react"
5
import classNames from "classnames"
6
7
export type ButtonProps = HeadlessButtonProps & {
8
dark?: boolean
9
size?: "small" | "medium" | "large"
10
fullWidth?: boolean
11
borderless?: boolean
12
}
13
14
export function Button({
15
children,
16
className,
17
dark = false,
18
size = "medium",
19
fullWidth = false,
20
borderless = false,
21
...props
22
}: React.PropsWithChildren<ButtonProps>) {
23
return (
24
<HeadlessButton
25
{...props}
26
className={classNames(
27
className,
28
"p-2 flex gap-2 items-center justify-center rounded-md",
29
fullWidth ? "w-full" : "w-max",
30
size === "small" && "b3 h-10",
31
size === "medium" && "b3 h-12",
32
size === "large" && "b3 md:b1 h-12 md:h-16 md:px-6",
33
"text-center font-semibold transition-colors focus:outline-none disabled:cursor-default",
34
"disabled:bg-gray-2 disabled:hocus:bg-gray-2 disabled:text-white",
35
!dark &&
36
"bg-white dark:bg-black hocus:bg-blurple-600 text-blurple-500 hocus:text-white",
37
dark && "bg-blurple-500 hocus:bg-blurple-600 text-white",
38
!borderless &&
39
"border-2 border-blurple-500 hocus:border-blurple-600 disabled:border-gray-2 disabled:hocus:border-gray-2"
40
)}
41
>
42
{children}
43
</HeadlessButton>
44
)
45
}
46
47