Opacity gradient in custom legend

"to have the blueish edge faded and the redish solid::

You can use a list of colors with desired opacities as option value for "ColorScheme". For example,

colorscheme = Append[ColorData["DarkRainbow"]@#, .01 + #] & /@ Subdivide[10];

Graphics[ChartElementData["GradientRectangle", 
   "ColorScheme" -> colorscheme,  "GradientOrigin" -> Left][{{0, 15}, {0, 2}}]]

enter image description here


One can also have a legend which shows colour and opacity separately, as

BarLegend["Rainbow", OpacityFunction -> (# &)]

enter image description here

This is used in built-in functions such as DensityPlot3D.