@navikt/tag-input
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

Tag-input

Simple react component for tag-input fields.

Exposes a simple react-component that can be used as a simple text-input-field, but will parse and render words prefixed with # as tags.

function Test() {
    const [text, setText] = useState('');
    return (
        <TagInput
              name="test"
              value={text}
              onChange={(e) => setText(e.target.value)}
        />
    );
}

Exposes a utility function to parse the content of text: parseTekst

import {parseTekst} from "./tag-input";

const text = "#test #one some query";
const parsed = parseTekst(text);
console.log(parsed);
// {
//     tags: ['test', 'one'],
//     text: 'some query'
// }

Styling

The application utilizes styling from the follow packages:

nav-frontend-core
nav-frontend-knapper-style
nav-frontend-lenker-style
nav-frontend-paneler-style
nav-frontend-skjema-style
nav-frontend-typografi-style

Readme

Keywords

none

Package Sidebar

Install

npm i @navikt/tag-input

Weekly Downloads

27

Version

2.0.1

License

MIT

Unpacked Size

25.9 kB

Total Files

9

Last publish

Collaborators

  • nutgaard