import { KbqTagsModule } from '@koobiq/components/tags';

KbqTag

componentCopy link to KbqTag
@Component({
selector: 'kbq-tag, [kbq-tag], kbq-basic-tag, [kbq-basic-tag]',
exportAs: 'kbqTag'
})
class KbqTag extends KbqColorDirective implements IFocusableOption, KbqTitleTextRef {
readonly editable = input<boolean | undefined>();
readonly preventEditSubmit = input<boolean>(false);
readonly selected = input(false);
value = input<NonNullable<unknown> | null | undefined>();
readonly selectable = input(false);
readonly removable = input(true);
tabindex = input<number | null | undefined>();
disabled = input<boolean | undefined>();
readonly color = input<T | null | undefined>();
readonly editChange = output<KbqTagEditChange>();
readonly selectionChange = output<KbqTagSelectionChange>();
readonly destroyed = output<KbqTagEvent>();
readonly removed = output<KbqTagEvent>();
changeDetectorRef: ChangeDetectorRef;
readonly contentChildren: Signal<readonly KbqIcon[]>;
readonly avatar: Signal<KbqTagAvatar | undefined>;
readonly trailingIcon: Signal<KbqTagTrailingIcon | undefined>;
readonly removeIcon: Signal<any>;
get canRemove(): boolean;
get colorClassName(): string;
select(): void;
deselect(): void;
toggleSelected(isUserInput?: boolean): boolean;
focus(): void;
remove(): void;
setDefaultColor(color: T): void;
}
editableinputCopy link to editableboolean | undefined

Whether the tag is editable.

preventEditSubmitinputCopy link to preventEditSubmitboolean

Whether the tag edits can't be submitted.

selectedinputCopy link to selectedSignal<boolean>

Whether the tag is selected.

valueinputCopy link to valueNonNullable<unknown> | null | undefined

The value of the tag. Defaults to the content inside <kbq-tag> tags.

selectableinputCopy link to selectableSignal<boolean>

Whether the tag is selectable.

removableinputCopy link to removableSignal<boolean>

Determines whether the tag is removable.

tabindexinputCopy link to tabindexnumber | null | undefined

Tab order of the tag.

disabledinputCopy link to disabledboolean | undefined

Whether the tag is disabled.

localeOverridesinputCopy link to localeOverridesKbqPartialLocaleData | undefined

Localized strings for this element and its subtree, keyed by locale section. Every key is optional at every depth.

colorinputCopy link to colorT | null | undefined

Color of the component. A value set in code holds until the input changes, and the default color is used while both are unset or falsy.

editChangeoutputCopy link to editChangeKbqTagEditChange

Emits event when the tag is edited.

selectionChangeoutputCopy link to selectionChangeKbqTagSelectionChange

Emitted when the tag is selected or deselected.

destroyedoutputCopy link to destroyedKbqTagEvent

Emitted when the tag is destroyed and leaving the DOM.

removedoutputCopy link to removedKbqTagEvent

Emitted when a tag is to be removed. Fires on programmatic and UI removal (click or keyboard).

avatarCopy link to avatarSignal<KbqTagAvatar | undefined>

The tag avatar

trailingIconCopy link to trailingIconSignal<KbqTagTrailingIcon | undefined>

The tag's trailing icon.

removeIconCopy link to removeIconSignal<any>

The tag's remove toggler.

canRemoveCopy link to canRemoveboolean

Whether the user may remove this tag through the controls the tag itself offers — the remove control and the Delete key. A disabled tag offers neither.

This is the affordance, not the channel: remove() stays open so the list can still clear a disabled tag when clearPredicate asks for it.

colorClassNameCopy link to colorClassNamestring

current class name of color

select()Copy link to select()void

Selects the tag.

deselect()Copy link to deselect()void

Deselects the tag.

toggleSelected()Copy link to toggleSelected()boolean

Toggles the current selected state of the tag.

focus()Copy link to focus()void

Focuses the tag.

