How to add dropdown menu on tab / tabset [rmarkdown / bootstrap]

前端 未结 2 852
小蘑菇
小蘑菇 2021-02-10 00:47

Documentation for Bootswatch suggests I can use a dropdown menu from a tab in a tabset:

How can I achieve this with Rmarkdown? I\'ve tried:

# SE         


        
2条回答
  •  难免孤独
    2021-02-10 01:26

    For now, I don't think this can be done using just rmarkdown. However, you can produce an HTML document with a tabset section using rmarkdown and then tweak the HTML to convert the tab set to a dropdown menu. Alternatively, you can use the bsselectR package, which is unfortunately still in a somewhat-stalled development.

    Below is an example of how you'd make an HTML document with rmarkdown and replace a tab set with a dropdown menu.

    First, you'd write your rmarkdown document and then knit it to HTML.

    ---
    title: "Tabset Example"
    output: html_document
    ---
    
    # The Tabset Section {.tabset .tabset-fade}
    
    ## First Tab
    Here is the first tab's content.
    
    ## Second Tab
    Here is the second tab's content
    ```
    

    Then, in the resultant HTML file, you'd find this section of HTML:

    
    

    and replace it with this HTML:

     
    

    Which should result in your tab set appearing as a dropdown menu, such as the following:

提交回复
热议问题