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 put content in tabs? #1667

Closed
JamesHWade opened this issue May 4, 2021 · 4 comments · Fixed by #1694
Closed

How to put content in tabs? #1667

JamesHWade opened this issue May 4, 2021 · 4 comments · Fixed by #1694
Assignees
Labels
feature a feature request or enhancement

Comments

@JamesHWade
Copy link

JamesHWade commented May 4, 2021

I have attempted to create tabs following this R Markdown Cookbook section, but the tabs render as sequential entries in the rendered website.

My goal is to demonstrate the use of a package in both R and python. Any advice?

Here's what I would like to do:

## Results {.tabset}

### Tab 1

<example using R>

### Tab 2

<example using python>

@JamesHWade JamesHWade changed the title Put content in tabs How to put content in tabs? May 6, 2021
@maelle
Copy link
Collaborator

maelle commented May 7, 2021

I don't think it's possible out of the box at the moment. In rmarkdown, tabsets work thanks to a script (and CSS) added by rmarkdown.

In pkgdown, one would probably have to use Bootstrap tabs, i.e. adding some more HTML tweaking to mimick the necessary HTML structure.

<nav>
  <div class="nav nav-tabs" id="nav-tab" role="tablist">
    <a class="nav-link active" id="nav-home-tab" data-toggle="tab" href="#nav-home" role="tab" aria-controls="nav-home" aria-selected="true">Home</a>
    <a class="nav-link" id="nav-profile-tab" data-toggle="tab" href="#nav-profile" role="tab" aria-controls="nav-profile" aria-selected="false">Profile</a>
    <a class="nav-link" id="nav-contact-tab" data-toggle="tab" href="#nav-contact" role="tab" aria-controls="nav-contact" aria-selected="false">Contact</a>
  </div>
</nav>
<div class="tab-content" id="nav-tabContent">
  <div class="tab-pane fade show active" id="nav-home" role="tabpanel" aria-labelledby="nav-home-tab">...</div>
  <div class="tab-pane fade" id="nav-profile" role="tabpanel" aria-labelledby="nav-profile-tab">...</div>
  <div class="tab-pane fade" id="nav-contact" role="tabpanel" aria-labelledby="nav-contact-tab">...</div>
</div>

@JamesHWade
Copy link
Author

Thanks for the pointer, @maelle. I have been playing around with but not yet had success. I can get tabs to appear but no content. I'll keep playing with it.

@maelle
Copy link
Collaborator

maelle commented May 13, 2021

Oh, what I meant is that maybe pkgdown should do the transformation to this html structure needed by Bootstrap, but maybe it's a too niche feature.
If you use this html structure above directly your vignettes probably only work as pkgdown articles not as vignettes (and its a bit cumbersome compared to the R Markdown recipe). 🤔

@maelle maelle self-assigned this May 14, 2021
@maelle
Copy link
Collaborator

maelle commented May 18, 2021

draft PR #1694

@maelle maelle added the feature a feature request or enhancement label May 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants