Preview:
add_action('wp_footer', function() {
?>

<script>
    const shareButton = document.querySelector('.share-button a');
    shareButton.addEventListener('click', event => {
    
        if (navigator.share) { 
        
            navigator.share({
                title: '<?php echo get_the_title(); ?>',
                url: '<?php echo get_permalink(); ?>'
            }).then(() => {
            })
            .catch(console.error);
        }
    });
	</script>

<?php
});
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter