5. 徽章,按钮和图标

5.1. 徽章

Inline badges can be used as a labelling component. Badges are available in each semantic color, with filled and outline variants:

内联标识可以用作标签组件。
徽章有各种语义颜色,填充和轮廓的变体:

  • plain badge

  • primary, primary-line

  • secondary, secondary-line

  • success, success-line

  • info, info-line

  • warning, warning-line

  • danger, danger-line

  • light, light-line

  • dark, dark-line

Syntax
{bdg}`plain badge`

{bdg-primary}`primary`, {bdg-primary-line}`primary-line`

{bdg-secondary}`secondary`, {bdg-secondary-line}`secondary-line`

{bdg-success}`success`, {bdg-success-line}`success-line`

{bdg-info}`info`, {bdg-info-line}`info-line`

{bdg-warning}`warning`, {bdg-warning-line}`warning-line`

{bdg-danger}`danger`, {bdg-danger-line}`danger-line`

{bdg-light}`light`, {bdg-light-line}`light-line`

{bdg-dark}`dark`, {bdg-dark-line}`dark-line`
:bdg:`plain badge`

:bdg-primary:`primary`, :bdg-primary-line:`primary-line`

:bdg-secondary:`secondary`, :bdg-secondary-line:`secondary-line`

:bdg-success:`success`, :bdg-success-line:`success-line`

:bdg-info:`info`, :bdg-info-line:`info-line`

:bdg-warning:`warning`, :bdg-warning-line:`warning-line`

:bdg-danger:`danger`, :bdg-danger-line:`danger-line`

:bdg-light:`light`, :bdg-light-line:`light-line`

:bdg-dark:`dark`, :bdg-dark-line:`dark-line`

bdg-link- and bdg-ref- variants are also available for use with links and references. The syntax is the same as for the ref role.

’ bdg-link- ‘和’ bdg-ref- '变体也可用于链接和参考。
语法与“ref”角色相同。

https://example.com

explicit title

badges

Syntax
{bdg-link-primary}`https://example.com`

{bdg-link-primary-line}`explicit title <https://example.com>`
:bdg-link-primary:`https://example.com`

:bdg-link-primary-line:`explicit title <https://example.com>`

5.2. 按钮

Buttons allow users to navigate to external (button-link) / internal (button-ref) links with a single tap.

按钮允许用户通过一次点击导航到外部(“按钮链接”)/内部(“按钮引用”)链接。

https://example.com

Button text

https://example.com

https://example.com

https://example.com

buttons

Reference Button text

Syntax
```{button-link} https://example.com
```

```{button-link} https://example.com
Button text
```

```{button-link} https://example.com
:color: primary
:shadow:
```

```{button-link} https://example.com
:color: primary
:outline:
```

```{button-link} https://example.com
:color: secondary
:expand:
```
.. button-link:: https://example.com

.. button-link:: https://example.com

    Button text

.. button-link:: https://example.com
    :color: primary
    :shadow:

.. button-link:: https://example.com
    :color: primary
    :outline:

.. button-link:: https://example.com
    :color: secondary
    :expand:

Note that by default sphinx converts the content of references to raw text. For example **Bold text** with ref-type set to ref will be rendered without bold:

Bold text

However, if using myst-parser, you can set the ref-type to myst, and the content will be properly rendered:

Bold text

Use the click-parent option to make the button’s parent container also clickable.

Card with an expanded button

https://example.com

See the Material Design and Bootstrap descriptions for further details.

5.3. 图标

Inline icon roles are available for both the GitHub octicon or FontAwesome libraries.

Octicon icons are added as SVG’s directly into the page with the octicon role.

By default the icon will be of height 1em (i.e. the height of the font). A specific height can be set after a semi-colon (;) with units of either px, em or rem. Additional CSS classes can also be added to the SVG after a second semi-colon (;) delimiter.

A coloured icon: , some more text.

