This is about configuring a keyboard shortcut (F12) to close notifications on Big Sur with Phoenix.

Key.on('f12', [], function () {
  Task.run('/usr/local/bin/cliclick', ['m:1200,100'], null)
  Task.run('/usr/bin/osascript',
    ['-e', 'tell application "System Events"\n' +
      'tell process "NotificationCenter"\n' +
      'set this_item to window 1\n' +
      'click button 1 of group 1 of UI element 1 of scroll area of this_item\n' +
      'end tell\n' +
      'end tell\n' +
      'return\n'], null)
})

2 things:

  1. This requires cliclick to be installed with brew install cliclick. Phoenix can probably control the cursor, but I ran out of time.
  2. You need to adjust the coordinators (1200,100 above) so it moves your cursor to be over the notification