|
1 | | -# Applies Switch |
| 1 | +# Applies switch |
2 | 2 |
|
3 | 3 | The applies-switch directive creates tabbed content where each tab displays an applies_to badge instead of a text title. This is useful for showing content that varies by deployment type, version, or other applicability criteria. |
4 | 4 |
|
5 | | -## Basic Usage |
| 5 | +## Basic usage |
6 | 6 |
|
7 | | -### Example |
| 7 | +::::::{tab-set} |
| 8 | +:::::{tab-item} Output |
8 | 9 |
|
9 | | -#### Syntax |
10 | | - |
11 | | -```markdown |
12 | | -:::::{applies-switch} |
| 10 | +::::{applies-switch} |
13 | 11 |
|
14 | | -::::{applies-item} stack: preview 9.1 |
15 | | -:::{tip} |
16 | | -This feature is in preview for Elastic Stack 9.1. |
| 12 | +:::{applies-item} stack: |
| 13 | +Content for Stack |
17 | 14 | ::: |
18 | | -:::: |
19 | 15 |
|
20 | | -::::{applies-item} ess: preview 9.1 |
21 | | -:::{note} |
22 | | -This feature is available for Elastic Cloud. |
| 16 | +:::{applies-item} serverless: |
| 17 | +Content for Serverless |
23 | 18 | ::: |
24 | | -:::: |
25 | 19 |
|
26 | | -::::{applies-item} ece: removed |
27 | | -:::{warning} |
28 | | -This feature has been removed from Elastic Cloud Enterprise. |
29 | | -::: |
30 | 20 | :::: |
31 | 21 |
|
32 | 22 | ::::: |
33 | | -``` |
34 | | - |
35 | | -#### Result |
| 23 | +:::::{tab-item} Markdown |
36 | 24 |
|
37 | | -:::::{applies-switch} |
| 25 | +```markdown |
| 26 | +::::{applies-switch} |
38 | 27 |
|
39 | | -::::{applies-item} stack: preview 9.1 |
40 | | -:::{tip} |
41 | | -This feature is in preview for Elastic Stack 9.1. |
| 28 | +:::{applies-item} stack: |
| 29 | +Content for Stack |
42 | 30 | ::: |
43 | | -:::: |
44 | 31 |
|
45 | | -::::{applies-item} ess: preview 9.1 |
46 | | -:::{note} |
47 | | -This feature is available for Elastic Cloud. |
| 32 | +:::{applies-item} serverless: |
| 33 | +Content for Serverless |
48 | 34 | ::: |
49 | | -:::: |
50 | 35 |
|
51 | | -::::{applies-item} ece: removed |
52 | | -:::{warning} |
53 | | -This feature has been removed from Elastic Cloud Enterprise. |
54 | | -::: |
55 | 36 | :::: |
56 | | - |
| 37 | +``` |
57 | 38 | ::::: |
| 39 | +:::::: |
58 | 40 |
|
59 | | -## Automatic Grouping |
60 | | - |
61 | | -Applies switches are automatically grouped together by default. This means all applies switches on a page will sync with each other - when you select a version in one switch, all other switches will automatically switch to the same version. |
| 41 | +## Multiple `applies_to` definitions |
62 | 42 |
|
63 | | -Items with the same applies_to definition will sync together across all switches on the page. For example, if you have `stack: preview 9.1` in multiple switches, selecting it in one will select it in all others. |
64 | | - |
65 | | -### Example |
66 | | - |
67 | | -In the following example we have two applies switch sets that are automatically grouped together. |
68 | | -Hence, both switch sets will be in sync. |
| 43 | +You can specify multiple `applies_to` definitions in a single `applies-item` using YAML object notation with curly braces `{}`. |
| 44 | +This is useful when content applies to multiple deployment types or versions simultaneously. |
69 | 45 |
|
70 | | -#### Syntax |
| 46 | +::::::{tab-set} |
| 47 | +:::::{tab-item} Output |
71 | 48 |
|
72 | | -```markdown |
73 | 49 | ::::{applies-switch} |
74 | | -:::{applies-item} stack: ga 8.11 |
75 | | -Content for GA version |
| 50 | + |
| 51 | +:::{applies-item} { ece:, ess: } |
| 52 | +Content for ECE and ECH bla |
76 | 53 | ::: |
77 | 54 |
|
78 | | -:::{applies-item} stack: preview 9.1 |
79 | | -Content for preview version |
| 55 | +:::{applies-item} serverless: |
| 56 | +Content for Serverless |
80 | 57 | ::: |
81 | 58 |
|
82 | 59 | :::: |
83 | 60 |
|
| 61 | +::::: |
| 62 | +:::::{tab-item} Markdown |
| 63 | + |
| 64 | +```markdown |
84 | 65 | ::::{applies-switch} |
85 | | -:::{applies-item} stack: ga 8.11 |
86 | | -Other content for GA version |
| 66 | + |
| 67 | +:::{applies-item} { ece:, ess: } |
| 68 | +Content for ECE and ECH bla |
87 | 69 | ::: |
88 | 70 |
|
89 | | -:::{applies-item} stack: preview 9.1 |
90 | | -Other content for preview version |
| 71 | +:::{applies-item} serverless: |
| 72 | +Content for Serverless |
91 | 73 | ::: |
92 | 74 |
|
93 | 75 | :::: |
94 | 76 | ``` |
| 77 | +::::: |
| 78 | +:::::: |
| 79 | + |
| 80 | +## Automatic grouping |
95 | 81 |
|
96 | | -#### Result |
| 82 | +Applies switches are automatically grouped together by default. This means all applies switches on a page will sync with each other - when you select a version in one switch, all other switches will automatically switch to the same version. |
| 83 | + |
| 84 | +Items with the same applies_to definition will sync together across all switches on the page. For example, if you have `stack: preview 9.1` in multiple switches, selecting it in one will select it in all others. |
97 | 85 |
|
98 | | -##### Automatically Grouped Applies Switches |
| 86 | +In the following example we have two applies switch sets that are automatically grouped together. |
| 87 | +Hence, both switch sets will be in sync. |
99 | 88 |
|
100 | 89 | ::::{applies-switch} |
101 | | -:::{applies-item} stack: ga 8.11 |
102 | | -Content for GA version |
| 90 | +:::{applies-item} stack: ga 9.0 |
| 91 | +Other content for 9.0 version |
103 | 92 | ::: |
104 | | - |
105 | | -:::{applies-item} stack: preview 9.1 |
106 | | -Content for preview version |
| 93 | +:::{applies-item} stack: ga 9.1 |
| 94 | +Other content for 9.1 version |
107 | 95 | ::: |
108 | | - |
109 | 96 | :::: |
110 | 97 |
|
111 | 98 | ::::{applies-switch} |
112 | | -:::{applies-item} stack: ga 8.11 |
113 | | -Other content for GA version |
| 99 | +:::{applies-item} stack: ga 9.0 |
| 100 | +Other content for 9.0 version |
114 | 101 | ::: |
115 | | - |
116 | | -:::{applies-item} stack: preview 9.1 |
117 | | -Other content for preview version |
| 102 | +:::{applies-item} stack: ga 9.1 |
| 103 | +Other content for 9.1 version |
118 | 104 | ::: |
119 | | - |
120 | 105 | :::: |
121 | 106 |
|
122 | | -## Supported Applies To Definitions |
| 107 | +## Supported `applies_to` definitions |
123 | 108 |
|
124 | | -The `applies-item` directive accepts any valid applies_to definition that would work with the `{applies_to}` role. This includes: |
| 109 | +The `applies-item` directive accepts any valid applies_to definition that would work with the `{applies_to}` role. |
125 | 110 |
|
126 | | -- **Stack versions**: `stack: ga 8.11`, `stack: preview 9.1` |
127 | | -- **Deployment types**: `ess: preview 9.1`, `ece: removed`, `eck: ga 8.11` |
128 | | -- **Product versions**: `product: preview 9.1` |
129 | | -- **Serverless projects**: `serverless: observability: preview 9.1` |
| 111 | +See the [](applies.md) page for more details on valid `applies_to` definitions. |
130 | 112 |
|
131 | | -## Best Practices |
132 | | - |
133 | | -**DOs**<br> |
134 | | -✅ **Do:** Use clear, descriptive applies_to definitions<br> |
135 | | -✅ **Do:** Make sure all switch items have the same type of content and similar goals<br> |
136 | | -✅ **Do:** Keep switch content scannable and self-contained<br> |
137 | | -✅ **Do:** Include other block elements in switches, like [admonitions](admonitions.md)<br> |
138 | | -✅ **Do:** Use applies_to definitions that are meaningful to your users |
139 | | - |
140 | | -**DON'Ts**<br> |
141 | | -❌ **Don't:** Nest applies switches<br> |
142 | | -❌ **Don't:** Split step-by-step procedures across switches<br> |
143 | | -❌ **Don't:** Use more than 6 switch items (use as few as possible)<br> |
144 | | -❌ **Don't:** Use applies switches in [dropdowns](dropdowns.md)<br> |
145 | | -❌ **Don't:** Use applies_to definitions that are too similar or confusing |
146 | | - |
147 | | -## When to Use |
| 113 | +## When to use |
148 | 114 |
|
149 | 115 | Use applies switches when: |
150 | 116 |
|
151 | 117 | - Content varies significantly by deployment type, version, or other applicability criteria |
152 | 118 | - You want to show applies_to badges as tab titles instead of text |
153 | 119 | - You need to group related content that differs by applicability |
154 | 120 | - You want to provide a clear visual indication of what each content section applies to |
155 | | - |
156 | | -## Comparison with Regular Tabs |
157 | | - |
158 | | -| Feature | Regular Tabs | Applies Switch | |
159 | | -|---------|--------------|----------------| |
160 | | -| Tab titles | Text labels | Applies_to badges | |
161 | | -| Use case | General content organization | Content that varies by applicability | |
162 | | -| Visual indication | Text | Badge with version/deployment info | |
163 | | -| Best for | General content grouping | Version-specific or deployment-specific content | |
0 commit comments