Skip to content

Latest commit

 

History

History
35 lines (23 loc) · 1.3 KB

README.md

File metadata and controls

35 lines (23 loc) · 1.3 KB

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