Password Field
#| standalone: true
#| components: [viewer]
#| viewerHeight: 200
## file: app.py
from shiny import App, render, ui
app_ui = ui.page_fluid(
ui.input_password("password", "", "mypassword1").add_class(
"pt-5 mx-auto text-center"
),
ui.output_text_verbatim("value"),
{"class": "vh-100 justify-content-center align-items-center px-5"},
).add_class("my-auto text-center")
def server(input, output, session):
@output
@render.text
def value():
return input.password()
app = App(app_ui, server)
Relevant Functions
-
ui.input_password
ui.input_password(id, label, value='', *, width=None, placeholder=None)
Details
A password field creates a text box for password entry.
To add a password field to your app:
Add
ui.input_password()
to the UI of your app to create a password field. Where you call this function will determine where the password field will appear within the app’s layout.Specify the
id
andlabel
parameters ofui.input_password()
to define the identifier and label of the passsword field.ui.input_password()
also includes various optional parameters, includingvalue
, which set the initial value.
The value of an input component is accessible as a reactive value within the server()
function. To access the value of a password field:
- Use
input.<password_field_id>()
(e.g.,input.password()
) to access the value of the password field. The server value of a password field is a string.