Style - kazhala/InquirerPy GitHub Wiki
https://inquirerpy.readthedocs.io/
This page is deprecated, documentation moved to:This page documents the guide to customize the style of the prompt.
Components
Before Answered
All prompts contains at least one window with the following components. These can be supplied to the prompt via parameters.
? What's your name: (full name) Kevinβ
- ----------------- ----------- -----
β β β β
β β β β
qmark message instruction input
? Select prefered methods: (j/k)
>Pick-up
>>Delivery
--------- β separator
Drive-through
ββ
ββ
pointer & marker
After Answered
? What's your name: Kevin Zhuang
? Select prefered methods: ["Pick-up", "Delivery"]
- ------------------------ -----------------------
β β β
β β β
qmark message answer
Style - Components Mapping
The following table contains the mapping between configurable components and their style class.
You will find these components as a parameter in individual prompt documentation βββ
Style class | Components |
---|---|
questionmark |
qmark |
question |
message |
instruction |
instruction |
pointer |
pointer |
checkbox |
enabled_symbol /disabled_symbol |
marker |
marker |
Customizing Style
get_style
Skip this section if you are coming from
PyInquirer
/ using the "classic syntax" (i.e. using theprompt
module)
When using the "alternate syntax" (i.e. interacting with the inquirer
module), each prompt class requires a InquirerPyStyle
object instead of a dictionary. You can get
this object by using the get_style
method.
def get_style(
style: Dict[str, str] = None, style_override: bool = True
) -> InquirerPyStyle:
from InquirerPy import get_style
from InquirerPy import inquirer
style = get_style({"questionmark": "#ffffff", "answer": "#000000"})
result = inquirer.confirm(message="Confirm?", style=style)
Parameters
style: Dict[str, str]
The dictionary of style classes and their colors, reference Default Style. If nothing is passed, the style will be resolved to the default style.
style_override: bool
A boolean to determine if the supplied style
parameter should be merged with the default style or override the entire default style.
By default, the supplied style will overwrite the entire default style.
Set to False
if you like the default onedark style or just playing around the styling options to have the supplied style
merge with the default style
.
Default Style
The default style is based on onedark color scheme (reference).
{
"questionmark": "#e5c07b",
"answer": "#61afef",
"input": "#98c379",
"question": "",
"instruction": "",
"pointer": "#61afef",
"checkbox": "#98c379",
"separator": "",
"skipped": "#5c6370",
"validator": "",
"marker": "#e5c07b",
"fuzzy_prompt": "#c678dd",
"fuzzy_info": "#98c379",
"fuzzy_border": "#4b5263",
"fuzzy_match": "#c678dd",
}
Color Syntax
Applying basic style.
{
"questionmark": "blue"
}
Coloring both foreground and background.
{
"questionmark": "fg:#e5c07b bg:#ffffff"
}
Adding additional styles to text.
{
"questionmark": "fg:#e5c07b bg:#ffffff underline bold"
}
Available Options
Colors
- ANSI color palette:
ansired
- Named color:
red
- Hexadecimal notation:
#ffffff
Text
underline
italic
bold
reverse
hidden
blink
Negative Variants
noblink
nobold
nounderline
noreverse
nohidden
noitalic
Support
The styling functionality leverages prompt_toolkit
. For more reference of the styling options, visit prompt_toolkit
documentation.
The colors and styling support will be limited by the terminal and font and experince may vary. Avoid
adding styles such as italic
since lots of font or terminal doesn't support it.