
Research
2025 Report: Destructive Malware in Open Source Packages
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.
@leafygreen-ui/text-input
Advanced tools
pnpm add @leafygreen-ui/text-input
yarn add @leafygreen-ui/text-input
npm install @leafygreen-ui/text-input
| Package | Version |
|---|---|
@leafygreen-ui/leafygreen-provider | ^1.1.0 |
import TextInput from '@leafygreen-ui/text-input';
const [value, setValue] = useState('');
return (
<TextInput
label="Email"
description="Enter your email below"
placeholder="your.email@example.com"
onChange={event => {
/* Something to handle the change event */
}}
value={value}
/>
);
| Prop | Type | Description | Default |
|---|---|---|---|
id | string | id associated with the TextInput component. | |
label | string | Text shown in bold above the input element. | |
description | string | Text that gives more detail about the requirements for the input. | |
optional | boolean | Marks the input as optional | false |
disabled | boolean | Disabled the input | false |
onChange | function | The event handler function for the 'onchange' event. Accepts the change event object as its argument and returns nothing. | |
onBlur | function | The event handler function for the 'onblur' event. Accepts the focus event object as its argument and returns nothing. | |
placeholder | string | The placeholder text shown in the input field before the user begins typing. | |
errorMessage | string | Text that gives more detail about the requirements for the input. | 'This input needs your attention' |
successMessage | string | Text that indicates that the requirements for the input are met. | 'Success' |
state | 'none', 'valid', 'error' | Describes the state of the TextInput element before and after the input has been validated | 'none' |
value | string | Sets the HTML value attribute. | '' |
className | string | Adds a className to the class attribute. | '' |
type | 'email', 'password', 'search', 'text', 'url', 'tel', 'number' | Sets type for TextInput | 'text' |
darkMode | boolean | Determines whether or not the component will appear in dark mode. | false |
sizeVariant | 'xsmall', 'small', 'default', 'large', | Sets the side padding, text size, and input height. | default |
baseFontSize | 14, 16 | Determines the base font-size of the component if the sizeVariant prop is set to default | 14 |
| ... | native input attributes | Any other props will be spread on the root input element |
Either label or aria-labelledby must be provided a string, or there will be a console error. This is to ensure that screenreaders have a description for what the Text Input does.
getTestUtils() is a util that allows consumers to reliably interact with LG TextInput in a product test suite. If the TextInput component cannot be found, an error will be thrown.
import TextInput, { getTestUtils } from '@leafygreen-ui/text-input';
const utils = getTestUtils(lgId?: string); // lgId refers to the custom `data-lgid` attribute passed to `TextInput`. It defaults to 'lg-text_input' if left empty.
TextInputimport { render } from '@testing-library/react';
import TextInput, { getTestUtils } from '@leafygreen-ui/text-input';
...
test('text-input', () => {
render(<TextInput label="label" value="text input" />);
const { getInput, getInputValue } = getTestUtils();
expect(getInput()).toBeInTheDocument();
expect(getInputValue()).toBe('text input');
});
TextInput'sWhen testing multiple TextInput's it is recommended to add the custom data-lgid attribute to each TextInput.
import { render } from '@testing-library/react';
import TextInput, { getTestUtils } from '@leafygreen-ui/text-input';
...
test('text-input', () => {
render(
<>
<TextInput data-lgid="text-input-1" label="label 1" />
<TextInput data-lgid="text-input-2" label="label 2" value="text input" />
</>,
);
const utilsOne = getTestUtils('text-input-1'); // data-lgid
const utilsTwo = getTestUtils('text-input-2'); // data-lgid
// First TextInput
expect(utilsOne.getInput()).toBeInTheDocument();
expect(utilsOne.getInputValue()).toBe('');
// Second TextInput
expect(utilsTwo.getInput()).toBeInTheDocument();
expect(utilsTwo.getInputValue()).toBe('text input');
});
import { render } from '@testing-library/react';
import Toggle, { getTestUtils as getToggleTestUtils } from '@leafygreen-ui/toggle';
import TextInput, { getTestUtils as getTextInputTestUtils } from '@leafygreen-ui/text-input';
import TextArea, { getTestUtils as getTextAreaTestUtils } from '@leafygreen-ui/text-area';
...
test('Form', () => {
render(
<Form>
<Toggle aria-label="Toggle label" />
<TextInput label="TextInput label" />
<TextArea label="TextArea label" />
</Form>,
);
const toggleInputUtils = getToggleTestUtils();
const textInputUtils = getTextInputTestUtils();
const textAreaUtils = getTextAreaTestUtils();
// LG Toggle
expect(toggleInputUtils.getInput()).toBeInTheDocument();
expect(toggleInputUtils.getInputValue()).toBe('false');
// LG TextInput
expect(textInputUtils.getInput()).toBeInTheDocument();
expect(textInputUtils.getInputValue()).toBe('');
// LG TextArea
expect(textAreaUtils.getInput()).toBeInTheDocument();
expect(textAreaUtils.getInputValue()).toBe('');
});
const {
getInput,
getLabel,
getDescription,
getErrorMessage,
getInputValue,
isDisabled,
isValid,
isError,
isOptional,
} = getTestUtils();
| Util | Description | Returns |
|---|---|---|
getInput | Returns the input node | HTMLButtonElement |
getLabel | Returns the label node | HTMLButtonElement | null |
getDescription | Returns the description node | HTMLButtonElement | null |
getErrorMessage | Returns the error message node | HTMLButtonElement | null |
getInputValue | Returns the input value | string |
isDisabled | Returns whether the input is disabled | boolean |
isValid | Returns whether the input state is valid | boolean |
isError | Returns whether the input state is error | boolean |
isOptional | Returns whether the input is optional | boolean |
FAQs
leafyGreen UI Kit Text Input
The npm package @leafygreen-ui/text-input receives a total of 16,110 weekly downloads. As such, @leafygreen-ui/text-input popularity was classified as popular.
We found that @leafygreen-ui/text-input demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
Destructive malware is rising across open source registries, using delays and kill switches to wipe code, break builds, and disrupt CI/CD.

Security News
Socket CTO Ahmad Nassri shares practical AI coding techniques, tools, and team workflows, plus what still feels noisy and why shipping remains human-led.

Research
/Security News
A five-month operation turned 27 npm packages into durable hosting for browser-run lures that mimic document-sharing portals and Microsoft sign-in, targeting 25 organizations across manufacturing, industrial automation, plastics, and healthcare for credential theft.