tabsdocusaurus

Docusaurus (mdx-based) tabs: How do I create a link in one tab that takes me to something in a different tab?


Use the docusaurus docs as a starting point: https://docusaurus.io/docs/markdown-features/tabs

Let's say I want to write some text in apple, and then say "if you want to go to oranges, click here" where clicking the link "click here" leads directly to the orange tab and it's corresponding text. That is, switch automatically to the orange tab.

Is this possible?

I've tried a bunch of searches and haven't found anything.


Solution

  • I answered this question from this user somewhere else and she confirmed that it worked for her. Noting the solution here in case others have the same question:

    <Tabs queryString="current-fruit">
      <TabItem value="apple" label="Apple" default>
        This is an apple 🍎
        <a href="?current-fruit=orange">Click for orange</a>
      </TabItem>
      <TabItem value="orange" label="Orange">
        This is an orange 🍊
      </TabItem>
    </Tabs>