In Sway, the wayland version of i3-gaps, regular x11 screenshot tools, like maim are not working. Thankfully there are some alternatives to consider.
My favorite solution is Grim with Slurp(region selection). Arch Linux already has a package for it, on other distrubitions you have to compile and install it manually.
You can either use one of the release packages or directly clone it from git.
Let's install slurp first:
$ git clone --depth 1 https://github.com/emersion/slurp.git
$ cd slurp
$ meson build
$ ninja -C build
# install -m 755 build/slurp /usr/local/bin
If you execute slurp
you should see a rectangle select and after selecting the coordinates in the console.
Now we are ready to install grim, which is from the same author.
$ git clone --depth 1 https://github.com/emersion/grim.git
$ cd grim
$ meson build
$ ninja -C build
# install -m 755 build/grim /usr/local/bin
Edit your ~/.config/sway/config
file and add some shortcuts for grim, in the sample below the print key is used for taking screenshots.
# Take a screenshot with all output and save it into screenshots
bindsym Print exec grim -t jpeg ~/screenshots/$(date +%Y-%m-%d_%H-%m-%s).jpg
# Take a Screenshot with the region select
bindsym $mod+Print exec grim -t jpeg -g "$(slurp)" ~/screenshots/$(date +%Y-%m-%d_%H-%m-%s).jpg
If you prefer png over jpg, just remove the type (-t) parameter.
Swayshot is a screenshot helper adding shortcuts. It also uses grim and slurp for image creation.