TTBaseSUIToggle
SwiftUI CoreSwiftUI toggle switch with 3 visual types: standard system toggle with label, icon+label toggle, and label-only display. Supports tint color from TTBaseUIKitConfig, disabled state, and multiple configurations.
🎨 Toggle Types
public enum TYPE {
case DEFAULT // Standard text label + toggle switch
case ICON // AwesomePro icon + label + toggle
case LABEL_ONLY // Only label text, no toggle (for display)
}
🚀 Usage
// DEFAULT — text label + toggle
@State private var notificationsOn = true
TTBaseSUIToggle(
isOn: $notificationsOn,
label: "Push Notifications"
)
// ICON — icon + label + toggle
TTBaseSUIToggle(
isOn: $darkModeOn,
label: "Dark Mode",
type: .ICON,
icon: .moon // AwesomePro icon
)
// Custom tint color
TTBaseSUIToggle(
isOn: $wifiOn,
label: "Wi-Fi",
tintColor: .systemBlue
)
// Disabled toggle (read-only display)
TTBaseSUIToggle(
isOn: .constant(true),
label: "Premium Only Feature",
isDisabled: true
)
// LABEL_ONLY — pure display
TTBaseSUIToggle(
isOn: $featureFlag,
label: "Beta Features",
type: .LABEL_ONLY
)
In a Settings Screen
struct SettingsView: View {
@State private var pushOn = true
@State private var emailOn = false
@State private var soundOn = true
var body: some View {
VStack(spacing: 0) {
SettingRow {
TTBaseSUIToggle(isOn: $pushOn, label: "Push Notifications", type: .ICON, icon: .bell)
}
SettingRow {
TTBaseSUIToggle(isOn: $emailOn, label: "Email Digest", type: .ICON, icon: .envelope)
}
SettingRow {
TTBaseSUIToggle(isOn: $soundOn, label: "Sound Effects", type: .ICON, icon: .volumeUp)
}
}
}
}
📖 Initializer Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
isOn | Binding<Bool> | — | Toggle state binding |
label | String | — | Toggle label text |
type | TYPE | .DEFAULT | Visual style |
icon | AwesomePro.Light? | nil | Icon for .ICON type |
tintColor | Color | theme primary | Toggle active tint |
isDisabled | Bool | false | Make toggle non-interactive |
Pro Tip: Use
.ICON type for settings lists — the icon makes rows instantly scannable. All icons respect your theme's icon color by default; override with tintColor per-toggle for categories (e.g., blue for connectivity, orange for sound).