{"id":10272,"library":"style","title":"Terminal String Styling","description":"Style is a simple and fast Python library for styling terminal output with colors and formatting using ANSI escape codes. It provides a clean API for foreground colors, background colors, and text effects. The current version is 1.1.6, and it maintains a stable, active release cadence.","status":"active","version":"1.1.6","language":"python","source_language":"en","source_url":"https://github.com/lmittmann/style","tags":["terminal","styling","colors","cli","ansi"],"install":[{"cmd":"pip install style","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"wrong":"import style","symbol":"style","correct":"import style"}],"quickstart":{"code":"from style import style, fg, bg, ef\n\nprint(style(\"Hello, World!\", fg.red, bg.blue, ef.bold))\nprint(style(\"Underlined text.\", ef.underline))\nprint(style(\"Green background.\", bg.green))","lang":"python","description":"This example demonstrates basic usage of `style` to apply foreground color, background color, and text effects like bold or underline to a string. The `style` function returns the styled string, which can then be printed."},"warnings":[{"fix":"Apply styles to individual components and concatenate them. For example, `print(style('Hello ', fg.red) + style('World!', fg.blue))` for distinct styling, rather than `print(style('Hello ' + style('World!', fg.blue), fg.red))` which won't apply red to 'World!'.","message":"When applying styles using the `style()` function, inner `style()` calls effectively create new styled segments that are concatenated. This means that a parent style will not 'wrap' a child styled segment as it implicitly resets before and after each `style()` call.","severity":"gotcha","affected_versions":"All versions (1.0.0+)"},{"fix":"Always use lowercase attribute names for colors and effects as defined in the `fg`, `bg`, and `ef` objects.","message":"Styles (colors and effects) are applied by their lowercase attribute names (e.g., `fg.red`, `ef.bold`). Using uppercase attribute names (e.g., `fg.RED`) will result in an `AttributeError`.","severity":"gotcha","affected_versions":"All versions (1.0.0+)"}],"env_vars":null,"search_vec":"'1.1.6':41 'activ':47 'ansi':21,54 'api':28 'background':32 'cadenc':49 'clean':27 'cli':53 'code':23 'color':17,31,33,52 'current':38 'effect':36 'escap':22 'fast':9 'foreground':30 'format':19 'librari':11 'maintain':44 'output':15 'provid':25 'python':10 'releas':48 'simpl':7 'stabl':46 'string':2 'style':3,4,13,51 'termin':1,14,50 'text':35 'use':20 'version':39","created_at":"2026-04-17T01:23:15.787219+00:00","updated_at":"2026-04-17T01:23:15.787219+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\n  File \"/tmp/tmp46veyma0/venv/lib/python3.12/site-packages/style/__init__.py\", line 2, in <module>\n    import pkg_resources\nModuleNotFoundError: No module named 'pkg_resources'"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.1.6","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/lmittmann/style","docs":null,"changelog":null,"pypi":"https://pypi.org/project/style/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"import_fail","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-07-10","install_tag":null}}