Skip to main content

TimeInput

The TimeInput component is a versatile and reusable component that allows users to input time in hours and minutes format. It allows only numbers as input. We can customize it by passing various props to suit our component needs. In this guide, we'll walk through how to use the TimeInput component in codebase.

Importing the TimeInput Component

To use the TimeInput component in our app, we need to import it from our styled components. Here's how we can import it:

import { TimeInput } from "StyledComponents";

default timeinput

Using the TimeInput Component

The TimeInput component can be used with various props to control its appearance. Here are some examples of how we can use it:

<TimeInput
className="h-8 w-20 rounded-sm bg-miru-gray-100 p-1 text-sm
onTimeChange={() => ()}
/>
<TimeInput
className="h-8 w-20 rounded-sm bg-miru-gray-100 p-1 text-sm placeholder:text-miru-gray-1000"
initTime={duration}
name="timeInput"
onTimeChange={handleDurationChange}
/>

TimeInput Component Props

NameDescriptionDefault Value
initTimeProvide the initial time value for the input string""
disabledTo set input as disabled boolfalse
onTimeChangeTo specify the action to be triggered on changing of the input value func-
placeholderProvide the input placeholder value string"HH:MM"
classNameTo provide external classnames to input string""
nameProvide the name for the input string""