Skip to content

Instantly share code, notes, and snippets.

@SergLam
Forked from lanserxt/DiscardableSliderView.swift
Created December 15, 2025 17:31
Show Gist options
  • Select an option

  • Save SergLam/a6b8e985c52e6e9ed3c1ee33ca34c2f0 to your computer and use it in GitHub Desktop.

Select an option

Save SergLam/a6b8e985c52e6e9ed3c1ee33ca34c2f0 to your computer and use it in GitHub Desktop.
SwiftUI: Discardable Slider View
import SwiftUI
struct DiscardableSliderView: View {
@State private var value = 5.0
@State private var filterValue: Double = 5.0
var body: some View {
VStack {
Text("Values to filter")
DiscardableSlider(value: $filterValue, bounds: 0...10, step: 1)
Text("Initial value: \(Text(value, format: .number.rounded(rule: .up)).bold())")
}
.onChange(of: filterValue) {
print(filterValue)
}
.padding(32)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment