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)
from shiny import render
from shiny.express import input, ui

ui.input_password("password", "Password", "mypassword1")  

@render.text
def value():
    return input.password()
from shiny import App, render, ui

app_ui = ui.page_fluid(
    ui.input_password("password", "Password", "mypassword1"),  
    ui.output_text_verbatim("value"),
)

def server(input, output, session):
    @render.text
    def value():
        return input.password()

app = App(app_ui, server)
No matching items

Relevant Functions

  • ui.input_password
    ui.input_password(id, label, value='', *, width=None, placeholder=None)

No matching items

Details

A password field creates a text box for password entry.

To add a password field to your app:

  1. 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.

  2. Specify the id and label parameters of ui.input_password() to define the identifier and label of the passsword field. ui.input_password() also includes various optional parameters, including value, 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:

  1. 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.