---
title: rightBarButtonItem
framework: uikit
role: symbol
role_heading: Instance Property
path: uikit/uinavigationitem/rightbarbuttonitem
---

# rightBarButtonItem

A custom bar button item that displays on the right (or trailing) edge of the navigation bar when the navigation item is the top item.

## Declaration

```swift
var rightBarButtonItem: UIBarButtonItem? { get set }
```

## Discussion

Discussion The contents of this property always refer to the first bar button item in the rightBarButtonItems array. Assigning a new value to this property replaces the first item in the rightBarButtonItems array with the new value. Setting this property to nil removes the first item in the array. If the bar button item is already in the array, it is moved from its current location to the front of the array. In a right-to-left user interface, the position of the right bar button item is automatically flipped.

## See Also

### Specifying custom views

- [centerItemGroups](uikit/uinavigationitem/centeritemgroups.md)
- [leadingItemGroups](uikit/uinavigationitem/leadingitemgroups.md)
- [trailingItemGroups](uikit/uinavigationitem/trailingitemgroups.md)
- [pinnedTrailingGroup](uikit/uinavigationitem/pinnedtrailinggroup.md)
- [titleView](uikit/uinavigationitem/titleview.md)
- [subtitleView](uikit/uinavigationitem/subtitleview.md)
- [largeSubtitleView](uikit/uinavigationitem/largesubtitleview.md)
- [leftBarButtonItems](uikit/uinavigationitem/leftbarbuttonitems.md)
- [leftBarButtonItem](uikit/uinavigationitem/leftbarbuttonitem.md)
- [rightBarButtonItems](uikit/uinavigationitem/rightbarbuttonitems.md)
- [setLeftBarButtonItems(_:animated:)](uikit/uinavigationitem/setleftbarbuttonitems(_:animated:).md)
- [setLeftBarButton(_:animated:)](uikit/uinavigationitem/setleftbarbutton(_:animated:).md)
- [setRightBarButtonItems(_:animated:)](uikit/uinavigationitem/setrightbarbuttonitems(_:animated:).md)
- [setRightBarButton(_:animated:)](uikit/uinavigationitem/setrightbarbutton(_:animated:).md)
