徽章、按钮与图标

徽章

内联徽章可用作标签组件。徽章提供每种语义颜色,并有填充和轮廓两种变体:

  • plain badge

  • primary, primary-line

  • secondary, secondary-line

  • success, success-line

  • info, info-line

  • warning, warning-line

  • danger, danger-line

  • light, light-line

  • muted, muted-line

  • dark, dark-line

  • white, white-line

  • black, black-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-muted}`muted`, {bdg-muted-line}`muted-line`

{bdg-dark}`dark`, {bdg-dark-line}`dark-line`

{bdg-white}`white`, {bdg-white-line}`white-line`

{bdg-black}`black`, {bdg-black-line}`black-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-muted:`muted`, :bdg-muted-line:`muted-line`

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

:bdg-white:`white`, :bdg-white-line:`white-line`

:bdg-black:`black`, :bdg-black-line:`black-line`

bdg-link-bdg-ref- 变体也可用于链接和引用。其语法与 ref 角色相同。

https://example.com

explicit title

徽章

语法
{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>`

更多信息请参阅Bootstrap徽章,以及相关的Material Design chip

按钮

按钮允许用户通过一次点击导航到外部(button-link)或内部(button-ref)链接。

https://example.com

按钮文本

https://example.com

https://example.com

https://example.com

按钮

Reference Button text

