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

Cannot be rendered correctly in Shiny app with tailwind css #1103

Open
dukechain2333 opened this issue Dec 7, 2023 · 3 comments
Open

Cannot be rendered correctly in Shiny app with tailwind css #1103

dukechain2333 opened this issue Dec 7, 2023 · 3 comments

Comments

@dukechain2333
Copy link

Hi!

I am working on a shiny app project with tailwind CSS, and my UI is purely written in HTML.

Here is my HTML code.

<div class="relative h-full w-2/3 px-5">
        <div class="relative h-full w-full px-5 flex flex-col">
            <div class="relative bg-white shadow-lg sm:rounded-3xl h-full w-full px-10 py-10" id="table"
                 style="overflow-x: scroll">
                <!--                {{tableOutput("table")}}-->
                {{DTOutput('table')}}
            </div>
        </div>
    </div>

And this is the code on my server side.

output$table <- DT::renderDT({
    DT::datatable(
      processed_data_table()
    )
  })

The original tableOutput("table") works correctly, however, when I switch to DT, my page goes blank.

@stla
Copy link
Collaborator

stla commented Dec 7, 2023

You have a duplicated id = "table".

@dukechain2333
Copy link
Author

You have a duplicated id = "table".

I changed the HTML to this but it's still blank

<div class="relative h-full w-full px-5 flex flex-col">
            <div class="relative bg-white shadow-lg sm:rounded-3xl h-full w-full px-10 py-10"
                 style="overflow-x: scroll">
                {{DTOutput('table')}}
            </div>
        </div>

I checked the rendered HTML, it shows like this:

<div class="datatables html-widget html-widget-output shiny-report-size html-fill-item-overflow-hidden html-fill-item" id="table" style="width:100%;height:auto;"></div>

I think the problem is on the server side. Somehow, the DT is not passed to the ui.

@yihui
Copy link
Member

yihui commented Dec 7, 2023

It will be easier for people to help you if you could provide a minimal reproducible example (as the issue guide required). It's hard to tell what could be wrong if you only provide code fragments. Anyway, my guess is that you need spaces inside {{ }} (after the opening {{ and before the closing }}).

Reference: https://shiny.posit.co/r/articles/build/templates/

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

3 participants