Skip to content

Instantly share code, notes, and snippets.

@ajitid
Created April 26, 2022 05:44
Show Gist options
  • Save ajitid/21720c292b042d9bdcd6c1a70b1c7b77 to your computer and use it in GitHub Desktop.
Save ajitid/21720c292b042d9bdcd6c1a70b1c7b77 to your computer and use it in GitHub Desktop.
React extend HTML element
import React, { forwardRef } from 'react';
import cn from 'classnames';
import css from './input.module.scss';
interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {}
const Input = forwardRef<HTMLInputElement, InputProps>(
({ type = 'text', className, ...props }, ref) => {
let classes = cn(css.input, className);
return <input type={type} className={classes} {...props} ref={ref} />;
}
);
export default Input;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment