> For the complete documentation index, see [llms.txt](https://platform.slapdash.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://platform.slapdash.com/command-tutorials/toggle-dark-mode.md).

# Toggle Dark Mode

A Mac OS command that uses AppleScript

![Run Toggle Dark Mode in Command Bar](https://2278499523-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MbsXkso5TLXDAfcG2Q2%2Fuploads%2Fgit-blob-ff05f263f39732e17edac9a8370bad9fd0a6fe92%2Ftoggle-dark-mode%20\(1\)%20\(2\)%20\(2\)%20\(2\)%20\(2\)%20\(2\).gif?alt=media)

This is an example that will only work on macOS because it uses AppleScript. It's an example of a command that doesn't return a response: it just does its thing and exits.

When the command is run, it will toggle the dark mode system preference setting.

Paste the following code in a new file with a `.applescript` extension and then [create a Local Command](/command-bar-101/local-commands.md#create-local-command) to try it out in Slapdash.

```javascript
tell application "System Events"
  tell appearance preferences
    set dark mode to not dark mode
  end tell
end tell
```

[See on Github](https://github.com/slapdash/platform/tree/main/tutorials/toggle-dark-mode)
