|
| 1 | +--- |
| 2 | +title: Tabs and tab variants |
| 3 | +description: Organize your documentation with tabs and show different content variations using tab variants. |
| 4 | +--- |
| 5 | + |
| 6 | +Tabs let you group sections of your documentation together, while tab variants allow you to display different content perspectives within a single tab. |
| 7 | + |
| 8 | +## Tabs |
| 9 | + |
| 10 | +Add `tabs` to group sections together. The example below shows tabs for `Help Center`, `API Reference`, and an external link to `Github`. Each tab has a `title` and `icon`. |
| 11 | + |
| 12 | +<CodeBlock> |
| 13 | +{/* <!-- vale off --> */} |
| 14 | + |
| 15 | +```yaml title="docs.yml" |
| 16 | +tabs: |
| 17 | + api: |
| 18 | + display-name: API Reference |
| 19 | + icon: puzzle # Font Awesome icon |
| 20 | + help: |
| 21 | + display-name: Help center |
| 22 | + icon: ./assets/icons/help-icon.svg # Custom image file |
| 23 | + github: |
| 24 | + display-name: GitHub |
| 25 | + icon: brands github # Font Awesome icon |
| 26 | + href: https://github.com/fern-api/fern |
| 27 | + |
| 28 | + navigation: |
| 29 | + - tab: api |
| 30 | + layout: |
| 31 | + - section: Introduction |
| 32 | + contents: |
| 33 | + - page: My page |
| 34 | + path: my-page.mdx |
| 35 | + - api: API Reference |
| 36 | + - tab: help |
| 37 | + layout: |
| 38 | + - section: Help center |
| 39 | + contents: |
| 40 | + - page: Contact us |
| 41 | + path: contact-us.mdx |
| 42 | + - tab: github |
| 43 | +``` |
| 44 | +{/* <!-- vale on --> */} |
| 45 | +</CodeBlock> |
| 46 | +
|
| 47 | +<Note title="Tab icons"> |
| 48 | +<Markdown src="/snippets/icons.mdx" /> |
| 49 | +</Note> |
| 50 | +
|
| 51 | +Here's an example of how a tabs implementation renders: |
| 52 | +
|
| 53 | +<Frame> |
| 54 | + <img src="./images/tabs-sidebar.png" alt="Tabs displayed in the sidebar (default)" /> |
| 55 | +</Frame> |
| 56 | +
|
| 57 | +### Tabs placement |
| 58 | +
|
| 59 | +Tabs display in the left sidebar by default. To display them horizontally, set `tabs-placement` to `header` in your [layout configuration](/docs/configuration/what-is-docs-yml#layout-configuration). |
| 60 | + |
| 61 | +<CodeBlock title="docs.yml"> |
| 62 | +```yaml |
| 63 | +layout: |
| 64 | + tabs-placement: header |
| 65 | +``` |
| 66 | +</CodeBlock> |
| 67 | + |
| 68 | + |
| 69 | +## Tab variants |
| 70 | + |
| 71 | +Tab variants let you display different content variations within a single tab, and [support RBAC](/learn/docs/authentication/rbac). This is useful for showing different user types, implementation approaches, or experience levels without creating separate tabs. |
| 72 | + |
| 73 | +<Tip title="When to use variants vs. tabs"> |
| 74 | + Use **variants** for different perspectives on the same content area (REST vs. GraphQL, beginner vs. advanced). Use **tabs** for completely different documentation sections (guides vs. API Reference). |
| 75 | +</Tip> |
| 76 | + |
| 77 | +### Basic usage |
| 78 | + |
| 79 | +Define a tab with a `variants` property instead of a `layout` property. Each variant has its own title and layout. The example below shows two variants for the `Help Center` tab. |
| 80 | + |
| 81 | +```yaml title="docs.yml" startLine=20 {22-34} |
| 82 | +tabs: |
| 83 | + api: |
| 84 | + display-name: API Reference |
| 85 | + icon: puzzle |
| 86 | + help: |
| 87 | + display-name: Help center |
| 88 | + icon: home |
| 89 | + github: |
| 90 | + display-name: GitHub |
| 91 | + icon: brands github |
| 92 | + href: https://github.com/fern-api/fern |
| 93 | + |
| 94 | +navigation: |
| 95 | + - tab: api |
| 96 | + layout: |
| 97 | + - section: Introduction |
| 98 | + contents: |
| 99 | + - page: My page |
| 100 | + path: my-page.mdx |
| 101 | + - api: API Reference |
| 102 | + - tab: help |
| 103 | + variants: |
| 104 | + - title: For developers |
| 105 | + layout: |
| 106 | + - section: Getting started |
| 107 | + contents: |
| 108 | + - page: Quick start |
| 109 | + path: ./pages/dev-quickstart.mdx |
| 110 | + - title: For product managers |
| 111 | + layout: |
| 112 | + - section: Getting started |
| 113 | + contents: |
| 114 | + - page: Overview |
| 115 | + path: ./pages/pm-overview.mdx |
| 116 | + - tab: github |
| 117 | +``` |
| 118 | + |
| 119 | +### Variant properties |
| 120 | + |
| 121 | +<ParamField path="title" type="string" required={true}> |
| 122 | + Display name for the variant |
| 123 | +</ParamField> |
| 124 | + |
| 125 | +<ParamField path="layout" type="list" required={true}> |
| 126 | + Navigation structure using the same format as regular tab layouts |
| 127 | +</ParamField> |
| 128 | + |
| 129 | +<ParamField path="subtitle" type="string"> |
| 130 | + Text displayed below the variant title |
| 131 | +</ParamField> |
| 132 | + |
| 133 | +<ParamField path="icon" type="string"> |
| 134 | + <Markdown src="/snippets/icons.mdx" /> |
| 135 | +</ParamField> |
| 136 | + |
| 137 | +<ParamField path="slug" type="string"> |
| 138 | + Custom URL slug for the variant |
| 139 | +</ParamField> |
| 140 | + |
| 141 | +<ParamField path="skip-slug" type="boolean"> |
| 142 | + Exclude the variant slug from URLs |
| 143 | +</ParamField> |
| 144 | + |
| 145 | +<ParamField path="hidden" type="boolean"> |
| 146 | + Hide the variant from navigation |
| 147 | +</ParamField> |
| 148 | + |
| 149 | +<ParamField path="default" type="boolean"> |
| 150 | + When true, this variant displays by default. If not specified, the first variant in the list is used. |
| 151 | +</ParamField> |
| 152 | + |
| 153 | +<ParamField path="viewers" type="string | list"> |
| 154 | + Role-based access control for the variant |
| 155 | +</ParamField> |
| 156 | + |
| 157 | +<ParamField path="feature-flag" type="string | object"> |
| 158 | + Conditional display configuration |
| 159 | +</ParamField> |
| 160 | + |
0 commit comments