Do you mean the Ryobi 40V X-head cordless string trimmer? This model has a 12-15" cutting width. For the 40V battery, you remove it by pressing and holding the latch button at the bottom of the battery (on the side closest to you). Then pull the battery out of the power head, exactly reversing how you slid it into place. Do not release the latch button until the battery slide free of the tool. The latch is usually stiff and takes a lot of force to hold down. See Fig 4 for the position of the latch in the manual: https://images.homedepot-static.com/catalog/pdfimages/fa/fab7f50b-d65b-40de-9e1c-5fecce2436f5.pdf
. The same directions apply to removing the battery from the Ryobi 40V string trimmer with the fixed head.
For the 18V batteries, there are two latches, one on each side of the battery. Press and hold again. These are so stiff that my mother and I often need someone else take off the battery from any of the Ryobi tools. (We're both about 5' tall and 100 pounds. The tools aren't designed for our proportions.)
I hope this helps.