Skip to content

scr037/ToggleableSecureField

Repository files navigation

ToggleableSecureField

Sumary

An alternative to "custom password" text fields made 100% with SwiftUI.

Description

ToggleableSecureField is a flexible type of text field that relies on both SwiftUI native components TextField and SecureField. In addition, it contains a built-in toggle that allows to swap between two states. It is the ideal component to let users input their password, showing or hiding the entered content without glitches.

The "show/hide" button takes in an Image that can be customized via environment, as well as its tint Color.

Customization

Any style (or other types of) customization can be done externally using the TextFieldStyle.

Usage

ToggleableSecureField(
  title: "Password",
  text: $password,
  prompt: nil
)
.environment(\.secureToggleImageShow, Image(systemName: "eye.circle"))
.environment(\.secureToggleImageHide, Image(systemName: "eye.slash.circle"))
.environment(\.secureToggleImageTintColor, .orange)

Preview

image

Demo

tfgif

About

A SwiftUI alternative for Password inputs.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Packages

 
 
 

Contributors

Languages