语法
```{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:

请注意,默认情况下,Sphinx 会将引用的内容转换为纯文本。例如,**Bold text**ref-type 设置为 ref 时,将不会以粗体呈现:

Bold text

然而,如果使用myst-parser,您可以将 ref-type 设置为 myst,内容将正确呈现:

Bold text

使用 click-parent 选项使按钮的父容器也可点击。

带有扩展按钮的卡片

https://example.com

请参阅 Material DesignBootstrap 的描述以获取更多详细信息。

内联图标

内联图标角色适用于 GitHub octiconGoogle Material Design IconsFontAwesome 库。

Octicon 图标和 Material 图标通过 octiconmaterial-<flavor> 角色以 SVG 格式直接嵌入页面。以下是 Material Design 图标的不同风格。

默认情况下,图标的高度为 1em (即字体的高度)。可以在分号 (;) 后设置特定高度,单位可以是 pxemrem。还可以在第二个分号 (;) 分隔符后为 SVG 添加额外的 CSS 类。

Octicon 图标

带颜色的图标:,以及一些更多文本。

A coloured icon: {octicon}`report;1em;sd-text-info`, some more text.
A coloured icon: :octicon:`report;1em;sd-text-info`, some more text.
全部 Octicon
accessibility
accessibility-inset
alert
alert-fill
apps
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
cache
calendar
check
check-circle
check-circle-fill
checkbox
checklist
chevron-down
chevron-left
chevron-right
chevron-up
circle
circle-slash
clock
clock-fill
cloud
cloud-offline
code
code-of-conduct
code-review
code-square
codescan
codescan-checkmark
codespaces
columns
command-palette
comment
comment-discussion
commit
container
copilot
copilot-error
copilot-warning
copy
cpu
credit-card
cross-reference
dash
database
dependabot
desktop-download
device-camera
device-camera-video
device-desktop
device-mobile
devices
diamond
diff
diff-added
diff-ignored
diff-modified
diff-removed
diff-renamed
discussion-closed
discussion-duplicate
discussion-outdated
dot
dot-fill
download
duplicate
ellipsis
eye
eye-closed
feed-discussion
feed-forked
feed-heart
feed-issue-closed
feed-issue-draft
feed-issue-open
feed-issue-reopen
feed-merged
feed-person
feed-plus
feed-public
feed-pull-request-closed
feed-pull-request-draft
feed-pull-request-open
feed-repo
feed-rocket
feed-star
feed-tag
feed-trophy
file
file-added
file-badge
file-binary
file-code
file-diff
file-directory
file-directory-fill
file-directory-open-fill
file-directory-symlink
file-media
file-moved
file-removed
file-submodule
file-symlink-file
file-zip
filter
filter-remove
fiscal-host
flame
fold
fold-down
fold-up
gear
gift
git-branch
git-commit
git-compare
git-merge
git-merge-queue
git-pull-request
git-pull-request-closed
git-pull-request-draft
globe
goal
grabber
graph
hash
heading
heart
heart-fill
history
home
home-fill
horizontal-rule
hourglass
hubot
id-badge
image
inbox
infinity
info
issue-closed
issue-draft
issue-opened
issue-reopened
issue-tracked-by
issue-tracks
italic
iterations
kebab-horizontal
key
key-asterisk
law
light-bulb
link
link-external
list-ordered
list-unordered
location
lock
log
logo-gist
logo-github
mail
mark-github
markdown
megaphone
mention
meter
milestone
mirror
moon
mortar-board
move-to-bottom
move-to-end
move-to-start
move-to-top
multi-select
mute
no-entry
no-entry-fill
north-star
note
number
organization
package
package-dependencies
package-dependents
paintbrush
paper-airplane
paperclip
passkey-fill
paste
pencil
people
person
person-add
person-fill
pin
pin-slash
pivot-column
play
plug
plus
plus-circle
project
project-roadmap
project-symlink
project-template
pulse
question
quote
read
redo
rel-file-path
reply
repo
repo-clone
repo-deleted
repo-forked
repo-locked
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-slash
shield-x
sidebar-collapse
sidebar-expand
sign-in
sign-out
single-select
skip
skip-fill
sliders
smiley
sort-asc
sort-desc
sparkle-fill
sponsor-tiers
square
square-fill
squirrel
stack
star
star-fill
stop
stopwatch
strikethrough
sun
sync
tab
tab-external
table
tag
tasklist
telescope
telescope-fill
terminal
three-bars
thumbsdown
thumbsup
tools
tracked-by-closed-completed
tracked-by-closed-not-planned
trash
triangle-down
triangle-left
triangle-right
triangle-up
trophy
typography
undo
unfold
unlink
unlock
unmute
unread
unverified
upload
verified
versions
video
webhook
workflow
x
x-circle
x-circle-fill
zap
zoom-in
zoom-out

Material Design 图标

Material Design 图标提供了多种风格。每种风格代表 sphinx-design 中使用的不同角色。这些风格包括:

  • material-regular

  • material-outlined

  • material-round

  • material-sharp

  • material-twotone

并非所有图标都适用于每种风格,但大多数都可以。这里不展示全部 10660 多个图标,建议您浏览由 Google 托管的 Material Design Icons 展示页面 来查看可用图标。

  • 常规图标:,以及一些更多文本。

  • 带颜色的常规图标:,以及一些更多文本。

  • 带颜色的轮廓图标:,以及一些更多文本。

  • 带颜色的锐利图标:,以及一些更多文本。

  • 带颜色的圆润图标:,以及一些更多文本。

  • 带颜色的双色调图标:,以及一些更多文本。

- A regular icon: {material-regular}`data_exploration;2em`, some more text
- A coloured regular icon: {material-regular}`settings;3em;sd-text-success`, some more text.
- A coloured outline icon: {material-outlined}`settings;3em;sd-text-success`, some more text.
- A coloured sharp icon: {material-sharp}`settings;3em;sd-text-success`, some more text.
- A coloured round icon: {material-round}`settings;3em;sd-text-success`, some more text.
- A coloured two-tone icon: {material-twotone}`settings;3em;sd-text-success`, some more text.
- A fixed size icon: {material-regular}`data_exploration;24px`, some more text.
- A regular icon: :material-regular:`data_exploration;2em`, some more text
- A coloured regular icon: :material-regular:`settings;3em;sd-text-success`, some more text.
- A coloured outline icon: :material-outlined:`settings;3em;sd-text-success`, some more text.
- A coloured sharp icon: :material-sharp:`settings;3em;sd-text-success`, some more text.
- A coloured round icon: :material-round:`settings;3em;sd-text-success`, some more text.
- A coloured two-tone icon: :material-twotone:`settings;3em;sd-text-success`, some more text.
- A fixed size icon: :material-regular:`data_exploration;24px`, some more text.

FontAwesome 图标

FontAwesome 图标通过 FontAwesome 的 CSS 类添加。如果您使用的主题尚未包含 FontAwesome 的 CSS,可以通过 html_css_files 配置选项从 font-awesome CDN 加载,例如:

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

角色名称可以使用 fa (在 font-awesome v5 中已弃用)、fasfabfar。请注意,并非所有常规样式的图标都是免费的,far 角色仅适用于免费图标。

警告

由于 FontAwesome 图标是直接从其分发的 CSS 中获取的,因此不支持为 fa* 角色指定高度/大小。不过,您可以随时添加自定义的 CSS 类来控制 font-size 属性。

如果为 fa* 角色提供了高度/大小,它将被解释为 CSS 类。fa* 角色的参数中最多只能包含 1 个 ;

- An icon {fas}`spinner;sd-text-primary`, some more text.
- An icon {fab}`github`, some more text.
- An icon {fab}`gitkraken;sd-text-success fa-xl`, some more text.
- An icon {fas}`skull;sd-text-danger`, some more text.
- An icon :fas:`spinner;sd-text-primary`, some more text.
- An icon :fab:`github`, some more text.
- An icon :fab:`gitkraken;sd-text-success fa-xl`, some more text.
- An icon :fas:`skull;sd-text-danger`, some more text.
  • 图标 ,以及一些更多文本。

  • 图标 ,以及一些更多文本。

  • An icon , some more text.

  • An icon , some more text.

默认情况下,图标仅在 HTML 格式中输出。但如果您希望在 LaTeX 中输出 FontAwesome 图标,可以使用 fontawesome 包,并在配置中添加:

sd_fontawesome_latex = True