generated from fahricansecer/boilerplate-fe
Initial commit
This commit is contained in:
20
src/components/ui/forms/radio.tsx
Normal file
20
src/components/ui/forms/radio.tsx
Normal file
@@ -0,0 +1,20 @@
|
||||
import { RadioGroup as ChakraRadioGroup } from '@chakra-ui/react';
|
||||
import * as React from 'react';
|
||||
|
||||
export interface RadioProps extends ChakraRadioGroup.ItemProps {
|
||||
rootRef?: React.RefObject<HTMLDivElement | null>;
|
||||
inputProps?: React.InputHTMLAttributes<HTMLInputElement>;
|
||||
}
|
||||
|
||||
export const Radio = React.forwardRef<HTMLInputElement, RadioProps>(function Radio(props, ref) {
|
||||
const { children, inputProps, rootRef, ...rest } = props;
|
||||
return (
|
||||
<ChakraRadioGroup.Item ref={rootRef} {...rest}>
|
||||
<ChakraRadioGroup.ItemHiddenInput ref={ref} {...inputProps} />
|
||||
<ChakraRadioGroup.ItemIndicator />
|
||||
{children && <ChakraRadioGroup.ItemText>{children}</ChakraRadioGroup.ItemText>}
|
||||
</ChakraRadioGroup.Item>
|
||||
);
|
||||
});
|
||||
|
||||
export const RadioGroup = ChakraRadioGroup.Root;
|
||||
Reference in New Issue
Block a user