Skip to content

Tag Input

A tag/chip input widget for entering and managing multiple tags.

Preview

FXTagInput

Classes

FXTagInput

Bases: FXThemeAware, QWidget

A styled input widget that displays tags as removable chips.

This widget provides an input field where users can type and press Enter to add tags. Tags are displayed as styled chips that can be removed by clicking the × button.

Parameters:

Name Type Description Default

parent

Optional[QWidget]

Parent widget.

None

placeholder

str

Placeholder text for the input field.

'Add tag and press Enter...'

max_tags

int

Maximum number of tags allowed (0 = unlimited).

0

allow_duplicates

bool

Whether duplicate tags are allowed.

False
Signals

tags_changed: Emitted when tags are added or removed. tag_added: Emitted when a single tag is added. tag_removed: Emitted when a single tag is removed.

Examples:

>>> tag_input = FXTagInput(placeholder="Add tags...")
>>> tag_input.tags_changed.connect(lambda tags: print(f"Tags: {tags}"))
>>> tag_input.add_tag("python")
>>> tag_input.add_tag("qt")

Methods:

Name Description
add_tag

Add a tag to the input.

clear_tags

Remove all tags.

remove_tag

Remove a tag from the input.

set_tags

Set the tags, replacing any existing tags.

Attributes:

Name Type Description
tags List[str]

Return the list of current tags.

tags property

tags: List[str]

Return the list of current tags.

add_tag

add_tag(tag: str) -> bool

Add a tag to the input.

Parameters:

Name Type Description Default

tag

str

The tag text to add.

required

Returns:

Type Description
bool

True if the tag was added, False otherwise.

clear_tags

clear_tags() -> None

Remove all tags.

remove_tag

remove_tag(tag: str) -> bool

Remove a tag from the input.

Parameters:

Name Type Description Default

tag

str

The tag text to remove.

required

Returns:

Type Description
bool

True if the tag was removed, False otherwise.

set_tags

set_tags(tags: List[str]) -> None

Set the tags, replacing any existing tags.

Parameters:

Name Type Description Default

tags

List[str]

List of tag strings to set.

required

FXTagChip

Bases: FXThemeAware, QFrame

A single removable tag chip.

Parameters:

Name Type Description Default

text

str

The tag text.

required

parent

Optional[QWidget]

Parent widget.

None

removable

bool

Whether the chip can be removed.

True
Signals

removed: Emitted when the remove button is clicked.

Attributes:

Name Type Description
text str

Return the tag text.

text property

text: str

Return the tag text.