Input

General


Input
Through mouse or keyboard input content, it is the most basic form field wrapper.

Show Code
import React from "react"; 
import Input from "pocko-ui/Input";
 
const inputFocusRef = useRef(null);
 
return (
  <div className="mt-4">
    <Input label="Title" wrapperClassName="mb-1" />
 
    <Input label="disabled" defaultValue={"disabled"} wrapperClassName="mb-1" disabled />
 
    <Input label="number" type="number" wrapperClassName="mb-1" />
 
    <Input
      inputRef={inputFocusRef}
      label={
        <>
          <button
            className="btn btn-sm btn-primary"
            onClick={() => {
              if (inputFocusRef.current) inputFocusRef.current.focus();
            }}
          >
            ref focus
          </button>
        </>
      }
      iconLeft={<i className="fa-solid fa-left-long"></i>}
      iconRight={<i className="fa-solid fa-right-long"></i>}
      wrapperClassName="mb-1"
    />
  </div>
);

No spacing


Show Code
import React from "react"; 
import Input from "pocko-ui/Input";
 
return (
  <div className="mt-4">
    <Input defaultValue={'no-spacing'} wrapperClassName="" />
 
    <Input defaultValue={'no-spacing'} wrapperClassName="position-relative" />
  </div>
);

Date or DateTime


Show Code
import React from "react"; 
import Input from "pocko-ui/Input";
 
return (
  <div className="mt-4">
    <Input label="Date" type="date" wrapperClassName="mb-2" />
 
    <Input label='DateTime' type="datetime-local" wrapperClassName="mb-2" />
 
    <Input label="Time" type="time" wrapperClassName="mb-2" />
  </div>
);

Keyboard Control


Show Code
import React from "react"; 
import Input from "pocko-ui/Input";
 
return (
  <div className="mt-4">
    <Input
      label="Ctrl Pressed"
      type="text"
      onPressEnter={(item: any) => {
        if (item.key == "Control") {
          alert("Ctrl pressed!");
        }
      }}
    />
  </div>
);

API


Input
import Input from 'pocko-ui/Input';
PropertyTypeDefaultDescriptionRequired
inputRefany-A ref object that allows external components to programmatically focus the input field.-
idstring-The unique identifier for the input field. This is used to target the element in forms or labels.-
namestring-The name associated with the input field. It is used to reference form data after form submission.-
sizestring | number-Defines the width of the input field. Can be a string (e.g., 'small', 'large') or a number (e.g., 100 for pixel value).-
labelstring | React.ReactNode-The label to be displayed for the input field. Can be a string or React component.-
labelClassNamestring-The class name for the label element. Used to style the label of the input field.-
wrapperClassNamestring-The class name for the outer wrapper of the input field.-
controlGroupWrapperClassNamestring-The class name for the input group wrapper.-
controlGroupTextClassNamestring-The class name for the input group text.-
iconLeftReact.ReactNode | string-The icon or content to be displayed on the left side of the input field.-
iconRightReact.ReactNode | string-The icon or content to be displayed on the right side of the input field.-
controlClassNamestring-The class name for the input element itself.-
typestring"text"The type of the input field, such as 'text', 'password', or 'email'.-
disabledboolean-Whether the input is disabled or not.-
readonlyboolean-Whether the input is read-only or not.-
requiredboolean-Whether the input is required.-
requiredLabelstring | any-The label or message to be shown when the input is required.-
defaultValuestring | any-The initial value of the input field.-
placeholderstring-The placeholder text to be displayed in the input field.-
autoComplete"on" | "off""on"Whether the input field allows autocomplete. The default is "on".-
minnumber-The minimum value for input[type="number"].-
maxnumber-The maximum value for input[type="number"].-
stepnumber-The step increment for input[type="number"].-
onChange(value: string) => void-The callback function to be triggered when the value of the input field changes.-
onBlur() => void-The callback function to be triggered when the input field loses focus.-
onFocus() => void-The callback function to be triggered when the input field gains focus.-
onPressEnterFunction | any-The callback function to be triggered when the Enter key is pressed in the input field.-