1.5.1 • Published 9 months ago

@arif-un/react-mix-tag-input v1.5.1

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

React Mix Tag Input

A react input component that pairs text with tags, supports multiline entry, and provides customizable tag rendering.

Full Documentation

mix tag input example

Installation

npm install @arif-un/react-mix-tag-input
import  MixTagInput  from  "mix-tag-input";

const  [value, setValue]  =  useState<MixInputValues>([
  [ "Text ",  {type:  "tag", attrs:  {id:  "1", label:  "Tag"}} ]
]);

<MixTagInput  value={value}  onChange={handleChange}  />

Props

<MixTagInput />

PropDescriptionDefaultType
refReact forwardRef with options of componentMixInputRef
valueValues of Mix Input[]MixInputValues
onChangeFunction to handle the change event(value: MixInputValues) => void
disabledBoolean value to set the input as disabledfalseBoolean
placeholderPlaceholder textstring
immediatelyRenderBoolean value to render the component immediately on mount. Useful for server side renderingfalseBoolean
tagClassNameClass name for tagsmi-tagstring
editorOptionsOptions for the editor{}Editor
tagAttrsAllowed attributes for tags, that returns with tag value on change and also render as data-* attribute{ key: string: string }
tagViewCustom tag view componentReact.FC[TagViewProps](https://tiptap.dev/docs/editor/extensions/custom-extensions/node-views/react#all-available-props)

MixInputRef: React.forwardRef

import { type MixInputRef } from '@arif-un/react-mix-tag-input';

const ref = useRef<MixInputRef>(null);

// ...
ref.current?.insertContent({ type: 'tag', attrs: { id: '1', label: 'Tag' } });
// ...

return <MixTagInput ref={ref} />;
PropDescriptionType
insertContentFunction to insert content in the editor current caret position, accepts Tag or Text alone or in array(content: Tag | string | (Tag | string)[]) => void
elementReturns the editor elementHTMLDivElement
editorReturns the editor instanceEditor

MixInputValues: (string | Tag)

const text =  'Any text string'

const tag:  Tag  =  {
 type:  'tag',
 attrs:  {
   id:  '1',
   label:  'Tag',
   className:  'tag-class',
   style:  {color:  'cyan'}
   [key:  string]:  string  // key and default value need to specify in 'tagAttrs' prop
  },
}

const firstLineValues:  MixInputValues  =  [[ text, tag ]]

return  <MixTagInput  value={firstLineValues}  />;

Tag

PropDescriptionType
typeType of the tag'tag'
attrsAttributes of the tagobject
attrs.idUnique identifier of the tagstring
attrs.labelLabel of the tagstring
attrs.classNameClass name of the tagstring
attrs.styleStyle of the tagReact.CSSProperties
attrs.key: stringAny other attribute. Key and default value need to specify in tagAttrs prop in order to get back with tag value on change and also render as data-* attributestring
1.5.1

9 months ago

1.5.0

9 months ago

1.4.1

10 months ago

1.4.0

10 months ago

1.3.3

1 year ago

1.3.2

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

1.2.1

1 year ago

1.2.0

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.17

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.6

1 year ago

1.0.4

1 year ago

1.0.0

1 year ago