2021-08-25 11:33:29 +00:00
+++
2022-06-05 17:31:59 +00:00
description = "Expandable/collapsible sections of text"
2021-08-25 11:33:29 +00:00
title = "Expand"
+++
2017-08-20 15:10:29 +00:00
2022-06-05 17:31:59 +00:00
The `expand` shortcode displays an expandable/collapsible section of text.
2023-05-31 21:44:27 +00:00
{{% expand title="Expand me..." %}}Thank you!
That's some text with a footnote[^1]
[^1]: And that's the footnote.
That's some more text with a footnote.[^someid]
[^someid]:
Anything of interest goes here.
Blue light glows blue.
{{% /expand %}}
2021-07-16 20:35:20 +00:00
2023-02-03 07:57:55 +00:00
{{% notice note %}}
2023-02-04 15:01:42 +00:00
This only works in modern browsers flawlessly. While Internet Explorer 11 has issues in displaying it, the functionality still works.
2023-02-03 07:57:55 +00:00
{{% /notice %}}
2021-07-16 20:35:20 +00:00
## Usage
2022-10-31 11:10:36 +00:00
While the examples are using shortcodes with named parameter you are free to use positional as well or also call this shortcode from your own partials.
2022-06-05 17:31:59 +00:00
{{< tabs groupId = "shortcode-parameter" > }}
2022-06-22 22:03:24 +00:00
{{% tab name="shortcode" %}}
2022-06-05 17:31:59 +00:00
2021-08-23 21:32:34 +00:00
````go
2022-06-05 17:31:59 +00:00
{{%/* expand title="Expand me..." */%}}Thank you!{{%/* /expand */%}}
2021-07-16 20:35:20 +00:00
````
2022-06-05 17:31:59 +00:00
{{% /tab %}}
2022-06-22 22:03:24 +00:00
{{% tab name="shortcode (positional)" %}}
2021-07-16 20:35:20 +00:00
2022-06-05 17:31:59 +00:00
````go
{{%/* expand "Expand me..." */%}}Thank you!{{%/* /expand */%}}
````
2021-07-16 20:35:20 +00:00
2022-06-22 22:03:24 +00:00
{{% /tab %}}
{{% tab name="partial" %}}
````go
{{ partial "shortcodes/expand.html" (dict
"context" .
"title" "Expand me..."
"content" "Thank you!"
)}}
````
2022-06-05 17:31:59 +00:00
{{% /tab %}}
{{< / tabs > }}
2021-09-03 22:50:08 +00:00
2022-06-05 17:31:59 +00:00
### Parameter
2017-08-20 15:10:29 +00:00
2022-06-05 17:31:59 +00:00
| Name | Position | Default | Notes |
|:----------------------|:---------|:-----------------|:------------|
2022-10-31 11:10:36 +00:00
| **title** | 1 | `"Expand me..."` | Arbitrary text to appear next to the expand/collapse icon. |
2022-06-05 17:31:59 +00:00
| **open** | 2 | `false` | When `true` the content text will be initially shown as expanded. |
2022-10-31 11:10:36 +00:00
| _**<content>**_ | | _<empty>_ | Arbitrary text to be displayed on expand. |
2022-06-05 17:31:59 +00:00
## Examples
### All Defaults
2021-07-16 20:35:20 +00:00
2021-08-23 21:32:34 +00:00
````go
2022-06-05 17:31:59 +00:00
{{%/* expand */%}}Yes, you did it!{{%/* /expand */%}}
2021-07-16 20:35:20 +00:00
````
2021-07-16 21:51:11 +00:00
2022-06-05 17:31:59 +00:00
{{% expand %}}Yes, you did it!{{% /expand %}}
2021-07-16 21:51:11 +00:00
2022-06-05 17:31:59 +00:00
### Initially Expanded
2021-07-16 21:51:11 +00:00
2021-08-23 21:32:34 +00:00
````go
2022-06-05 17:31:59 +00:00
{{%/* expand title="Expand me..." open="true" */%}}No need to press you!{{%/* /expand */%}}
2021-07-16 21:51:11 +00:00
````
2017-08-20 15:10:29 +00:00
2022-06-05 17:31:59 +00:00
{{% expand title="Expand me..." open="true" %}}No need to press you!{{% /expand %}}
2017-08-20 15:10:29 +00:00
2022-06-05 17:31:59 +00:00
### Arbitrary Text
2017-08-20 15:10:29 +00:00
2022-06-05 17:31:59 +00:00
````go
2023-03-14 20:48:18 +00:00
{{%/* expand title="Show me almost **endless** possibilities" */%}}
2022-05-23 12:59:24 +00:00
You can add standard markdown syntax:
2017-08-20 15:10:29 +00:00
2021-07-16 20:35:20 +00:00
- multiple paragraphs
- bullet point lists
2021-07-26 08:10:10 +00:00
- _emphasized_, **bold** and even **_bold emphasized_** text
2021-07-16 20:35:20 +00:00
- [links ](https://example.com )
- etc.
2017-08-20 15:10:29 +00:00
2021-08-23 21:32:34 +00:00
```plaintext
2021-07-16 20:35:20 +00:00
...and even source code
```
2017-08-20 15:10:29 +00:00
2022-10-31 11:10:36 +00:00
> the possibilities are endless (almost - including other shortcodes may or may not work)
2022-06-05 17:31:59 +00:00
{{%/* /expand */%}}
````
2017-08-20 15:10:29 +00:00
2023-03-14 20:48:18 +00:00
{{% expand title="Show me almost **endless** possibilities" %}}
2022-05-23 12:59:24 +00:00
You can add standard markdown syntax:
2017-08-20 15:10:29 +00:00
2021-07-16 20:35:20 +00:00
- multiple paragraphs
- bullet point lists
2021-07-26 08:10:10 +00:00
- _emphasized_, **bold** and even **_bold emphasized_** text
2021-07-16 20:35:20 +00:00
- [links ](https://example.com )
- etc.
2021-08-23 21:32:34 +00:00
```plaintext
2021-07-16 20:35:20 +00:00
...and even source code
```
2022-10-31 11:10:36 +00:00
> the possibilities are endless (almost - including other shortcodes may or may not work)
2021-07-16 21:51:11 +00:00
{{% /expand %}}