Skip to main content
196

Search Lumen

Find components, APIs, guides, and recipes.

GitHub
Apple docs
FormsApple

Number field

Edit localized numeric drafts with exact decimal steps and inclusive bounds.

Public APILumenNumberFieldApple / 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 Vision · visionOS 1+

Native example

Use Number field

Preserve the raw localized String draft, including unfinished sign or decimal input. Grouping and exponent notation are unsupported. Keep currency, units, required validation, and submission parsing application-owned.

Number field rendered in the iPhone simulator Lumen playground
Captured exampleiPhone simulator
swift
import LumenUI
import SwiftUI

struct Quantity: View {
    @State private var draft = "1"
    var body: some View {
        LumenNumberField("Quantity", text: $draft, min: "0", max: "10", step: "0.5",
            incrementLabel: "Increase quantity", decrementLabel: "Decrease quantity")
            .environment(\.locale, Locale(identifier: "en_US"))
    }
}

Reference

Public API

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

APIValues or typeDefaultDescription
_ label / textString / Binding<String>RequiredNames the field and retains raw localized drafts.
min / max / stepString? / String? / Stringnil / nil / 1Uses exact decimal strings; the application owns units and submission parsing.
incrementLabel / decrementLabelStringIncrease value / Decrease valueNames step actions.
invalidNumberLabel / outOfRangeLabelStringEnter a valid number / Enter a number within the allowed rangeLocalizes draft validation.
showStepperBooltrueShows step actions.
focusedFocusState<Bool>.Binding?nilConnects application-owned input focus.
.environment(\.locale, ...)LocaleEnvironmentSelects decimal separator and displayed digits.
description / errorMessageString?nilProvides localized supporting copy or host validation.
readOnly / .disabled(...)BoolfalseBlocks editing; disabled state comes from the SwiftUI environment.

Native behavior

Design and accessibility

When to use it

Preserve the raw localized String draft, including unfinished sign or decimal input. Grouping and exponent notation are unsupported. Keep currency, units, required validation, and submission parsing application-owned.

Accessibility

Labels the editable numeric draft and step actions, exposes invalid or out-of-range context, and disables unavailable or read-only steps.

Shared component

Available on other platforms

React NativeAndroid / Compose
Apple docsSwiftUI package