Saturday, November 18, 2023

Input component for reuse

 


import React from 'react'
import classes from './Input.module.css'

const Input = (props) => {
  return (
    <div className={classes.input}>
        <label htmlFor={props.input.id}>{props.label}</label>
        <input {...props.input}/>

    </div>
  )
}

export default Input
  1. Passing from below from another component where input requireed <Input
  2. label='Amount'
  3. input={{
  4. id: 'amount',
  5. type: 'number',
  6. min: '1',
  7. max: '5',
  8. step: '1',
  9. defaultValue: '1',
  10. }}
  11. />


in
in