Combine all dry ingredients (powdered sugar, cornstarch, and xanthan gum or arrowroot) in a mixing bowl (or the bowl of a stand mixer with the whisk attachment). Beat at low speed for 1 minute, or until everything is thoroughly combined.
With the mixer running, drizzle 1/3 cup water down the side of the bowl so it doesn't splatter, slowly increasing mixer speed until sugar is incorporated. Beat at medium-high speed for 2 minutes, scraping down the sides as needed.
The icing should be thick and stiff enough so that the beaters or whisk attachment leaves ridges when drawn through. If the icing seems too thick, you may need to add up to an additional teaspoon of water.
Divide icing into however many colors you would like and color to your liking and decorate cookies as you would with regular royal icing, watering down slightly to fill piped lines.
Video
Notes
Store this icing in an airtight container in the refrigerator. It should keep well for up to 1 month. After storage, beat the icing again for a few minutes to make it smooth again before using.
This icing will dry hard, but stay soft enough for biting into. Allow decorated cookies to dry for several hours or up to overnight before stacking them.
If desired, flavor your icing with vanilla extract, almond extract, or any flavor that you like.
For piping outlines on cookies or creating line details, 1/3 cup of water should give you the proper consistency. For a thinner, flood consistency, you will want to add a bit more water so that the icing is still thick and glossy, but runs off the beater in a thinner, quicker stream.