
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
react-bootstrap-typeahead
Advanced tools
The react-bootstrap-typeahead package is a flexible, robust, and highly customizable typeahead (autocomplete) component for React. It is built using Bootstrap styles and provides a variety of features to enhance user experience in form inputs.
Basic Typeahead
This feature allows you to create a basic typeahead input where users can type and get suggestions from a predefined list of options.
import React from 'react';
import { Typeahead } from 'react-bootstrap-typeahead';
const options = ['John', 'Paul', 'George', 'Ringo'];
function BasicTypeahead() {
return (
<Typeahead
id="basic-typeahead"
labelKey="name"
options={options}
placeholder="Choose a name..."
/>
);
}
export default BasicTypeahead;
Multiple Selections
This feature allows users to select multiple options from the typeahead suggestions, making it useful for forms that require multiple inputs.
import React from 'react';
import { Typeahead } from 'react-bootstrap-typeahead';
const options = ['John', 'Paul', 'George', 'Ringo'];
function MultiSelectTypeahead() {
return (
<Typeahead
id="multi-select-typeahead"
labelKey="name"
multiple
options={options}
placeholder="Choose several names..."
/>
);
}
export default MultiSelectTypeahead;
Custom Rendering
This feature allows you to customize the rendering of the typeahead options, providing more control over the appearance and behavior of the suggestions.
import React from 'react';
import { Typeahead } from 'react-bootstrap-typeahead';
const options = [
{ id: 1, name: 'John' },
{ id: 2, name: 'Paul' },
{ id: 3, name: 'George' },
{ id: 4, name: 'Ringo' }
];
function CustomRenderTypeahead() {
return (
<Typeahead
id="custom-render-typeahead"
labelKey="name"
options={options}
placeholder="Choose a Beatle..."
renderMenuItemChildren={(option, props) => (
<div>
<span>{option.name}</span>
</div>
)}
/>
);
}
export default CustomRenderTypeahead;
react-autosuggest is a popular package for building autocomplete and autosuggest components in React. It offers a high degree of customization and flexibility, similar to react-bootstrap-typeahead, but does not rely on Bootstrap for styling.
downshift is a highly customizable library for building autocomplete, dropdown, and select components in React. It provides a set of primitives to build complex components, offering more flexibility but requiring more setup compared to react-bootstrap-typeahead.
react-select is a flexible and beautiful Select Input control for React with support for multi-select, async options, and more. It is highly customizable and provides a rich set of features, making it a strong alternative to react-bootstrap-typeahead.
React-based typeahead component that uses Bootstrap as a base for styles and behaviors and supports both single- and multi-selection. The UI and behaviors are inspired by Twitter's typeahead.js. Try a live example.
Please note that this library is under active development and the APIs may change. The documentation below applies to the most recent version and may no longer be applicable if you're using an outdated version.
Use NPM to install the module in your project:
$ npm install --save react-bootstrap-typeahead
Include the module in your project as you normally would:
// Using ES2015 modules
import Typeahead from 'react-bootstrap-typeahead';
// Using CommonJS (Note: you must add `.default`)
var Typeahead = require('react-bootstrap-typeahead').default;
Minified and unminified UMD modules are also included in the NPM package, or you can get them from CDNJS.
A pre-release of v1.0 is now available. The code is reasonably stable, but could use some additional real-world testing. New examples and better documentation are currently the main things gating a full release. The latest stable version is v0.10.4.
This version has some breaking changes. Please see the release notes for more information. In particular, there is no longer a default Typeahead
component:
// v1.0
import {Typeahead} from 'react-bootstrap-typeahead'; // ES2015
var Typeahead = require('react-bootstrap-typeahead').Typeahead; // CommonJS
The component tries to use as little CSS as possible, relying primarily on Bootstrap or any Bootstrap themes for styling. Some minimal styling is included in Typeahead.css
and Token.css
and should ideally be included wherever you're using the component.
To modify the example, clone the repository, npm install
and npm run example
to build the example index file. You can then open the HTML file locally in a browser. You can also try the live example.
Recent versions of the following browsers are supported:
FAQs
React typeahead with Bootstrap styling
The npm package react-bootstrap-typeahead receives a total of 134,166 weekly downloads. As such, react-bootstrap-typeahead popularity was classified as popular.
We found that react-bootstrap-typeahead demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.