![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
react-tag-autocomplete
Advanced tools
React Tag Autocomplete is a simple tagging component ready to drop in your React projects.
React Tag Autocomplete is a simple tagging component ready to drop in your React projects. Originally based on the React Tags project by Prakhar Srivastav this version removes the drag-and-drop re-ordering functionality, adds appropriate roles and ARIA states and introduces a resizing text input.
The preferred way of using the component is via NPM
npm install --save react-tag-autocomplete
Here's a sample implementation that initializes the component with a list of preselected tags
and a suggestions
list. For more details, go through the API.
var ReactTags = require('react-tag-autocomplete');
var App = React.createClass({
getInitialState: function () {
return {
tags: [
{ id: 1, name: "Apples" },
{ id: 2, name: "Pears" }
],
suggestions: [
{ id: 3, name: "Bananas" },
{ id: 4, name: "Mangos" },
{ id: 5, name: "Lemons" },
{ id: 6, name: "Apricots" }
]
}
},
handleDelete: function (i) {
var tags = this.state.tags
tags.splice(i, 1)
this.setState({ tags: tags })
},
handleAddition: function (tag) {
var tags = this.state.tags
tags.push(tag)
this.setState({ tags: tags })
},
render: function () {
return (
<ReactTags
tags={this.state.tags}
suggestions={this.state.suggestions}
handleDelete={this.handleDelete}
handleAddition={this.handleAddition} />
)
}
})
React.render(<App />, document.getElementById('app'))
tags
suggestions
placeholder
autofocus
autoresize
minQueryLength
maxSuggestionsLength
classNames
handleAddition
handleDelete
handleInputChange
allowNew
An array of tags that are displayed as pre-selected. Each tag must have an id
and a name
property. Default: []
.
var tags = [
{ id: 1, name: "Apples" },
{ id: 2, name: "Pears" }
]
An array of suggestions that are used as basis for showing suggestions. Each suggestion must have an id
and a name
property and an optional disabled
property. Default: []
.
var suggestions = [
{ id: 3, name: "Bananas" },
{ id: 4, name: "Mangos" },
{ id: 5, name: "Lemons" },
{ id: 6, name: "Apricots", disabled: true }
]
The placeholder string shown for the input. Default: 'Add new tag'
.
Boolean parameter to control whether the text-input should be autofocused on mount. Default: true
.
Boolean parameter to control whether the text-input should be automatically resized to fit its value. Default: true
.
How many characters are needed for suggestions to appear. Default: 2
.
Maximum number of suggestions to display. Default: 6
.
Override the default class names. Defaults:
{
root: 'react-tags',
selected: 'react-tags__selected',
selectedTag: 'react-tags__selected-tag',
selectedTagName: 'react-tags__selected-tag-name',
search: 'react-tags__search',
searchInput: 'react-tags__search-input',
suggestions: 'react-tags__suggestions',
isActive: 'is-active',
isDisabled: 'is-disabled'
}
Function called when the user wants to add a tag. Receives the tag.
function (tag) {
// Add the tag { id, name } to the tag list
tags.push(tag)
}
Function called when the user wants to delete a tag. Receives the tag index.
function (i) {
// Delete the tag at index i
tags.splice(i, 1)
}
Optional event handler when the input changes. Receives the current input value.
function (input) {
if (this.state.busy) {
return
} else {
this.setState({ busy: true })
return fetch(`query=${input}`).then(function (result) {
this.setState({ busy: false })
})
}
}
Allows users to add new (not suggested) tags. Default: false
.
It is possible to customize the look of the component the way you want it. An example can be found in /example/styles.css
.
The component is written in ES6 and uses Webpack as its build tool.
npm install
npm run dev # open http://localhost:8080
FAQs
A simple, accessible, tagging component ready to drop into your React projects.
The npm package react-tag-autocomplete receives a total of 351 weekly downloads. As such, react-tag-autocomplete popularity was classified as not popular.
We found that react-tag-autocomplete 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.