Has anyone implemented a social sharing widget

Hi,

I want to add a “share this page” widget to my Streamlit app with “share to facebook, twitter, Linkedin” buttons. Has anyone done this? What’s a good way?

Hi @fredzannarbor ,

I’ve tried this in case of Twitter. Here’s the code.

import streamlit as st
import streamlit.components.v1 as components

components.html(
    """
        <a href="https://twitter.com/share?ref_src=twsrc%5Etfw" class="twitter-share-button" 
        data-text="Check my cool Streamlit Web-App🎈" 
        data-url="https://streamlit.io"
        data-show-count="false">
        data-size="Large" 
        data-hashtags="streamlit,python"
        Tweet
        </a>
        <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
    """
)

You can tweak the code further, and make it as you want it. Refer to Tweet Button, for more information.

Here’s how it looks when you click the tweet button

Probably, if you don’t use the parameter data-url="https://streamlit.io" , will be auto-populated.

Does this help ?

Best,
Avra

3 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.