Tag Input

Note: Enter or space to add an element

General


      Show Code
      import React from "react";
      import TagInput from 'funda-ui/TagInput';
       
      // component styles
      import 'funda-ui/TagInput/index.css';
       
      export default () => {
       
          return (
              <>
                
                  <TagInput 
                      placeholder="Add tag..." 
                      name="tagInput-name-1" 
                      onChange={(e, data, dataStr) => {
                          console.log(e, data, dataStr);
                          /*
                          <input ... placeholder="Add tag..." value="">,
                          [
                              {
                                  "content": "1",
                                  "id": 0
                              },
                              {
                                  "content": "3",
                                  "id": 1
                              },
                              {
                                  "content": "34",
                                  "id": 2
                              }
                          ],
                          '[1][3][34]'
                          */
                      }}
                  />
       
       
                  <TagInput 
                      placeholder="Add tag..." 
                      name="tagInput-name-2" 
                      maxTags={5} 
                      value="[tag1][tag2]"
                  />
       
                  
              </>
          );
      }

      No spacing


          Show Code
          import React from "react";
          import TagInput from 'funda-ui/TagInput';
           
          // component styles
          import 'funda-ui/TagInput/index.css';
           
           
          export default () => {
           
           
              return (
                  <>
           
                      <TagInput
                          ...
                          wrapperClassName="position-relative"
                          ...
                      />
           
                       <TagInput
                          ...
                          wrapperClassName=""
                          ...
                      />
           
                  </>
              );
          }

          API

          Tag Input

          import TagInput from 'funda-ui/TagInput';
          PropertyTypeDefaultDescriptionRequired
          refReact.ForwardedRef-It is the return element of this component.-
          wrapperClassNamestringmb-3 position-relativeThe class name of the control wrapper.-
          extractValueByBracketsbooleantrueWhether to use square brackets to save result and initialize default value.-
          maxTagsnumber10Maximum number of tags that can be added.-
          valuestring-Set a default value for this control. Please separate multiple values with square brackets. Such as [tag1][tag2][tag3]
          If extractValueByBrackets is false, the default value will be separated by comma, such as
          tag1,tag2,tag3
          -
          requiredLabelstring | ReactNode<span className="position-absolute end-0 top-0 my-2 mx-2"><span className="text-danger">*</span></span>It is used to specify a label for an element required.-
          labelstring | ReactNode-It is used to specify a label for an element of a form.
          Support html tags
          -
          namestring-Name is not deprecated when used with form fields.-
          placeholderstring-Specifies a short hint that describes.-
          autoCompletestringoffThe autocomplete attribute provides a hint to the user agent specifying how to, or indeed whether to, prefill a form control.-
          autoCapitalizestringoffThe autocapitalize property of the HTMLElement interface represents the element's capitalization behavior for user input.-
          spellCheckbooleanfalseThe spellcheck global attribute is an enumerated attribute that defines whether the element may be checked for spelling errors.-
          maxLengthnumber-Defines the maximum string length that the user can enter into it.-
          minLengthnumber-Defines the minimum string length that the user can enter into it.-
          disabledbooleanfalseWhether it is disabled-
          requiredbooleanfalseWhen present, it specifies that a field must be filled out before submitting the form.-
          onChangefunction-Call a function when the value of an HTML element is changed. It returns three callback values.
          1. The first is the control (HTML Element)
          2. The second is the current value (Array)
          3. The third is the current string value (String)
          -
          onBlurfunction-Call a function when a user leaves a form field. It returns only one callback value which is the Control Event (Event)-
          onFocusfunction-Call a function when an form field gets focus. It returns only one callback value which is the Control Event (Event)-

          It accepts all props which this control support. Such as style, data-*, tabIndex, id, and so on.