If you add a shortcode in a widget (using the block editor), WordPress will automatically wrap the shortcode in <p></p> tags. This results in an empty space on top of the output of your shortcode.
You can remove the paragraph tags using this filter:
add_filter('render_block', function ($blockContent, $block) {
if ($block['blockName'] == 'core/shortcode') {
$blockContent = str_replace('<p>[', '[', $blockContent);
$blockContent = str_replace(']</p>', ']', $blockContent);
}
return $blockContent;
}, 10, 2);