Skip to content

Instantly share code, notes, and snippets.

@itkrt2y
Last active April 19, 2022 12:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itkrt2y/54f860571ea8109c13bba77b2d37c2fc to your computer and use it in GitHub Desktop.
Save itkrt2y/54f860571ea8109c13bba77b2d37c2fc to your computer and use it in GitHub Desktop.
react-hook-form + ChakraUI NumberInput
import {
NumberDecrementStepper,
NumberIncrementStepper,
NumberInput,
NumberInputField,
NumberInputStepper,
} from "@chakra-ui/react";
import { Controller } from "react-hook-form";
<Controller
name="sample"
control={control}
render={({ field: { ref, onChange, ...rest } }) => (
<NumberInput {...rest} onChange={(_, v) => onChange(v)}>
<NumberInputField ref={ref} />
<NumberInputStepper>
<NumberIncrementStepper />
<NumberDecrementStepper />
</NumberInputStepper>
</NumberInput>
)}
/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment