Textbox¶
Use textboxes to capture text inputs and passwords.
Basic¶
Call box() with mode='text' to show a textbox.
The return value is the text entered into the box.

Set initial value¶
Set value= to prefill the box with a value.
mode='text' can be elided if value= is set.

Set a label¶
Any text passed to box() is used as a label.

Show placeholder text¶
Use placeholder= to show placeholder text inside the box.

Mark as required¶
Add required to mode to indicate that input is required.

Control input format¶
Set mask= to specify an input mask. An input mask is used to format the text field for the expected entry.
For example, to accept a phone number, use an input mask containing three sets of digits.
To construct the input mask:
- Use
ato indicate a letter. - Use
9to indicate a number. - Use
*to indicate a letter or number. - Use a backslash to escape any character.

Show an icon¶
Set icon= to show an icon at the end of the box.
phrase = view(box('Filter results containing:', icon='Filter'))
view(f'You set a filter on `{phrase}`.')
![]()
Set prefix text¶
Set prefix= to show a prefix at the start of the box.
website = view(box('Website', prefix='https://', value='example.com'))
view(f'Your website is https://{website}.')

Set suffix text¶
Set suffix= to show a suffix at the end of the box.
website = view(box('Website', suffix='.com', value='example'))
view(f'Your website is {website}.com.')

Set both prefix and suffix texts¶
A textbox can show both a prefix and a suffix at the same time.
website = view(box('Website', prefix='https://', suffix='.com', value='example'))
view(f'Your website is https://{website}.com.')

Show an error message¶
Set error= to show an error message below the box.

Accept a password¶
Add password to mode when accepting passwords and other confidential inputs.
password = view(box('Password field', mode='password'))
view(f'Your password `{password}` is not strong enough!')

Enable multiple lines¶
Set lines= to show a multi-line text box (also called a text area).
Note that multi-line textboxes can be resized by the user, and lines= only sets the initial height of the textbox.

Disable¶
Set disabled=True to disable.
