---
title: InputTag
---

import LibraryInfo from '@theme/LibraryInfo'
import { Feedback, FigmaEmbed, PropsTable } from '../../src/components'
import { InputTag } from '@telus-uds/components-community'
import { InputTag as InputTagDocs } from 'docs/@telus-uds/components-community'
import AvailableOnBoth from '../../partials/_platform-considerations-both.mdx'
import NoStylisticVariants from '../../partials/_variants-none.mdx'

# InputTag

<LibraryInfo
  packageType="Multi-Platform Component"
  packageName="components-community.input-tag"
  compatibility={['React 18']}
  figmaLink="https://www.figma.com/file/JmDVYTCFyLcPObNGOA7V7w/PM-Mobile-App---Clearbridge?type=design&node-id=3122-11398&mode=design&t=Y8tjAduzIxOT47rv-0"
/>

```jsx live
<InputTag onButtonPress={() => true} placeholder="Text here" buttonLabel="Apply" />
```

## Introduction

InputTag is combination of TextInput field, Action button , Tags and error message text.

It receives user's input and displays as a Tag above the TextInput field through action button.

[Follow the appropriate instructions](importing-components) to add this component in to your app.

## Guidance

### Using custom textinput and custom button

Even though component displays a TextInput and Button by default, you can use it with a custom input and button component, for example:

```jsx live
function customInput(args) {
  const [inputText, setInputText] = useState('')
  const [tagArray, setTagArray] = useState([{ id: 'UDS', label: 'UDS' }])
  return (
    <InputTag
      {...args}
      placeholder="Text here"
      buttonLabel="Apply"
      tagArray={tagArray}
      setTagArray={setTagArray}
      inputText={inputText}
      setInputText={setInputText}
      customTextInput={({ value, onChange, editable, style }) => (
        <TextInput value={value} onChange={onChange} placeholder="Promo Code" editable={editable} />
      )}
      customButton={({ onPress, disabled, label }) => (
        <Button
          onPress={onPress}
          disabled={disabled}
          tokens={{
            height: 45,
            fontSize: 20
          }}
        >
          {label}
        </Button>
      )}
      onButtonPress={(code) => true}
    />
  )
}
```

### Using custom error message

We can add custom error message like this:

```jsx live
function customInput(args) {
  const [inputText, setInputText] = useState('')
  const [error, setError] = useState('')
  const [tagArray, setTagArray] = useState([])
  return (
    <InputTag
      {...args}
      placeholder="Text here"
      buttonLabel="Apply"
      setTagArray={setTagArray}
      inputText={inputText}
      setInputText={setInputText}
      customTextInput={({ value, onChange, editable, style }) => (
        <TextInput value={value} onChange={onChange} placeholder="Promo Code" editable={editable} />
      )}
      onButtonPress={(code) => {
        if (!code || tagArray.some((item) => item.id === code)) {
          setError('Enter valid text')
          return false
        }
        setError('')
        return true
      }}
      errorMessage={error}
      customErrorMessage={({ errorMessage }) => (
        <Typography variant={{ colour: 'danger' }}>{errorMessage}</Typography>
      )}
    />
  )
}
```

### Platform considerations

<AvailableOnBoth />

## Props

<PropsTable base={InputTagDocs} />

## Variants

<NoStylisticVariants />

## Feedback

<Feedback component="InputTag" />
