Taglist

import Taglist from 'frui/fields/Taglist';
Copy

Props

The following props are accepted by Taglist.

NameTypeRequiredNotes
classNamestringNoStandard HTML class names
colorstringNoCustom background color for tags
dangerbooleanNoRed background color for tags
infobooleanNoBlue background color for tags
defaultValuestring[]NoDefault value (uncontrolled)
errorstring|booleanNoAny error message
mutedbooleanNoGray background color for tags
namestringNoUsed for react server components.
placeholderstringNoPlaceholders for input values.
onUpdateFunctionNoEvent handler when value updates
styleCSS ObjectNoStandard CSS object
successbooleanNoGreen background color for tags
valuestring[]NoDefault value (controlled)
warningbooleanNoOrange background color for tags

Basics

The following is a basic example of a Taglist field.

<Taglist placeholder="Enter Value" value={['foo', 'bar']} />
Copy

Events

The following example makes use of all the possible events for Taglist.

<Taglist onUpdate={console.log} />
Copy

On Update

The onUpdate event is triggered when the value has been updated. The following arguments are passed to the event handler:

NameTypeSample
valuestring[]`['foo', 'bar']`

Errors

You can pass the error prop to highlight the Taglist field red.

<Taglist error value={['foo', 'bar']} />
Copy

Custom Styles

You can add your own custom class to selects or use any of the respective frui-field-taglist, frui-field-taglist-tag, frui-field-taglist-remove, and frui-field-taglist-input CSS classes.