Docs
useInputValue

A hook to manage input values with useInputValue.

Loading...

Installation

pnpm dlx shadcn@latest add https://usekit.kiron.dev/k/use-input-value

Usage

"use client"
 
import * as React from "react"
 
import { useInputValue } from "@/hooks/use-input-value"
 
export function Component() {
  const name = useInputValue("useKit")
 
  return (
    <div>
      <input
        style={{
          borderRadius: "0.5rem",
          backgroundColor: "rgba(229, 231, 235, 0.2)",
          border: "1px solid rgba(229, 231, 235, 0.2)",
        }}
        {...name}
      />
      <p>Hello, {name.value}!</p>
    </div>
  )
}

API Reference

Parameters

NameTypeDescriptionDefault ValueOptional
initialstring | number | boolean | null | undefinedThe initial value of the input.""Yes

Return Values

NameTypeDescription
valuestringThe current value of the input.
onChangeReact.ChangeEventHandlerThe event handler to update the value of the input.