--- author: "Mark Dumay" title: "Custom Shortcodes" date: 2022-12-05 modified: 2022-12-31 description: "Available shortcodes using Bootstrap components and styling." tags: ["bootstrap", "shortcode"] thumbnail: img/sketch.jpg photoCredits: picjumbo.com photoSource: Pexels --- Bootstrap is an open-source web development framework originally created by Twitter. It uses a responsive, mobile-first approach that scales seamlessly across different screen sizes. Bootstrap includes an extensive collection of ready-to-use components, such as navigation bars, pagination controls, buttons, and much more. The Hinode theme exposes several of those components as Hugo shortcodes to simplify their usage within markdown content. The below paragraphs illustrate the available shortcodes and how to use them. ## Accordion Use the `accordion` shortcode to show a group of vertically collapsing and expanding items. Add `accordion-item` inner elements for each accordion item. The shortcode supports the following arguments: | Argument | Required | Description | |-------------|----------|-------------| | class | No | Optional class attribute of the accordion element, e.g. “w-50”. | {.table} Add an inner `accordion-item` element for each item of the accordion. The `accordion-item` element supports the following arguments: | Argument | Required | Description | |-----------|----------|-------------| | header | Yes | Required header of the accordion element. | | class | No | Optional class attribute of the inner accordion element, e.g. “show”. | {.table} As an example, the following shortcode displays an accordion with three elements, of which the first element is expanded. ```html {{}} {{}} 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 too supports HTML content. {{}} {{}} This is the third item's accordion body. {{}} {{}} ``` The result looks like this: {{< accordion >}} {{< accordion-item header="Accordion Item #1" class="show" >}} 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. {{< /accordion-item >}} {{< accordion-item header="Accordion Item #2" >}} This is the second item's accordion body. It too supports HTML content. {{< /accordion-item >}} {{< accordion-item header="Accordion Item #3" >}} This is the third item's accordion body. {{< /accordion-item >}} {{< /accordion >}} ## Alert Use the `alert` shortcode to display a contextual feedback message. The inner content is used as alert text. The shortcode supports the following arguments: | Argument | Required | Description | |-------------|----------|-------------| | color | No | Optional theme color of the alert, either "primary" (default), "secondary", "success", "danger", "warning", "info", "light", or "dark". | | dismissible | No | Optional flag to indicate the alert is dismissible, defaults to false. | {.table} As an example, the following shortcode displays a simple alert. ```html {{}} A simple danger alert—check it out! {{}} ``` The result looks like this: {{< alert color="danger" >}} A simple danger alert—check it out! {{< /alert >}} ## Breadcrumb Use the `breadcrumb` shortcode to display the current page’s location within the site's navigational hierarchy. The shortcode requires no arguments, see the following example. ```html {{}} ``` The result looks like this: {{< breadcrumb >}} ## Button Use the `button` shortcode to display a button with a hyperlink. The inner content is used as button title. The button supports an optional badge and tooltip. The shortcode supports the following arguments: | Argument | Required | Description | |-------------|----------|-------------| | href | No | Optional address for the button or hyperlink. Automatically assigned when using collapse. | | state | No | Optional state of the button, either "enabled" (default), "disabled", "active", or "inactive". | | size | No | Optional size of the button, either "sm", "md" (default), or "lg". | | color | No | Optional theme color of the element, either "primary" (default), "secondary", "success", "danger", "warning", "info", "light", or "dark". | | badge | No | Optional positioned badge to display on top of the button. | | outline | No | Optional flag indicating the button should be outlined, either "false" (default) or "true". | | aria-label | No | Optional label for the badge. | | tooltip | No | Optional text to display in a tooltip. Cannot be used together with collapse. Ignored for active/inactive buttons. | | collapse | No | Optional panel to collapse. Cannot be used together with tooltip. Ignored for active/inactive buttons. | | placement | No | How to position the tooltip: "top" (default), "bottom", "left", or "right". | {.table} As an example, the following shortcode displays a tooltip for a dark button with a badge. ```html {{}} Inbox {{}} ``` The result looks like this: {{< button color="dark" tooltip="Click on the inbox to view your unread messages" href="#" badge="99+" >}} Inbox {{< /button >}} ## Button Group Use the `button-group` shortcode to display a group of buttons. Add inner `