Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to render a clickable link inside ui.output_data_frame #14

Closed
SamEdwardes opened this issue Dec 20, 2023 · 1 comment
Closed

How to render a clickable link inside ui.output_data_frame #14

SamEdwardes opened this issue Dec 20, 2023 · 1 comment

Comments

@SamEdwardes
Copy link

I would like to include a clickable link in the cell of ui.output_data_frame. I have tried a few iterations but cannot find anything that works.

  1. Raw text
import pandas as pd
from shiny import App, render, ui


app_ui = ui.page_fluid(
    ui.output_data_frame("data_output")
)


def server(input, output, session):
    # Load the data
    data = pd.DataFrame({
        "id": [1, 2, 3],
        "url": ['https://google.com', 'https://duckduckgo.com', 'https://bing.com']
    })

    @output
    @render.data_frame
    def data_output():
        df = data.copy()
        return df


app = App(app_ui, server)

Screenshot 2023-12-20 at 15 14 48@2x

  1. Use ui.a
    @output
    @render.data_frame
    def data_output():
        df = data.copy()
        df['url'] = df['url'].apply(lambda x: ui.a(x))
        return df

Screenshot 2023-12-20 at 15 16 28@2x

    @output
    @render.data_frame
    def data_output():
        df = data.copy()
        df['url'] = df['url'].apply(lambda x: f'<a href"{x}">click me</a>')
        return df

Screenshot 2023-12-20 at 15 17 31@2x

@SamEdwardes
Copy link
Author

Apologies, I created this in the wrong repo. I have reposted in the correct repo here: posit-dev/py-shiny#930

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant