To remove an iCloud account from an iPhone X
follow these steps
Tap on your name at the top of the screen.
Scroll down and tap “Sign Out”.
Choose the data that you want to keep a copy of on your iPhone X, if any.
Tap “Sign Out” again to confirm.
Once you have signed out of your iCloud account, all iCloud data, such as contacts, calendars, and notes, will be removed from your iPhone X. However, any data that is stored on your iPhone X itself, such as photos and app data, will remain on the device. If you plan to give away or sell your iPhone X, it is recommended that you erase all content and settings to ensure that all personal data is removed from the device.