
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
A simple, lightweight, and no-dependency library for repeating elements with a button click. Useful for input groups in forms that need to be repeated so the user can submit an arbitrary number of items.
A simple, lightweight, and no-dependency library for repeating elements with a button click. Useful for input groups in forms that need to be repeated so the user can submit an arbitrary number of items.
npm install repeatable
or
yarn add repeatable
<ul>
<li class="person-template">
<input name='people[][firstName]' placeholder='First Name' />
<input name='people[][lastName]' placeholder='Last Name' />
<button class="remove-person">Remove person</button>
</li>
</ul>
<button class="add-person">Add person</button>
import Repeatable from 'repeatable'
new Repeatable({
template: `.person-template`,
button: `.add-person`,
removeButton: `.remove-person`,
incrementInputs: true,
})
If you want to show a message when there are no elements, you can pass an emptyState option. It accepts either a query selector string or an element. This element will show when there are no elements and hide when there are.
<div class="empty-state">No people added yet.</div>
new Repeatable({
// ...
emptyState: `.empty-state`,
})
Set startEmpty to true to start with no elements and an empty state.
new Repeatable({
// ...
startEmpty: true,
})
Set min and max to limit the number of elements that can be added. If min is set, the remove button will be disabled when there are fewer than that number of elements. If max is set, the add button will be disabled when there are more than that number of elements.
new Repeatable({
// ...
min: 3,
max: 6,
})
You can pass functions to onCreate and onRemove to run when an element is created or removed. The element that was added or removed gets passed so you can manipulate the value, name attribute, etc.
new Repeatable({
// ...
onCreate: (element) => {
console.log(`Added element:`, element)
},
onRemove: (element) => {
console.log(`Removed element:`, element)
},
})
If you have multiple repeatable elements on the same page, you can set incrementInputs to true to increment the [] part of the name attributes in all inputs in the template. This is useful if you want to submit the data as an array of objects.
<ul>
<li class="person-template">
<input name='people[][firstName]' placeholder='First Name' />
<input name='people[][lastName]' placeholder='Last Name' />
<button class="remove-person">Remove person</button>
</li>
</ul>
new Repeatable({
// ...
incrementInputs: true,
})
FAQs
A simple, lightweight, and no-dependency library for repeating elements with a button click. Useful for input groups in forms that need to be repeated so the user can submit an arbitrary number of items.
The npm package repeatable receives a total of 1 weekly downloads. As such, repeatable popularity was classified as not popular.
We found that repeatable demonstrated a not healthy version release cadence and project activity because the last version was released 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.