Skip to main content
239

Search Lumen

Find components, APIs, guides, and recipes.

GitHub
Themes
Apple docs
FormsApple

Character count

Show how many characters remain for a text field.

Public APILumenCharacterCountApple / SwiftUISwift product: LumenUI

Apple availability

Supported native targets

Import LumenUI in the target that uses this component. iPad support follows the iOS package baseline and uses native iPad layout behavior.

iPhone · iOS 16+iPad · iPadOS 16+Mac · macOS 13+Apple TV · tvOS 16+Apple Vision · visionOS 1+Apple Watch · watchOS 9+

Native example

Use Character count

It never truncates; validate the limit on submit.

Character count rendered in the iPhone simulator Lumen playground
Captured exampleiPhone simulatorView dark appearance
swift
import LumenUI
import SwiftUI

struct CharacterCountExample: View {
    @State private var bio = "Design systems engineer building calm interfaces."

    var body: some View {
        VStack(alignment: .leading, spacing: LumenSpacing.xs) {
            LumenTextField("Short bio", text: $bio)
            LumenCharacterCount(text: bio, max: 80)
        }
    }
}
Apple
A bio field with a counter that warns near the 80-character limit and turns danger over it.

Reference

Public API

The primary shared and platform-specific options exposed by LumenCharacterCount.

APIValues or typeDefaultDescription
max / value / announceAtlimit / current text / thresholdsrequired / required / 20, 10, 0It never truncates; validate the limit on submit.

Native behavior

Design and accessibility

When to use it

It never truncates; validate the limit on submit.

Accessibility

Counts graphemes and announces only at thresholds and at the limit.

Shared component

Available on other platforms

React NativeAndroid / Compose Web
Apple docsSwiftUI package