A coloured icon: {octicon}`report;1em;sd-text-info`, some more text.
A coloured icon: :octicon:`report;1em;sd-text-info`, some more text.
All Octicons
  • alert:
  • alert-fill:
  • archive:
  • arrow-both:
  • arrow-down:
  • arrow-down-left:
  • arrow-down-right:
  • arrow-left:
  • arrow-right:
  • arrow-switch:
  • arrow-up:
  • arrow-up-left:
  • arrow-up-right:
  • beaker:
  • bell:
  • bell-fill:
  • bell-slash:
  • blocked:
  • bold:
  • book:
  • bookmark:
  • bookmark-fill:
  • bookmark-slash:
  • bookmark-slash-fill:
  • briefcase:
  • broadcast:
  • browser:
  • bug:
  • calendar:
  • check:
  • check-circle:
  • check-circle-fill:
  • checklist:
  • chevron-down:
  • chevron-left:
  • chevron-right:
  • chevron-up:
  • circle:
  • circle-slash:
  • clock:
  • code:
  • code-review:
  • code-square:
  • codescan:
  • codescan-checkmark:
  • codespaces:
  • columns:
  • comment:
  • comment-discussion:
  • commit:
  • container:
  • copy:
  • cpu:
  • credit-card:
  • cross-reference:
  • dash:
  • database:
  • dependabot:
  • desktop-download:
  • device-camera:
  • device-camera-video:
  • device-desktop:
  • device-mobile:
  • diamond:
  • diff:
  • diff-added:
  • diff-ignored:
  • diff-modified:
  • diff-removed:
  • diff-renamed:
  • dot:
  • dot-fill:
  • download:
  • duplicate:
  • ellipsis:
  • eye:
  • eye-closed:
  • file:
  • file-badge:
  • file-binary:
  • file-code:
  • file-diff:
  • file-directory:
  • file-directory-fill:
  • file-media:
  • file-submodule:
  • file-symlink-file:
  • file-zip:
  • filter:
  • flame:
  • fold:
  • fold-down:
  • fold-up:
  • gear:
  • gift:
  • git-branch:
  • git-commit:
  • git-compare:
  • git-merge:
  • git-pull-request:
  • git-pull-request-closed:
  • git-pull-request-draft:
  • globe:
  • grabber:
  • graph:
  • hash:
  • heading:
  • heart:
  • heart-fill:
  • history:
  • home:
  • home-fill:
  • horizontal-rule:
  • hourglass:
  • hubot:
  • image:
  • inbox:
  • infinity:
  • info:
  • issue-closed:
  • issue-draft:
  • issue-opened:
  • issue-reopened:
  • italic:
  • iterations:
  • kebab-horizontal:
  • key:
  • key-asterisk:
  • law:
  • light-bulb:
  • link:
  • link-external:
  • list-ordered:
  • list-unordered:
  • location:
  • lock:
  • logo-gist:
  • logo-github:
  • mail:
  • mark-github:
  • markdown:
  • megaphone:
  • mention:
  • meter:
  • milestone:
  • mirror:
  • moon:
  • mortar-board:
  • multi-select:
  • mute:
  • no-entry:
  • no-entry-fill:
  • north-star:
  • note:
  • number:
  • organization:
  • package:
  • package-dependencies:
  • package-dependents:
  • paintbrush:
  • paper-airplane:
  • paste:
  • pencil:
  • people:
  • person:
  • person-add:
  • person-fill:
  • pin:
  • play:
  • plug:
  • plus:
  • plus-circle:
  • project:
  • pulse:
  • question:
  • quote:
  • reply:
  • repo:
  • repo-clone:
  • repo-forked:
  • repo-pull:
  • repo-push:
  • repo-template:
  • report:
  • rocket:
  • rows:
  • rss:
  • ruby:
  • screen-full:
  • screen-normal:
  • search:
  • server:
  • share:
  • share-android:
  • shield:
  • shield-check:
  • shield-lock:
  • shield-x:
  • sidebar-collapse:
  • sidebar-expand:
  • sign-in:
  • sign-out:
  • single-select:
  • skip:
  • smiley:
  • sort-asc:
  • sort-desc:
  • square:
  • square-fill:
  • squirrel:
  • stack:
  • star:
  • star-fill:
  • stop:
  • stopwatch:
  • strikethrough:
  • sun:
  • sync:
  • tab:
  • table:
  • tag:
  • tasklist:
  • telescope:
  • telescope-fill:
  • terminal:
  • three-bars:
  • thumbsdown:
  • thumbsup:
  • tools:
  • trash:
  • triangle-down:
  • triangle-left:
  • triangle-right:
  • triangle-up:
  • typography:
  • unfold:
  • unlock:
  • unmute:
  • unverified:
  • upload:
  • verified:
  • versions:
  • video:
  • workflow:
  • x:
  • x-circle:
  • x-circle-fill:
  • zap:

FontAwesome icons are added via the Fontawesome CSS classes. If the theme you are using does not already include the FontAwesome CSS, it should be loaded in your configuration from a font-awesome CDN, with the html_css_files option, e.g.:

html_css_files = ["https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/fontawesome.min.css"]

Use either fa (deprecated in font-awesome v5), fas, fab or far for the role name. Note that not all regular style icons are free, far role only works with free ones.

An icon {fas}`spinner;sd-bg-primary sd-bg-text-primary`, some more text.
An icon :fas:`spinner;sd-bg-primary sd-bg-text-primary`, some more text.

An icon , some more text.

By default, icons will only be output in HTML formats. But if you want fontawesome icons to be output on LaTeX, using the fontawesome package, you can add to your configuration:

sd_fontawesome_latex = True