diff --git a/.changeset/tiny-cameras-hunt.md b/.changeset/tiny-cameras-hunt.md new file mode 100644 index 000000000..138f9cf03 --- /dev/null +++ b/.changeset/tiny-cameras-hunt.md @@ -0,0 +1,5 @@ +--- +"kitchn": patch +--- + +Add ref to Button diff --git a/packages/kitchn/src/components/Button/index.tsx b/packages/kitchn/src/components/Button/index.tsx index 224c5b545..983f85431 100644 --- a/packages/kitchn/src/components/Button/index.tsx +++ b/packages/kitchn/src/components/Button/index.tsx @@ -31,21 +31,25 @@ export type ButtonProps = KitchnComponent< React.ButtonHTMLAttributes >; -const ButtonComponent = styled( - ({ - as: Component = "button", - children, - loading, - size, - width, - prefix, - suffix, - htmlType, - ...props - }: ButtonProps) => { +const ForwardedButton = React.forwardRef( + ( + { + as: Component = "button", + children, + loading, + size, + width, + prefix, + suffix, + htmlType, + ...props + }, + ref: React.ForwardedRef, + ) => { const theme = useTheme(); return ( ); }, -)` +); + +ForwardedButton.displayName = "Button"; + +const ButtonComponent = styled(ForwardedButton)` position: relative; display: flex; align-items: center;