How to render a clickable link inside `ui.output_data_frame`
Closed this issue · 1 comments
SamEdwardes commented
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.
- 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)
- 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
@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
SamEdwardes commented
Apologies, I created this in the wrong repo. I have reposted in the correct repo here: posit-dev/py-shiny#930