Bootstrap elements

Posted on August 5, 2023 • 8 min read • 1,565 words
Share via

Use shortcodes to add common Bootstrap elements with ease.

Bootstrap elements
Photo by Nathan Dumlao on Unsplash

Hinode provides several shortcodes that wrap common Bootstrap components. Refer to the official documentation for more details.

Accordion

As an example, the following shortcode displays an accordion with three elements, of which the first element is expanded.

This is the first item’s accordion body. It supports HTML content. The item is shown by adding the value show to the class argument.

This is the second item’s accordion body. It supports HTML content too.

This is the third item’s accordion body.
markdown
{{< accordion >}}
  {{< accordion-item header="Accordion Item #1" show="true" >}}
    This is the first item's accordion body. It supports HTML content. The item is shown by adding the value
    <code>show</code> to the <code>class</code> argument.
  {{< /accordion-item >}}
  {{< accordion-item header="Accordion Item #2" >}}
    This is the second item's accordion body. It supports HTML content too.
  {{< /accordion-item >}}
  {{< accordion-item header="Accordion Item #3" >}}
    This is the third item's accordion body.
  {{< /accordion-item >}}
{{< /accordion >}}

Alert

As an example, the following shortcode displays a simple alert.

markdown
{{< alert color="danger" dismissible="true" >}}
    A simple danger alert—check it out!
{{< /alert >}}

Badge

Use HTML code to display a badge for a heading. See the Bootstrap documentation for more options.

Example heading of size one New

Example heading of size two New

Example heading of size three New

Example heading of size four New

Example heading of size five New
Example heading of size six New
html
<h1>Example heading of size one <span class="badge bg-secondary">New</span></h1>
<h2>Example heading of size two <span class="badge bg-secondary">New</span></h2>
<h3>Example heading of size three <span class="badge bg-secondary">New</span></h3>
<h4>Example heading of size four <span class="badge bg-secondary">New</span></h4>
<h5>Example heading of size five <span class="badge bg-secondary">New</span></h5>
<h6>Example heading of size six <span class="badge bg-secondary">New</span></h6>

As an example, the following shortcode displays a breadcrumb for the blog page.

markdown
{{< breadcrumb path="blog" >}}

Button

As an example, the following shortcode displays a tooltip for a dark button with a badge.

markdown
{{< button color="secondary" tooltip="Click on the inbox to view your unread messages" href="#!" badge="99+" >}}
    Inbox
{{< /button >}}

Button group

As an example, the following shortcode displays a group of three buttons.

markdown
{{< button-group aria-label="Basic example" >}}
  {{< button color="primary" href="#!" >}}Left{{< /button >}}
  {{< button color="primary" href="#!" >}}Middle{{< /button >}}
  {{< button color="primary" href="#!" >}}Right{{< /button >}}
{{< /button-group >}}

Card

As an example, the following shortcode displays a stacked card that links to the about page. It includes a custom header.

markdown
{{< card path="about" padding="3" class="w-50" color="body-tertiary" header="publication" footer="none" >}}

As an example, the following shortcode displays a centered carousel with three slides, 16x9 aspect ratio, and a relative width of 67% on large screens.

markdown
{{< carousel ratio="16x9" class="col-sm-12 col-lg-8 mx-auto" >}}
  {{< img src="img/coffee.jpg" caption="slide 1" >}}
  {{< img src="img/phone.jpg" caption="slide 2" >}}
  {{< img src="img/dunes.jpg" caption="slide 3" >}}
{{< /carousel >}}

Collapse

As an example, the following shortcode displays a button that, when clicked, triggers a panel to appear or disappear.

Some placeholder content for the collapse component. This panel is hidden by default but revealed when the user activates the relevant trigger.
markdown
{{< button collapse="collapse-1" >}}
    Trigger panel
{{< /button >}}

{{< collapse id="collapse-1" class="p-3 border rounded bg-primary-subtle" >}}
    Some placeholder content for the collapse component. This panel is <i>hidden by default</i> but
    revealed when the user activates the relevant trigger.
{{< /collapse >}}

Command prompt

Use the command shortcode to generate a block with a default bash command prompt.

export MY_VAR=123
markdown
{{< command >}}
export MY_VAR=123
{{< /command >}}

Specify user and host to add the user context to the prompt. In addition, use (out) to specify an output line and use \ to denote a line continuation.

export MY_VAR=123
echo "hello"
hello
echo one \
two \
three
one two three
echo "goodbye"
goodbye
markdown
{{< command user="user" host="localhost" >}}
export MY_VAR=123
echo "hello"
(out)hello
echo one \
two \
three
(out)one two three
echo "goodbye"
(out)goodbye
{{< /command >}}

Docs

Use the docs shortcode to display the content of a js, scss or toml file:

[style]
    primary = "#d43900"
    secondary = "#6c757d"
    success = "#198754"
    info = "#0dcaf0"
    warning = "#ffc107"
    danger = "#dc3545"
    light = "#f8f9fa"
    dark = "#212529"

Example

Use the example shortcode to display a code example and to render a preview of the same input.

export MY_VAR=123
markdown
{{< command >}}
export MY_VAR=123
{{< /command >}}

File

