MCPcopy Create free account
hub / github.com/cosscom/coss / Button

Function Button

apps/ui/registry/default/ui/button.tsx:57–96  ·  view source on GitHub ↗
({
  className,
  variant,
  size,
  render,
  children,
  loading = false,
  disabled: disabledProp,
  ...props
}: ButtonProps)

Source from the content-addressed store, hash-verified

55}
56
57export function Button({
58 className,
59 variant,
60 size,
61 render,
62 children,
63 loading = false,
64 disabled: disabledProp,
65 ...props
66}: ButtonProps): React.ReactElement {
67 const isDisabled: boolean = Boolean(loading || disabledProp);
68 const typeValue: React.ButtonHTMLAttributes<HTMLButtonElement>["type"] =
69 render ? undefined : "button";
70
71 const defaultProps = {
72 children: (
73 <>
74 {children}
75 {loading && (
76 <Spinner
77 className="pointer-events-none absolute"
78 data-slot="button-loading-indicator"
79 />
80 )}
81 </>
82 ),
83 className: cn(buttonVariants({ className, size, variant })),
84 "aria-disabled": loading || undefined,
85 "data-loading": loading ? "" : undefined,
86 "data-slot": "button",
87 disabled: isDisabled,
88 type: typeValue,
89 };
90
91 return useRender({
92 defaultTagName: "button",
93 props: mergeProps<"button">(defaultProps, props),
94 render,
95 });
96}

Callers

nothing calls this directly

Calls 1

cnFunction · 0.90

Tested by

no test coverage detected