Back to Twenty

Text

packages/twenty-docs/twenty-ui/input/text.mdx

2.2.03.7 KB
Original Source
<Frame> </Frame>

Text Input

Allows users to enter and edit text.

<Tabs> <Tab title="Usage">
jsx
import { TextInput } from "@/ui/input/components/TextInput";

export const MyComponent = () => {
  const handleChange = (text) => {
    console.log("Input changed:", text);
  };

  const handleKeyDown = (event) => {
    console.log("Key pressed:", event.key);
  };

  return (
    <TextInput
      className
      label="Username"
      onChange={handleChange}
      fullWidth={false}
      disableHotkeys={false}
      error="Invalid username"
      onKeyDown={handleKeyDown}
      RightIcon={null}
    />
  );
};

</Tab> <Tab title="Props">
PropsTypeDescription
classNamestringOptional name for additional styling
labelstringRepresents the label for the input
onChangefunctionThe function called when the input value changes
fullWidthbooleanIndicates whether the input should take up 100% of the width
disableHotkeysbooleanIndicates whether hotkeys are enabled for the input
errorstringRepresents the error message to be displayed. When provided, it also adds an icon error on the right side of the input
onKeyDownfunctionCalled when a key is pressed down while the input field is focused. Receives a React.KeyboardEvent as an argument
RightIconIconComponentAn optional icon component displayed on the right side of the input

The component also accepts other HTML input element props.

</Tab> </Tabs>

Autosize Text Input

Text input component that automatically adjusts its height based on the content.

<Tabs> <Tab title="Usage">
jsx
import { AutosizeTextInput } from "@/ui/input/components/AutosizeTextInput";

export const MyComponent = () => {
  return (
    <AutosizeTextInput
      onValidate={() => console.log("onValidate function fired")}
      minRows={1}
      placeholder="Write a comment"
      onFocus={() => console.log("onFocus function fired")}
      variant="icon"
      buttonTitle
      value="Task: "
    />
  );
};
</Tab> <Tab title="Props">
PropsTypeDescription
onValidatefunctionThe callback function you want to trigger when the user validates the input
minRowsnumberThe minimum number of rows for the text area
placeholderstringThe placeholder text you want to display when the text area is empty
onFocusfunctionThe callback function you want to trigger when the text area gains focus
variantstringThe variant of the input. Options include: default, icon, and button
buttonTitlestringThe title for the button (only applicable for the button variant)
valuestringThe initial value for the text area
</Tab> </Tabs>

Text Area

Allows you to create multi-line text inputs.

<Tabs> <Tab title="Usage">
jsx
import { TextArea } from "@/ui/input/components/TextArea";

export const MyComponent = () => {
  return (
    <TextArea
    disabled={false}
    minRows={4}
    onChange={()=>console.log('On change function fired')}
    placeholder="Enter text here"
    value=""
    />
  );
};
</Tab> <Tab title="Props">
PropsTypeDescription
disabledbooleanIndicates whether the text area is disabled
minRowsnumberMinimum number of visible rows for the text area.
onChangefunctionCallback function triggered when the text area content changes
placeholderstringPlaceholder text displayed when the text area is empty
valuestringThe current value of the text area
</Tab> </Tabs>