Use the file shortcode to print and highlight the full content of a given input file.

# toml-docs-start lang-main
[en]
    languageName = "English"
    contentDir = "content/en"
    weight = 1
# toml-docs-end lang-main
# toml-docs-start lang-param
    [en.params.head]
        tagline = "A Hugo Theme"
    [en.params.feature]
        link = "about"
        caption = "About"
    [en.params.footer]
        license = "Licensed under Creative Commons (<a href='https://creativecommons.org/licenses/by-nc-sa/4.0/' class='link-secondary' target='_blank' rel='noopener noreferrer'>CC BY-NC-SA 4.0</a>)."
        socialTitle = "Follow me"
        socialCaption = "I work on everything coding and tweet developer memes"
# toml-docs-end lang-param

[nl]
    languageName = "Nederlands"
    contentDir = "content/nl"
    weight = 2
    [nl.params.head]
        tagline = "Een Hugo Thema"
    [nl.params.feature]
        link = "over-mij"
        caption = "Over mij"
    [nl.params.footer]
        license = "Gelicenseerd onder Creative Commons (<a href='https://creativecommons.org/licenses/by-nc-sa/4.0/' class='link-secondary' target='_blank' rel='noopener noreferrer'>CC BY-NC-SA 4.0</a>)."
        socialTitle = "Volg mij"
        socialCaption = "Ik doe aan programmeren en tweet memes"
markdown
{{< file path="./config/_default/languages.toml" id="file-collapse-1" >}}

Icon

As an example, the following shortcodes show a square check, a brand logo, and a circle check.

markdown
{{< fa square-check >}}
{{< fab linkedin >}}
{{< fas circle-check >}}

Image

As an example, the following shortcode displays an image with rounded corners and a 21x9 aspect ratio.

Figure caption
markdown
{{< image src="img/flowers.jpg" ratio="21x9" caption="Figure caption" class="rounded" >}}

As an example, the following shortcode displays a tab group with vertically aligned pills.

markdown
  {{< nav type="pills" vertical="true" >}}
    {{< nav-item header="Nav Item #1" show="true" >}}
      This is the first item's nav body. It supports HTML content. The item is shown by adding the value
      <code>show</code> to the <code>class</code> argument.
    {{< /nav-item >}}
    {{< nav-item header="Nav Item #2" >}}
      This is the second item's nav body. It too supports HTML content.
    {{< /nav-item >}}
    {{< nav-item header="Nav Item #3" >}}
      This is the third item's nav body.
    {{< /nav-item >}}
  {{< /nav >}}

As an example, the following shortcode displays a light navigation header.

markdown
{{< navbar path="about" color="primary" size="md" search="false" menus="sample" title="Brand" mode="false" >}}

Release

As an example, the following shortcode displays a default release button.

markdown
{{< release version="v0.14.1" >}}

Spinner

As an example, the following shortcode displays a centered spinner.

Loading...
markdown
{{< spinner color="info" class="text-center" >}}
Loading...
{{< /spinner >}}

Timeline

As an example, the following shortcode displays a timeline with the file data/timeline-en.yml as data.

July 1, 2023

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cupiditate ducimus officiis quod! Aperiam eveniet nam nostrum odit quasi ullam voluptatum. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cupiditate ducimus officiis quod! Aperiam eveniet nam nostrum odit quasi ullam voluptatum.

May 6, 2023

Lorem ipsum dolor sit amet.

February 4, 2023

Cupiditate ducimus officiis quod!

Beta release

November 30, 2022

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cupiditate ducimus officiis quod! Aperiam eveniet nam nostrum odit quasi ullam voluptatum. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cupiditate ducimus officiis quod! Aperiam eveniet nam nostrum odit quasi ullam voluptatum.

July 1, 2023

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cupiditate ducimus officiis quod! Aperiam eveniet nam nostrum odit quasi ullam voluptatum. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cupiditate ducimus officiis quod! Aperiam eveniet nam nostrum odit quasi ullam voluptatum.

May 6, 2023

Lorem ipsum dolor sit amet.

February 4, 2023

Cupiditate ducimus officiis quod!

Beta release

November 30, 2022

Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cupiditate ducimus officiis quod! Aperiam eveniet nam nostrum odit quasi ullam voluptatum. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cupiditate ducimus officiis quod! Aperiam eveniet nam nostrum odit quasi ullam voluptatum.

markdown
{{< timeline data="timeline-en" background="dark" >}}

Toast

As an example, the following shortcode displays a button that, when clicked, triggers the toast message.

Show toast 1
Show toast 2
markdown
{{< button toast="toast-example-1" >}}
    Show toast 1
{{< /button >}}

{{< button toast="toast-example-2" >}}
    Show toast 2
{{< /button >}}

{{< toast id="toast-example-1" header="First title" >}}
    This is the first toast message.
{{< /toast >}}

{{< toast id="toast-example-2" header="Second title" >}}
    This is the second toast message.
{{< /toast >}}

Tooltip

As an example, the following shortcode displays a tooltip for a colored hyperlink.

demonstration
markdown
{{< tooltip color="primary" title="Tooltip" href="#!" >}}Tooltip{{< /tooltip >}} demonstration
Follow me

I work on everything coding and tweet developer memes