You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/docs/guide/shortcodes/tabs.md
+45-36Lines changed: 45 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,50 +5,46 @@ next: /docs/guide/deploy-site
5
5
6
6
## Example
7
7
8
-
{{< tabs items="macOS,Linux,Windows" >}}
9
-
10
-
{{< tab >}}**macOS**: A desktop operating system by Apple.{{< /tab >}}
11
-
{{< tab >}}**Linux**: An open-source operating system.{{< /tab >}}
12
-
{{< tab >}}**Windows**: A desktop operating system by Microsoft.{{< /tab >}}
13
-
8
+
{{< tabs >}}
9
+
{{< tab name="JSON" >}}**JSON**: JavaScript Object Notation (JSON) is a standard text-based format for representing structured data based on JavaScript object syntax.{{< /tab >}}
10
+
{{< tab name="YAML" >}}**YAML**: YAML is a human-readable data serialization language.{{< /tab >}}
11
+
{{< tab name="TOML" >}}**TOML**: TOML aims to be a minimal configuration file format that's easy to read due to obvious semantics.{{< /tab >}}
14
12
{{< /tabs >}}
15
13
16
14
## Usage
17
15
18
16
### Default
19
17
20
18
```
21
-
{{</* tabs items="JSON,YAML,TOML" */>}}
19
+
{{</* tabs */>}}
22
20
23
-
{{</* tab */>}}**JSON**: JavaScript Object Notation (JSON) is a standard text-based format for representing structured data based on JavaScript object syntax.{{</* /tab */>}}
24
-
{{</* tab */>}}**YAML**: YAML is a human-readable data serialization language.{{</* /tab */>}}
25
-
{{</* tab */>}}**TOML**: TOML aims to be a minimal configuration file format that's easy to read due to obvious semantics.{{</* /tab */>}}
21
+
{{</* tab name="JSON" */>}}**JSON**: JavaScript Object Notation (JSON) is a standard text-based format for representing structured data based on JavaScript object syntax.{{</* /tab */>}}
22
+
{{</* tab name="YAML" */>}}**YAML**: YAML is a human-readable data serialization language.{{</* /tab */>}}
23
+
{{</* tab name="TOML" */>}}**TOML**: TOML aims to be a minimal configuration file format that's easy to read due to obvious semantics.{{</* /tab */>}}
26
24
27
25
{{</* /tabs */>}}
28
26
```
29
27
30
-
### Specify Selected Index
28
+
### Specify Selected Tab
31
29
32
-
Use `defaultIndex` property to specify the selected tab. The index starts from 0.
30
+
Use `selected` property to specify the selected tab.
{{</* tab */>}}**JSON**: JavaScript Object Notation (JSON) is a standard text-based format for representing structured data based on JavaScript object syntax.{{</* /tab */>}}
38
-
{{</* tab */>}}**YAML**: YAML is a human-readable data serialization language.{{</* /tab */>}}
39
-
{{</* tab */>}}**TOML**: TOML aims to be a minimal configuration file format that's easy to read due to obvious semantics.{{</* /tab */>}}
35
+
{{</* tab name="JSON" */>}}**JSON**: JavaScript Object Notation (JSON) is a standard text-based format for representing structured data based on JavaScript object syntax.{{</* /tab */>}}
36
+
{{</* tab name="YAML" selected=true */>}}**YAML**: YAML is a human-readable data serialization language.{{</* /tab */>}}
37
+
{{</* tab name="TOML" */>}}**TOML**: TOML aims to be a minimal configuration file format that's easy to read due to obvious semantics.{{</* /tab */>}}
{{< tab >}}**JSON**: JavaScript Object Notation (JSON) is a standard text-based format for representing structured data based on JavaScript object syntax.{{< /tab >}}
49
-
{{< tab >}}**YAML**: YAML is a human-readable data serialization language.{{< /tab >}}
50
-
{{< tab >}}**TOML**: TOML aims to be a minimal configuration file format that's easy to read due to obvious semantics.{{< /tab >}}
51
-
44
+
{{< tabs >}}
45
+
{{< tab name="JSON" >}}**JSON**: JavaScript Object Notation (JSON) is a standard text-based format for representing structured data based on JavaScript object syntax.{{< /tab >}}
46
+
{{< tab name="YAML" selected=true >}}**YAML**: YAML is a human-readable data serialization language.{{< /tab >}}
47
+
{{< tab name="TOML" >}}**TOML**: TOML aims to be a minimal configuration file format that's easy to read due to obvious semantics.{{< /tab >}}
52
48
{{< /tabs >}}
53
49
54
50
@@ -57,9 +53,9 @@ The `YAML` tab will be selected by default.
57
53
Markdown syntax including code block is also supported:
58
54
59
55
````
60
-
{{</* tabs items="JSON,YAML,TOML" */>}}
56
+
{{</* tabs */>}}
61
57
62
-
{{</* tab */>}}
58
+
{{</* tab name="JSON" */>}}
63
59
```json
64
60
{ "hello": "world" }
65
61
```
@@ -70,21 +66,21 @@ Markdown syntax including code block is also supported:
70
66
{{</* /tabs */>}}
71
67
````
72
68
73
-
{{< tabs items="JSON,YAML,TOML" >}}
69
+
{{< tabs >}}
74
70
75
-
{{< tab >}}
71
+
{{< tab name="JSON" >}}
76
72
```json
77
73
{ "hello": "world" }
78
74
```
79
75
{{< /tab >}}
80
76
81
-
{{< tab >}}
77
+
{{< tab name="YAML" >}}
82
78
```yaml
83
79
hello: world
84
80
```
85
81
{{< /tab >}}
86
82
87
-
{{< tab >}}
83
+
{{< tab name="TOML" >}}
88
84
```toml
89
85
hello = "world"
90
86
```
@@ -97,7 +93,7 @@ Markdown syntax including code block is also supported:
97
93
98
94
Tabs with the same list of `items` can be synchronized. When enabled, selecting a tab updates all other tabs with the same `items` and remembers the selection across pages.
99
95
100
-
Enable globally in your `hugo.yaml` under the `page` section:
96
+
Enable/disable globally in your `hugo.yaml` under the `page` section:
101
97
102
98
```yaml {filename="hugo.yaml"}
103
99
params:
@@ -106,20 +102,33 @@ params:
106
102
sync: true
107
103
```
108
104
109
-
With this enabled the following two tab blocks will always display the same selected item:
105
+
Enable/disable per page inside the front matter:
106
+
107
+
```yaml {filename="my_page.md"}
108
+
---
109
+
title: My page
110
+
params:
111
+
tabs:
112
+
sync: true
113
+
---
114
+
115
+
Example content.
116
+
```
117
+
118
+
With this enabled, the following two tab blocks will always display the same selected item:
110
119
111
120
```markdown
112
-
{{</* tabs items="A,B" */>}}
121
+
{{</* tabs */>}}
113
122
114
-
{{</* tab */>}}A content{{</* /tab */>}}
115
-
{{</* tab */>}}B content{{</* /tab */>}}
123
+
{{</* tab name="A" */>}}A content{{</* /tab */>}}
124
+
{{</* tab name="B" */>}}B content{{</* /tab */>}}
116
125
117
126
{{</* /tabs */>}}
118
127
119
-
{{</* tabs items="A,B" */>}}
128
+
{{</* tabs */>}}
120
129
121
-
{{</* tab */>}}Second A content{{</* /tab */>}}
122
-
{{</* tab */>}}Second B content{{</* /tab */>}}
130
+
{{</* tab name="A" */>}}Second A content{{</* /tab */>}}
131
+
{{</* tab name="B" */>}}Second B content{{</* /tab */>}}
0 commit comments