Dyes can be obtained through questing or with Pearls from the cash shop.
How to Dye Gear
First, press the J key to open your dyeing window. Next, select the piece of gear you wish to add dyes to, and then select the part of the gear you wish to dye. Each piece of gear/costume has its own amount of sections you are able to dye, so it will vary accordingly.
You can experiment with as many dye combinations as you wish without using up your dyes. Once you have found the look you want, press the "Dye" button to finalize your dyeing process.
Through the Escape button menu, if you select the rainbow paint bucket icon button, you can then mix 2 dyes together for a random dye selection, found in your pearl section of your bag once mixed.