Docs
Inputs

Secure Entry

A glass password field with a reveal bubble, a strength chip and requirement chips that turn sage with a check as each rule passes.

$npx swiftpieces add SecureEntry
Free · MIT + Commons ClauseiOS 17.0+Liquid Glasspasswordsecurestrengthvalidationform
Type
SecureEntry
Files
SecureEntry.swift
Depends on
Nothing (Apple frameworks only)
Version
2.3.0
In a full screen · SwiftPieces ProVerifyA sign-in verification screen with springing digits, SMS autofill and a shake on a wrong code.

Liquid glass password field with strength meter, live requirements, and inline error. The field is a glass shape with a round glass reveal bubble joined to it. Everything below it buds out of the field when it appears and melts back into it when it goes: the error chip, joined just under it, and, apart from it, the strength chip and the requirement chips.

Notes

  • The field is liquid glass, with a round glass reveal bubble joined to its end by a liquid neck. Revealing swaps SecureField for TextField instantly; the toggle re-targets @FocusState to the new field so the keyboard stays up, and its eye glyph blurs into the other. The bubble sinks under the finger.
  • Focus draws a 2pt ring around the field. The field's glass carries its state: Style.error (butter) while there is an error, Style.success (sage) once every requirement passes, neutral otherwise. Text on a tinted field turns to dark ink.
  • Everything below the field lines up with it and buds straight down out of it when it appears, then melts back into it when it goes, while the room it takes opens and closes on the same springs, so whatever sits below moves with it instead of jumping.
  • Setting error from nil shakes the field once with an .error haptic on the same beat, tints it butter, and buds a butter error chip out of its bottom edge to rest joined just under it. A new message for an error already showing blurs into the new wording in place, with no second shake or haptic, so live validation never buzzes per keystroke. To signal a later refusal, set error to nil when the user edits, so the next refused submit arrives from nil and shakes again. Clearing it melts the chip back into the field as the tint drains. VoiceOver hears each new or reworded message once, as an announcement.
  • The strength chip buds out of the field as typing starts and rests apart below it, beside a gauge that fades in. Its label morphs letter by letter from WEAK through FAIR and GOOD to STRONG, and the chip and gauge take the level's tint: butter while weak or fair, sage once good. The gauge changes length without overshoot, so the reading never wobbles.
  • Requirement chips bud out of the field while it is focused or filled, two to a row, resting apart. A met requirement clicks into sage glass with a small dip and swell, its check drawing in after the tint lands, with a .selection haptic. When all four pass, the field turns sage and a check blurs into it with a .success haptic in place of the tick and the pop of the last chip, and the chips stay a beat so the last one lands, then melt back into the field. Leaving the field melts them at once, and losing a rule during that beat keeps them.
  • submitLabel and onSubmit set the Return key and what it does, the same whether the password is hidden or revealed. Leave submitLabel as nil to keep a label set around the field. To chain fields, apply .focused($focus, equals: .confirm) to each SecureEntry (focus reaches the text field inside) and move focus in onSubmit.
  • Style sets every tint plus the field's minimum height and its radius. The field grows past that height when larger text needs it, and the reveal bubble grows with it, a circle as tall as the field on the same centre line. At accessibility text sizes the strength chip moves under its gauge, the requirement chips stack one to a row and wrap long labels, and a chip whose text wraps takes rounded corners in place of capsule ends. All text is semibold. .disabled(true) dims the field.
  • Reduce Motion: no shake and no press scale (the reveal bubble shades instead), the chips open and close where they rest instead of budding, the morphing label and the swapped glyphs crossfade, and met chips change tint without the pop. The tints, the drawn checks and every haptic remain. Reduce Transparency draws the glass as solid shapes.
  • For one-time codes after sign-in, see the Verify screen (code entry) in SwiftPieces Pro.

Usage

SecureEntryExample()

Parameters

ParameterDescription
labelStatic caption above the field, also the placeholder and accessibility label.
textBound password text.
errorValidation message. Setting it from nil shakes the field once with an error haptic, tints it with Style.error, buds an error chip out of its bottom edge, and announces the message to VoiceOver. A new message for a standing error swaps in place and is announced, without a second shake; clear it to nil on edit so the next refused submit shakes again.
showsStrengthShow the strength gauge and its label chip once text is non-empty.
showsRequirementsShow the 8+ / number / symbol / mixed-case chips while focused or filled. When all four pass the field takes the success tint with a check, and the chips melt back into it a beat later.
submitLabelThe Return key label, e.g. .go or .next, hidden or revealed. nil, the default, keeps the label set around the field, .return unless one is.
onSubmitCalled when Return is pressed, hidden or revealed. Submit the form or move focus to the next field here.
styleColors and field metrics. Defaults to the SwiftPieces house palette, adapting to light and dark.

Install

Pick one. Run it from the folder that contains your .xcodeproj and the files land inside your app.

Terminal

$npx swiftpieces add SecureEntry

Or ask your coding agent · Claude Code, Cursor or Xcode, once the MCP server is connected

>Add the SwiftPieces "Secure Entry" piece to my app

Or copy the source above into your app.

New to SwiftUI?If you know React, CSS or Tailwind, SwiftUI is easier to pick up than it looks.Try real app patterns first

Building a whole app? See SwiftPieces Pro →

All inputs and forms →

Build it yourself: SwiftUI haptics guide

On this page

SwiftPiecesPro

Build the whole app with one library.

Production-ready screens, whole flows, complete app templates, a Build Kit your agent follows and Pro remixing.

54 screens · 46 patterns · 48 flows · 12 templates · 31 Build Kit skills

Explore Pro