simoncor.net/themes/hugo-coder/exampleSite/content/posts/html-and-css-only-tabs.md
Simon Cornet 956e73d0e4
All checks were successful
Build and Publish / Build (push) Successful in 5s
Build and Publish / Deployment (push) Successful in 58s
[hugo] feat: update
2024-08-26 17:13:18 +02:00

2.0 KiB

+++ authors = ["Lone Coder"] title = "HTML and CSS only tabs" date = "2023-07-09" description = "Sample article showcasing shortcodes for HTML/CSS only tabs" tags = [ "hugo", "markdown", "css", "html", "shortcodes", ] categories = [ "theme demo", "syntax", ] series = ["Theme Demo"] aliases = ["migrate-from-jekyl"] +++

Shortcodes

The following content:

{{</* tabgroup */>}}
{{</* tab name="Hello" */>}}
Hello World!
{{</* /tab */>}}

{{</* tab name="Goodbye" */>}}
Goodbye Everybody!
{{</* /tab */>}}
{{</* /tabgroup */>}}

Will generate:

{{< tabgroup >}} {{< tab name="Hello" >}} Hello World! {{< /tab >}}

{{< tab name="Goodbye" >}} Goodbye Everybody! {{< /tab >}} {{< /tabgroup >}}

Right alighment

You can also align the tabs to the right:

{{</* tabgroup align="right" */>}}
{{</* tab name="Hello" */>}}
Hello World!
{{</* /tab */>}}

{{</* tab name="Goodbye" */>}}
Goodbye Everybody!
{{</* /tab */>}}
{{</* /tabgroup */>}}

Giving you this look:

{{< tabgroup align="right" >}} {{< tab name="Hello" >}} Hello World! {{< /tab >}}

{{< tab name="Goodbye" >}} Goodbye Everybody! {{< /tab >}} {{< /tabgroup >}}

Markdown content

Any valid markdown can be used inside the tab:

{{</* tabgroup align="right" style="code" */>}}
{{</* tab name="Ruby" */>}}

```ruby
puts 'Hello'
```

{{</* /tab */>}}
{{</* tab name="Python" */>}}

```python
print('Hello')
```

{{</* /tab */>}}
{{</* tab name="JavaScript" */>}}

```js
console.log("Hello");
```

{{</* /tab */>}}
{{</* /tabgroup */>}}

And you get this lovely content:

{{< tabgroup align="right" style="code" >}} {{< tab name="Ruby" >}}

puts 'Hello'

{{< /tab >}} {{< tab name="Python" >}}

print('Hello')

{{< /tab >}} {{< tab name="JavaScript" >}}

console.log("Hello");

{{< /tab >}} {{< /tabgroup >}}

In this case style="code" makes it look a little nicer for scenarios where your content is purely a code block.