Docs
Text

Glass Text

Liquid Glass drawn on the actual letter shapes of a string, with fallbacks before iOS 26 and under Reduce Transparency.

$npx swiftpieces add GlassText
Free · MIT + Commons ClauseiOS 17.0+Liquid Glasstextglasscoretextdisplaynumerals
Type
GlassText
Files
GlassText.swift
Depends on
Nothing (Apple frameworks only)
Version
2.2.0
In a full screen · SwiftPieces ProPurchaseA complete StoreKit 2 purchase: plans load, the purchase runs, success lands, the app unlocks.

Liquid Glass applied to text outlines via Core Text glyph paths. The glyph path is built from the string and font when the view's body runs, then handed to glassEffect(_:in:) as a shape. Its subject is glass itself, so it draws its glass directly rather than on a liquid group's shapes. Split the string with \n for a stacked display title; lines use tight display leading.

Notes

  • Glyph outlines come from Core Text (CTFontCreatePathForGlyph), so any UIFont works, including custom families. The default is the system font at the house weight, semibold, like all SwiftPieces type; the example sets its numerals at 120pt so the strokes stay wide enough to bend the light. The path is built in body, not on layout passes, so keep GlassText out of anything that re-renders every frame: put the clock on the backdrop, as the example does, and leave the glass outside it.
  • On iOS 26 the outline is passed to glassEffect(_:in:) as a shape. Glass is this piece's subject, so it draws its glass directly instead of through the liquid group the other pieces share; the glass call needs the iOS 26 SDK and is compiled only with it, so the piece still builds with Xcode 16. Below iOS 26 the outline is filled with .ultraThinMaterial and a hairline highlight; Reduce Transparency fills it with .primary instead.
  • The point size follows Dynamic Type via @ScaledMetric(relativeTo: .largeTitle), capped at 1.6x so a display word never leaves the screen. Pass scalesWithDynamicType: false to pin it.
  • Glass reads best over a backdrop with soft tonal variation; a flat color gives it nothing to refract.
  • Split the string with \n for a stacked display title. Style.alignment and Style.leading (0.86 of the font's line height by default) lay out the lines.
  • States: Liquid Glass on iOS 26 with a soft lift shadow; below iOS 26 a layered fallback (Material, optional tint at fallbackTintAmount, a top light and a 1pt specular rim); under Reduce Transparency a solid Style.solidFill (.primary by default).
  • The letters have no motion of their own: no entrance, no idle loop, no press. A new string takes the old one's place at once, so letters that did not change never dim or double up mid-swap. For numerals that tick, such as a clock, use UIFont.monospacedDigitSystemFont(ofSize:weight:) so unchanged digits keep their place. The life comes from the backdrop moving behind the glass.
  • Reduce Motion changes nothing in the component, since nothing in it moves. The example's color blocks start from a rest pose when the view appears and ease into their drift over two seconds; under Reduce Motion they hold that rest pose, and turning it off starts the drift again from rest.
  • VoiceOver reads the lines as one static text.
  • For a full purchase screen built around glass display type, see the Pro Purchase screen.

Usage

GlassTextExample()
    .preferredColorScheme(.light)

Parameters

ParameterDescription
textThe string to render. \n starts a new line.
fontThe UIFont used to build glyph paths: system semibold, the house weight, by default. Its point size is scaled with Dynamic Type, relative to .largeTitle.
tintOptional glass tint. The Material fallback blends it in at style.fallbackTintAmount.
scalesWithDynamicTypeSet false to pin the point size.
styleLine alignment and leading, fallback specular strength, depth shadow and the Reduce Transparency fill.

Install

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

Terminal

$npx swiftpieces add GlassText

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

>Add the SwiftPieces "Glass Text" 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 text →

Build it yourself: SwiftUI animations guide · Liquid Glass 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