Migrate UI primitives from Radix to Base UI.
Local Build and Deploy / deploy (push) Successful in 54s
Local Build and Deploy / deploy (push) Successful in 54s
Co-authored-by: Cursor <[email protected]>
This commit is contained in:
1 parent
90cff7e5d5
commit
25f01b61b3
18 files changed
+510
-846
No files matched your search
@@ -1,7 +1,8 @@
|
||||
import { Button as ButtonPrimitive } from "@base-ui/react/button";
|
||||
import { cva, type VariantProps } from "class-variance-authority";
|
||||
import { Slot } from "@radix-ui/react-slot";
|
||||
import type * as React from "react";
|
||||
|
||||
import { resolveAsChild } from "@/lib/as-child";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const buttonVariants = cva(
|
||||
@@ -43,21 +44,26 @@ function Button({
|
||||
variant = "default",
|
||||
size = "default",
|
||||
asChild = false,
|
||||
children,
|
||||
render,
|
||||
...props
|
||||
}: React.ComponentProps<"button"> &
|
||||
}: ButtonPrimitive.Props &
|
||||
VariantProps<typeof buttonVariants> & {
|
||||
asChild?: boolean;
|
||||
}) {
|
||||
const Comp = asChild ? Slot : "button";
|
||||
const resolved = resolveAsChild(asChild, children, render);
|
||||
|
||||
return (
|
||||
<Comp
|
||||
<ButtonPrimitive
|
||||
data-slot="button"
|
||||
data-variant={variant}
|
||||
data-size={size}
|
||||
className={cn(buttonVariants({ variant, size, className }))}
|
||||
render={resolved.render}
|
||||
{...props}
|
||||
/>
|
||||
>
|
||||
{resolved.children}
|
||||
</ButtonPrimitive>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user