diff --git a/.changeset/silly-cows-exist.md b/.changeset/silly-cows-exist.md new file mode 100644 index 00000000000..8e9954d5331 --- /dev/null +++ b/.changeset/silly-cows-exist.md @@ -0,0 +1,5 @@ +--- +'@iota/apps-ui-kit': patch +--- + +add ref to Button component diff --git a/apps/ui-kit/src/lib/components/atoms/button/Button.tsx b/apps/ui-kit/src/lib/components/atoms/button/Button.tsx index 43509b320cd..8ad9aee2282 100644 --- a/apps/ui-kit/src/lib/components/atoms/button/Button.tsx +++ b/apps/ui-kit/src/lib/components/atoms/button/Button.tsx @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 import { ButtonHtmlType, ButtonSize, ButtonType } from './button.enums'; +import { forwardRef } from 'react'; import { PADDINGS, PADDINGS_ONLY_ICON, @@ -60,41 +61,50 @@ export interface ButtonProps { testId?: string; } -export function Button({ - icon, - text, - disabled, - onClick, - fullWidth, - htmlType = ButtonHtmlType.Button, - size = ButtonSize.Medium, - type = ButtonType.Primary, - iconAfterText = false, - tabIndex = 0, - testId, -}: ButtonProps): React.JSX.Element { - const paddingClasses = icon && !text ? PADDINGS_ONLY_ICON[size] : PADDINGS[size]; - const textSizes = TEXT_CLASSES[size]; - const backgroundColors = disabled ? DISABLED_BACKGROUND_COLORS[type] : BACKGROUND_COLORS[type]; - const textColors = disabled ? TEXT_COLOR_DISABLED[type] : TEXT_COLORS[type]; - return ( - - ); -} +export const Button = forwardRef( + ( + { + icon, + text, + disabled, + onClick, + fullWidth, + htmlType = ButtonHtmlType.Button, + size = ButtonSize.Medium, + type = ButtonType.Primary, + iconAfterText = false, + tabIndex = 0, + testId, + }, + ref, + ): React.JSX.Element => { + const paddingClasses = icon && !text ? PADDINGS_ONLY_ICON[size] : PADDINGS[size]; + const textSizes = TEXT_CLASSES[size]; + const backgroundColors = disabled + ? DISABLED_BACKGROUND_COLORS[type] + : BACKGROUND_COLORS[type]; + const textColors = disabled ? TEXT_COLOR_DISABLED[type] : TEXT_COLORS[type]; + + return ( + + ); + }, +);