remove()Copy link to remove()void

Allows for programmatic removal of the tag. Called by the KbqTagList when the DELETE or BACKSPACE keys are pressed.

Informs any listeners of the removal request. Does not remove the tag from the DOM.

setDefaultColor()Copy link to setDefaultColor()void

this color will be used as a default value. For example [color]="'' | false | undefined | null".

KbqTagList

componentCopy link to KbqTagList
@Component({ selector: 'kbq-tag-list', exportAs: 'kbqTagList' })
class KbqTagList implements KbqFormFieldControl<any>, ControlValueAccessor, CanUpdateErrorState {
draggable = input<boolean | undefined>();
readonly selectable = input<boolean>(true);
readonly editable = input<boolean>(false);
readonly clearPredicate = input<(tag: KbqTag) => boolean>(
(tag) => !tag.disabled
);
readonly removable = input<boolean>(true);
readonly errorStateMatcher = input<ErrorStateMatcher>();
readonly dropped = output<KbqTagListDroppedEvent>();
readonly change = output<KbqTagListChange>();
defaultErrorStateMatcher: ErrorStateMatcher;
parentForm: NgForm | null;
parentFormGroup: FormGroupDirective | null;
ngControl: NgControl;
readonly focused: Signal<boolean>;
notifyPendingTagChange(): void;
focus(): void;
blur(): void;
markAsTouched(): void;
}
draggableinputCopy link to draggableboolean | undefined

Whether the tags in the list can be reordered by dragging.

selectableinputCopy link to selectableboolean

Whether or not this tag list is selectable. When a tag list is not selectable, the selected states for all the tags inside the tag list are always ignored.

editableinputCopy link to editableboolean

Whether the tags in the list are editable.

clearPredicateinputCopy link to clearPredicate(tag: KbqTag) => boolean

Decides which tags the projected KbqCleaner removes: return true to clear the tag, false to keep it. Disabled tags are kept by default. Bind a stable reference — a new function on every change detection re-runs the predicate over every tag.

A tag the list does not allow to be removed is never offered, whatever the predicate answers.

removableinputCopy link to removableboolean

Whether the tags in the list are removable.

errorStateMatcherinputCopy link to errorStateMatcherErrorStateMatcher

An object used to control when error messages are shown.

droppedoutputCopy link to droppedKbqTagListDroppedEvent

Emits when the user drops tag inside tag list container.

changeoutputCopy link to changeKbqTagListChange

Event emitted when the selected tag list value has been changed by the user.

focusedCopy link to focusedSignal<boolean>

Whether any tags or the kbqTagInput inside of this tag-list has focus.

notifyPendingTagChange()Copy link to notifyPendingTagChange()void

Notifies that the next tags.changes emission is UI-initiated.

focus()Copy link to focus()void

Focuses the tag list. If there is a tag input, focuses that instead.

blur()Copy link to blur()void

When blurred, mark the field as touched when focus moved outside the tag list.

markAsTouched()Copy link to markAsTouched()void

Mark the field as touched

KbqTagEditInput

directiveCopy link to KbqTagEditInput

Directive to add input behavior for the editable tag.

@Directive({ selector: '[kbqTagEditInput]', exportAs: 'kbqTagEditInput' })
class KbqTagEditInput {}

KbqTagEditSubmit

directiveCopy link to KbqTagEditSubmit

Directive to add submit behavior for the editable tag.

@Directive({ selector: '[kbqTagEditSubmit]', exportAs: 'kbqTagEditSubmit' })
class KbqTagEditSubmit {}

KbqTagInput

directiveCopy link to KbqTagInput

Directive that adds tag-specific behaviors to an input element inside <kbq-form-field>. May be placed inside or outside of an <kbq-tag-list>.

