Skip to main content

Ruff PyPI-Server Pyversions License: MIT Downloads Coverage Status

textual-tags

demo_image

This library provides a custom tags widget called Tags, which can be easily added into your existing textual application.

Requires a Nerdfont to render the round corners of the Tag labels.

Features

  • Can be initiated with a predefined set/list of tags, similar entries will be ignored
  • Consists of a TagInput, with autocompletion powered by textual-autocomplete for existing tags and displayed tags wrapped in a flexbox-like container
  • Two different ways to display the tags (with x at the end or without)
  • Option to also add new not predefined tags, which are then also available for autocompletion
  • vim-like completion control

Installation

textual-tags is hosted on PyPi and can be installed with:

pip install textual-tags

or add it to your project using uv with:

uv add textual-tags

Demo App

You can run the demo app after installation with textual-tags or using uv with:

uvx textual-tags

Usage

Here is an exampke usage of the Tags-widget in a textual App. You can also check the demo app here.

from textual.app import App

from textual_tags import Tags

PRE_DEFINED_TAGS = [
    "uv",
    "Terminal",
    "tcss",
    "Textual",
    "Tags",
    "Widget",
    "Python",
    "TUI",
    "Highlander"
]

class TagsApp(App):
    DEFAULT_CSS = """
    Tags {
        width:50;
    }
    """
    def compose(self):
        yield Tags(
            # list/set of tags to start with
            tag_values=PRE_DEFINED_TAGS,
            # Show Tag-Labels as `TAG x` instead of ' TAG '
            show_x=False,
            # All tags are selected on startup
            start_with_tags_selected=True,
            # Allow to enter custom new tags and dont hide TagInput if all tags are selected
            # Also allows delete/edit of last tag when pressing `backspace` on empty input
            allow_new_tags=False,
        )

def main():
    app = TagsApp()
    app.run()

if __name__ == '__main__':
    main()

Messages

Tags sends two messages:

  • Tag.Removed, send when a tag is removed in any way
  • Tag.Focused, send when a tag is focused
  • Tag.Hovered, send when a tag is hovered
  • Tag.Selected, send when a tag is selected
  • TagAutoComplete.Applied, send when a completion option is applied

Issues/Feedback

Feel free to reach out and share your feedback, or open an Issue, if something doesnt work as expected. Also check the Changelog for new updates.

Metadata

Release files for textual-tags 0.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for textual-tags 0.3.3
File Size Uploaded
textual_tags-0.3.3.tar.gz 108.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for textual-tags 0.3.3
File Interpreter ABI Platform
textual_tags-0.3.3-py3-none-any.whl Python 3 none any Details

Total release size: 118.4 kB

Release files / textual_tags-0.3.3.tar.gz

Download URL textual_tags-0.3.3.tar.gz
Size 108.3 kB
Tags Source
SHA-256 checksum
How to use checksums
73acc315360bf7f927f71c36284f3426a78d9af2e1538660ef81fa4f7e790f9c
BLAKE2b-256 checksum
How to use checksums
0aa0d88cf93b8d3f82a3f1dec9db2b830e5529d9f965e5695e63d6e0ed84e882
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.22

Release files / textual_tags-0.3.3-py3-none-any.whl

Download URL textual_tags-0.3.3-py3-none-any.whl
Size 10.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8d394941366d974df2442204a2479ced88a97ceda8a72c885b2d3f158679e850
BLAKE2b-256 checksum
How to use checksums
ab4b855efdddf3487d0d6a1b54f795e40ac0cdaebda025fe2d7b91eb0288ffea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.22

Release history Release notifications | RSS feed

This release

0.3.3 This release

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page