react-input-placeholder-chips
v0.1.0
Published
React input component with insertable placeholder chips like {{candidateName}}.
Maintainers
Readme
react-input-placeholder-chips
React input component with insertable placeholder chips (for example {{candidateName}}).
Install
npm install react-input-placeholder-chipsUsage
import { useState } from "react";
import { InputWithPlaceholderChips } from "react-input-placeholder-chips";
import "react-input-placeholder-chips/style.css";
export default function Example() {
const [value, setValue] = useState("");
return (
<InputWithPlaceholderChips
id="template-message"
name="templateMessage"
value={value}
onChange={(e) => setValue(e.target.value)}
placeholder="Type message and insert placeholders..."
placeholderChips={[
{ label: "Candidate Name", value: "candidateName" },
{ label: "Hiring Manager", value: "hiringManager" },
]}
/>
);
}Props
value: string- Controlled value containing text and placeholders.onChange: (event) => void- Called with serialized output ({{token}}format).placeholder?: string- Placeholder shown when empty.placeholderChips?: Array<{ label: string; value: string } | string>- Chips the user can insert from the + menu. Each item is either{ label, value }(menu showslabel, inserted token isvalue) or a string (used as both label and token). Example strings:["candidateName", "jobTitle"].placeholderMeta?- Same asplaceholderChips(older name). If both are set,placeholderChipswins.disabled?: booleanid?: stringname?: stringclassName?: string
Local development
npm install
npm run devBuild package
npm run build:packageThis outputs publishable files in dist/.
Publish to npm
- Login:
npm login - (Optional) Dry run:
npm publish --dry-run - Publish:
npm publish --access public
