<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: 14.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UISwitch/title",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UISwitch(py)title"
  },
  "title" : "title"
}
-->

# title

The title displayed next to a checkbox-style switch.

```
var title: String? { get set }
```

## Discussion

Set [`title`](/documentation/UIKit/UISwitch/title) only when the user interface idiom is [`UIUserInterfaceIdiom.mac`](/documentation/UIKit/UIUserInterfaceIdiom/mac); otherwise, a runtime exception occurs.

```swift
let showFavoritesAtTop = UISwitch()
showFavoritesAtTop.preferredStyle = .checkbox
if traitCollection.userInterfaceIdiom == .mac {
    showFavoritesAtTop.title = "Always show favorite recipes at the top"
}
```

The switch ignores [`title`](/documentation/UIKit/UISwitch/title) when the value of [`style`](/documentation/UIKit/UISwitch/style-swift.property) isn’t [`UISwitch.Style.checkbox`](/documentation/UIKit/UISwitch/Style-swift.enum/checkbox).

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)