@Directive({
selector: 'input[kbqTagInputFor]',
exportAs: 'kbqTagInput, kbqTagInputFor'
})
class KbqTagInput implements KbqTagTextControl {
readonly separatorKeyCodes = input<number[]>(
this.defaultOptions.separatorKeyCodes,
{ alias: 'kbqTagInputSeparatorKeyCodes' }
);
readonly distinct = input<boolean>(false);
readonly placeholder = input<string>('');
readonly id = input<string>(
inject(_IdGenerator).getId('kbq-tag-list-input-')
);
readonly tagList = input<KbqTagList | undefined>(undefined, {
alias: 'kbqTagInputFor'
});
readonly addOnBlur = input<boolean>(true, {
alias: 'kbqTagInputAddOnBlur'
});
readonly addOnPaste = input<boolean>(
this.defaultOptions.addOnPaste ?? true,
{ alias: 'kbqTagInputAddOnPaste' }
);
disabled = input<boolean | undefined>();
readonly tagEnd = output<KbqTagInputEvent>({
alias: 'kbqTagInputTokenEnd'
});
readonly autofilled: Signal<boolean>;
readonly empty: Signal<boolean>;
focus(): void;
}
kbqTagInputSeparatorKeyCodesinputCopy link to kbqTagInputSeparatorKeyCodesnumber[]

The list of key codes that will trigger a tagEnd event.

Defaults to [ENTER].

distinctinputCopy link to distinctboolean

A value indicating whether allow/prevent tags duplication

placeholderinputCopy link to placeholderstring

The input's placeholder text.

idinputCopy link to idstring

Unique id for the input.

kbqTagInputForinputCopy link to kbqTagInputForKbqTagList | undefined

Register input for tag list.

kbqTagInputAddOnBlurinputCopy link to kbqTagInputAddOnBlurboolean

Whether or not the tagEnd event will be emitted when the input is blurred.

kbqTagInputAddOnPasteinputCopy link to kbqTagInputAddOnPasteboolean

Whether the tagEnd event will be emitted when the text pasted. Defaults to addOnPaste of KBQ_TAGS_DEFAULT_OPTIONS, or true.

disabledinputCopy link to disabledboolean | undefined

Whether the input is disabled.

kbqTagInputTokenEndoutputCopy link to kbqTagInputTokenEndKbqTagInputEvent

Emitted when a tag is to be added.

autofilledCopy link to autofilledSignal<boolean>

Whether the control's value was filled in by the browser.

emptyCopy link to emptySignal<boolean>

Whether the input is empty.

focus()Copy link to focus()void

Focuses the input.

KbqTagPrefix

directiveCopy link to KbqTagPrefix

Marks content to be projected into the prefix (leading) slot of a tag.

@Directive({ selector: '[kbqTagPrefix]' })
class KbqTagPrefix {}

KbqTagRemove

directiveCopy link to KbqTagRemove

Example:

<kbq-tag> <kbq-icon kbqTagRemove>cancel</kbq-icon> </kbq-tag>

You may use a custom icon, but you may need to override the kbq-tag-remove positioning styles to properly center the icon within the tag.

@Directive({ selector: '[kbqTagRemove]' })
class KbqTagRemove {
readonly ariaLabel = input<string | undefined>(undefined, {
alias: 'aria-label'
});
}
aria-labelinputCopy link to aria-labelstring | undefined

Accessible name of the button. Defaults to the localized "Remove".

KbqTagSuffix

directiveCopy link to KbqTagSuffix

Marks content to be projected into the suffix (trailing) slot of a tag.

@Directive({ selector: '[kbqTagSuffix]' })
class KbqTagSuffix {}

KbqTagEditChange

classCopy link to KbqTagEditChange

Event object emitted by KbqTag when the tag is edited.

class KbqTagEditChange {
readonly tag: KbqTag;
readonly type: "start" | "cancel" | "submit";
readonly reason: string;
constructor(
tag: KbqTag,
type: "start" | "cancel" | "submit",
reason: string
);
}

KbqTagListChange

classCopy link to KbqTagListChange

Change event object that is emitted when the tag list value has changed.

