Some software systems use the secondary button for cancel/close functions, and others use the warning button (usually red). Which is more correct?
A warning button is used in the case of destructive actions or data loss. If the close/cancel function will lead to the user losing changes or work, it's acceptable to use this type of button, even if the user didn't make changes. We don't usually see it used often with "Close", and even "Cancel" is a bit of a weak action for a destructive function - it's better to say "Discard changes" or something that clarifies the loss of data.
On the other hand, if the user is simply closing or canceling an informational panel or unwanted task and there's no data loss, a secondary button can be used.
Use the simple
Cancel button when:
- Wanting to close that view to continue some other related activity.
Alert button before closing or cancel when there is/are a:
- Running timer
- Playing audio
- Several filter options selected
- Some type of unsaved work
More detailed examples in this article: Cancel vs Close