From 467383b8a2ad42bd22fabe1f70ea17c95bede53b Mon Sep 17 00:00:00 2001 From: Junior Garcia Date: Fri, 10 Nov 2023 09:06:49 -0300 Subject: [PATCH] fix(switch): element type (#1949) --- .changeset/unlucky-bikes-care.md | 5 +++++ packages/components/switch/src/switch.tsx | 2 +- packages/components/switch/src/use-switch.ts | 2 +- packages/components/switch/stories/switch.stories.tsx | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 .changeset/unlucky-bikes-care.md diff --git a/.changeset/unlucky-bikes-care.md b/.changeset/unlucky-bikes-care.md new file mode 100644 index 0000000000..34992e17f5 --- /dev/null +++ b/.changeset/unlucky-bikes-care.md @@ -0,0 +1,5 @@ +--- +"@nextui-org/switch": patch +--- + +Fix switch base element type it is an input now. diff --git a/packages/components/switch/src/switch.tsx b/packages/components/switch/src/switch.tsx index bea99a7ad3..bee6a80bae 100644 --- a/packages/components/switch/src/switch.tsx +++ b/packages/components/switch/src/switch.tsx @@ -6,7 +6,7 @@ import {UseSwitchProps, useSwitch} from "./use-switch"; export interface SwitchProps extends UseSwitchProps {} -const Switch = forwardRef<"label", SwitchProps>((props, ref) => { +const Switch = forwardRef<"input", SwitchProps>((props, ref) => { const { Component, children, diff --git a/packages/components/switch/src/use-switch.ts b/packages/components/switch/src/use-switch.ts index 4dfb7b4226..431733ac97 100644 --- a/packages/components/switch/src/use-switch.ts +++ b/packages/components/switch/src/use-switch.ts @@ -23,7 +23,7 @@ export type SwitchThumbIconProps = { isSelected: boolean; className: string; }; -interface Props extends HTMLNextUIProps<"label"> { +interface Props extends HTMLNextUIProps<"input"> { /** * Ref to the DOM node. */ diff --git a/packages/components/switch/stories/switch.stories.tsx b/packages/components/switch/stories/switch.stories.tsx index 94aeb38735..33a753a70b 100644 --- a/packages/components/switch/stories/switch.stories.tsx +++ b/packages/components/switch/stories/switch.stories.tsx @@ -159,7 +159,7 @@ export const DisableAnimation = { }, }; -export const WiththumbIcon = { +export const WithThumbIcon = { args: { ...defaultProps, size: "xl",