Skip to main content
.accessibilityValue(value: string): Component;

Parameters

value
string
A string representing the current value of the accessibility element. Used for controls like sliders, progress bars, and other value-based components.

Support

Usage

Slider with current value

Slider(value: $volume, in: 0...100)
    .accessibilityLabel("Volume")
    .accessibilityValue(`${volume}%`)

Progress indicator

ProgressView({ value: progress })
    .accessibilityLabel("Upload progress")
    .accessibilityValue(`${Math.round(progress * 100)}% complete`)

Rating display

HStack([
    ForEach(0..<5, (index) =>
        Image(index < rating ? "star-filled" : "star-empty")
    )
]).accessibilityLabel("Rating")
  .accessibilityValue(`${rating} out of 5 stars`)

Toggle state value

Toggle("Dark mode", isOn: $isDarkMode)
    .accessibilityValue(isDarkMode ? "On" : "Off")

Custom control with numeric value

VStack([
    Text("Temperature"),
    Text(`${temperature}°F`)
]).accessibilityLabel("Current temperature")
  .accessibilityValue(`${temperature} degrees Fahrenheit`)

Date picker value

DatePicker("Select date", selection: $selectedDate)
    .accessibilityValue(selectedDate.formatted(date: .complete, time: .omitted))