Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

search-textfield

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

search-textfield

React component that works like a search text field, when user is typing, options will be displayed. Vanila React, no extra dependencies.

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

React Search Textfield

React component that works like a search text field, when user is typing, options will be displayed. Vanila React, no extra dependencies.

How to use it

Here is an example of implemention of the component:

function App() {
    const [value, setValue] = useState<string>("");

    return (
        <div className="App">
            <SearchTextField
                items={["Item 1", "Item 2", "Item 3"]}
                onChange={(e) => setValue(e.target.value)}
                onClickItem={(selectedItem: string) => setValue(selectedItem)}
                name={"input"}
                value={value}
                inputStyles={{ width: "200px" }}
                itemStyles={{ textAlign: "left" }}
            />
        </div>
    );
}

SearchTextField has some props that help developer to customize this component:

  • items: Options that user see when is typing inside the textfield. This field should be an array of strings.
  • onChange: This prop receive a callback that it will be executed each time user changes the value of the text field.
  • onClickItem: This prop receive a callback that il will be executed when user clicks on one of the options.
  • name: This is the name of the text field. This prop affects the value of event.target.name in the callback parameter of onChange prop.
  • value: It's the value of the text field.
  • inputStyles: This prop can override the styles of the text field. You could use an empty object if you wish.
  • itemStyles: This prop can override the styles of each option that will be displayed when user is typing inside the text field. You could use an empty object if you wish.

Recommendations and comments

If you have a recommendation, you can make an issue on GitHub repository: react-search-textfield repository

Feel free to collaborate in this project making a PR or request to be a collaborator of the repository.

Keywords

FAQs

Package last updated on 25 May 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc