How to use gradient on flat surface?

I have a triangle symmetrical to axis oy. How can I create a gradient on its surface that depends on oy position?

Hi and welcome to this forum!
Please, have a look at this post:

it is really useful…

That said.
You can’t make gradients with surfaces, but you can color mesh vertices.

In your case a single triangular mesh face will be plenty.
Remapping vertices Y coordinate to a 0-1 domain and using Gradient component to get colors to feed on the mesh creation (1 color per vertex).

triangle (10.8 KB)