Place sliced cucumbers and red onion in a large heatproof bowl.
In a small saucepan, combine rice vinegar, water, sugar, salt, peppercorns, and mustard seeds. Bring to a simmer over medium heat, stirring until sugar and salt dissolve.
Pour the hot brine over the cucumbers and onions. Toss gently to coat.
Let the mixture cool to room temperature, then cover and refrigerate for at least 30 minutes (or up to 2 hours).
Just before serving, stir in fresh dill if using. Serve chilled or at room temperature.