update
I now figured out a way to go from #page-4
#test1
to #page-5
#test4
by clicking a link. I use a bit of javascript to read the URLs parameters. This allows us to define links like a(href="?page5&tab=4")
. The javascript will get the parameters, in our case page
as 5
and tab
as 4
and then execute two clicks, one to get to #page-5
and another one to get the tab 4 called #test4
. There are probably better options which allow you to set the active page tab and tabset tab, but I didn't get them working with {flexdashboard}. Anyway, I hope the approach below solves your problem.
---
title: "Untitled"
output:
flexdashboard::flex_dashboard:
orientation: rows
vertical_layout: fill
---
```{r setup, include=FALSE}
library(flexdashboard)
library(htmltools)
```
```{js}
document.addEventListener("DOMContentLoaded", function(){
var url_string = window.location.href;
var url = new URL(url_string);
var page = url.searchParams.get('page');
var pageid = '#page-'.concat(url.searchParams.get('page'));
var tab = 'tab'.concat(url.searchParams.get('tab'));
var tabid = '#test'.concat(url.searchParams.get('tab'));
$('a[href="'+ pageid +'"]').click();
$('a[href="'+ tabid +'"]').click();
});
```
Page 4
=====================================
## Row {.tabset}
### tab 1 {#test1}
```{r}
tags$a(href = "?page=5&tab=4",
shiny::actionButton("btn1",
"go to page-5 tab4"
))
```
### tab 2 {#test2}
```{r}
tags$a(href = "#test1",
shiny::actionButton("btn4",
"go to tab1"
))
```
Page 5
=====================================
## Row {.tabset}
### tab 3 {#test3}
```{r}
tags$a(href = "#test4",
shiny::actionButton("btn5",
"go to tab4"
))
```
### tab 4 {#test4}
```{r}
tags$a(href = "?page=4&tab=2",
shiny::actionButton("btn6",
"go to page-4 tab2"
))
```
old answer
In my case your header level 3 anchors ({#test1}
etc.) are working even when not using runtime: shiny
. You can change the tabs
via action buttons, but only if you are on the same page. For example you can from tab1
to tab2
on page 4
but you cannot go from tab1
on page 4
to tab4
on page 5
. But changing from page 4
to page 5
is again possible.
---
title: "Untitled"
output:
flexdashboard::flex_dashboard:
orientation: rows
vertical_layout: fill
---
```{r setup, include=FALSE}
library(flexdashboard)
library(htmltools)
```
Page 4
=====================================
## Row {.tabset}
### tab 1 {#test1}
```{r}
tags$a(href = "#test2",
shiny::actionButton("btn1",
"go to tab2"
))
tags$a(href = "#test1",
shiny::actionButton("btn2",
"go to tab3 (not working)"
))
tags$a(href = "#page-5",
shiny::actionButton("btn3",
"go to page5 (working)"
))
```
### tab 2 {#test2}
```{r}
tags$a(href = "#test1",
shiny::actionButton("btn4",
"go to tab1"
))
```
Page 5
=====================================
## Row {.tabset}
### tab 3 {#test3}
```{r}
tags$a(href = "#test4",
shiny::actionButton("btn5",
"go to tab4"
))
```
### tab 4 {#test4}
```{r}
tags$a(href = "#test3",
shiny::actionButton("btn6",
"go to tab3"
))
```