class KbqTagListChange {
source: KbqTagList;
value: any;
constructor(source: KbqTagList, value: any);
}

KbqTagSelectionChange

classCopy link to KbqTagSelectionChange

Event object emitted by KbqTag when selected or deselected.

class KbqTagSelectionChange {
source: KbqTag;
selected: boolean;
isUserInput: boolean;
constructor(
source: KbqTag,
selected: boolean,
isUserInput?: boolean
);
}

KbqTagEvent

typeCopy link to KbqTagEvent

Event object emitted by KbqTag.

type KbqTagEvent = {
tag: KbqTag;
};

KbqTagFocusEvent

typeCopy link to KbqTagFocusEvent

Event object emitted when the KbqTag is focused.

type KbqTagFocusEvent = KbqTagEvent & {
origin: FocusOrigin;
};

KbqTagInputEvent

interfaceCopy link to KbqTagInputEvent

Represents an input event on a kbqTagInput.

interface KbqTagInputEvent {
input: HTMLInputElement;
value: string;
}
inputCopy link to inputHTMLInputElement

The native <input> element that the event is being fired for.

valueCopy link to valuestring

The value of the input.

KbqTagListDroppedEvent

typeCopy link to KbqTagListDroppedEvent
type KbqTagListDroppedEvent = Pick<CdkDragDrop<unknown>, 'event' | 'previousIndex' | 'currentIndex'> & {
tag: KbqTag;
};

KbqTagsDefaultOptions

interfaceCopy link to KbqTagsDefaultOptions

Default options for the tags module that can be overridden.

interface KbqTagsDefaultOptions {
separatorKeyCodes: number[];
separators?: KbqTagSeparator[];
addOnPaste?: boolean;
}
separatorKeyCodesCopy link to separatorKeyCodesnumber[]

The list of key codes that will trigger a tagEnd event.

separatorsoptionalCopy link to separatorsKbqTagSeparator[]

Custom separator definitions to use instead of the built-in defaults.

addOnPasteoptionalCopy link to addOnPasteboolean

Whether the tagEnd event will be emitted when text is pasted.

KbqTagSeparator

interfaceCopy link to KbqTagSeparator

Defines a character or pattern that ends a tag, and the contexts in which it applies.

interface KbqTagSeparator {
symbol: RegExp;
key?: string;
keyCode?: number;
appliesTo?: KbqTagSeparatorContext[];
}
symbolCopy link to symbolRegExp

Regular expression used to match/split this separator in text.

keyoptionalCopy link to keystring

KeyboardEvent.key that triggers this separator while typing. Omit for separators with no single-keystroke equivalent (e.g. a run of whitespace) — those are implicitly paste-only, since they can never match a keydown.

keyCodeoptionalCopy link to keyCodenumber

Numeric key code gating whether this separator is enabled, set via kbqTagInputSeparatorKeyCodes. Omit together with key for separators that should always be active regardless of that input.

appliesTooptionalCopy link to appliesToKbqTagSeparatorContext[]

Contexts this separator applies to. Defaults to ['input', 'paste'].

KbqTagSeparatorContext

typeCopy link to KbqTagSeparatorContext

Contexts a KbqTagSeparator can be active in.

type KbqTagSeparatorContext = 'input' | 'paste';

KBQ_TAGS_DEFAULT_OPTIONS

constCopy link to KBQ_TAGS_DEFAULT_OPTIONS

Injection token to be used to override the default options.

const KBQ_TAGS_DEFAULT_OPTIONS: InjectionToken<KbqTagsDefaultOptions>;

kbqTagsDefaultOptionsProvider

constCopy link to kbqTagsDefaultOptionsProvider

Utility provider for KBQ_TAGS_DEFAULT_OPTIONS.

const kbqTagsDefaultOptionsProvider: (
options: Partial<KbqTagsDefaultOptions>
) => Provider;
Suggestions for improvement
If you found a mistake or want to improve the article, create an issue on GitHub.