|
| 1 | +(tag-role)= |
| 2 | + |
| 3 | +# `tag(s)` role |
| 4 | + |
| 5 | + |
| 6 | +## About |
| 7 | + |
| 8 | +The `tag` and `tags` roles are shortcuts to the `badge` roles of sphinx{design}, |
| 9 | +see [](inv:sd#badges). |
| 10 | + |
| 11 | + |
| 12 | +## Details |
| 13 | + |
| 14 | +The idea is to need less code for defining "tag"-like badges within the |
| 15 | +[](#infocard-directive) element. All of them will use the `outline` option flag |
| 16 | +by default, to give them a corresponding visual appearance. |
| 17 | + |
| 18 | + |
| 19 | +## Synopsis |
| 20 | + |
| 21 | +There is the `{tag}`, and the `{tags}` role. A `{tag}` will render its text content |
| 22 | +1:1 into a single badge element, while `{tags}` will split the text by comma (`,`), |
| 23 | +and renders the outcome using individual badge elements. |
| 24 | + |
| 25 | + |
| 26 | +::::{sd-table} |
| 27 | +:widths: 3 3 3 3 |
| 28 | +:row-class: top-border |
| 29 | + |
| 30 | +:::{sd-row} |
| 31 | +```{sd-item} **Description** |
| 32 | +``` |
| 33 | +```{sd-item} **Appearance** |
| 34 | +``` |
| 35 | +```{sd-item} **MyST syntax** |
| 36 | +``` |
| 37 | +```{sd-item} **rST syntax** |
| 38 | +``` |
| 39 | +::: |
| 40 | + |
| 41 | +:::{sd-row} |
| 42 | +```{sd-item} Single tag |
| 43 | +``` |
| 44 | +```{sd-item} |
| 45 | +{tag}`foo, bar` |
| 46 | +``` |
| 47 | +```{sd-item} |
| 48 | +```markdown |
| 49 | +{tag}`foo, bar` |
| 50 | +``` |
| 51 | +```{sd-item} |
| 52 | +```restructuredtext |
| 53 | +:tag:`foo, bar` |
| 54 | +``` |
| 55 | +::: |
| 56 | + |
| 57 | +:::{sd-row} |
| 58 | +```{sd-item} Multiple tags |
| 59 | +``` |
| 60 | +```{sd-item} |
| 61 | +{tags}`foo, bar` |
| 62 | +``` |
| 63 | +```{sd-item} |
| 64 | +```markdown |
| 65 | +{tags}`foo, bar` |
| 66 | +``` |
| 67 | +```{sd-item} |
| 68 | +```restructuredtext |
| 69 | +:tags:`foo, bar` |
| 70 | +``` |
| 71 | +::: |
| 72 | + |
| 73 | +:::: |
| 74 | + |
| 75 | + |
| 76 | +## Color variants |
| 77 | + |
| 78 | +All colors of badges are supported, by appending a color label from the list of |
| 79 | +[semantic colors] as a suffix to the role name, like presented below. |
| 80 | + |
| 81 | +::::{sd-table} |
| 82 | +:widths: 3 3 6 |
| 83 | +:row-class: top-border |
| 84 | + |
| 85 | +:::{sd-row} |
| 86 | +```{sd-item} **Description** |
| 87 | +``` |
| 88 | +```{sd-item} **Appearance** |
| 89 | +``` |
| 90 | +```{sd-item} **MyST syntax** |
| 91 | +``` |
| 92 | +::: |
| 93 | + |
| 94 | +:::{sd-row} |
| 95 | +```{sd-item} Primary and secondary |
| 96 | +``` |
| 97 | +```{sd-item} |
| 98 | +{tags-primary}`foo, bar` \ |
| 99 | +{tags-secondary}`foo, bar` |
| 100 | +``` |
| 101 | +```{sd-item} |
| 102 | +```markdown |
| 103 | +{tags-primary}`foo, bar` \ |
| 104 | +{tags-secondary}`foo, bar` |
| 105 | +``` |
| 106 | +::: |
| 107 | + |
| 108 | +:::{sd-row} |
| 109 | +```{sd-item} Admonitions |
| 110 | +``` |
| 111 | +```{sd-item} |
| 112 | +{tags-success}`foo, bar` \ |
| 113 | +{tags-info}`foo, bar` \ |
| 114 | +{tags-warning}`foo, bar` \ |
| 115 | +{tags-danger}`foo, bar` |
| 116 | +``` |
| 117 | +```{sd-item} |
| 118 | +```markdown |
| 119 | +{tags-success}`foo, bar` \ |
| 120 | +{tags-info}`foo, bar` \ |
| 121 | +{tags-warning}`foo, bar` \ |
| 122 | +{tags-danger}`foo, bar` |
| 123 | +``` |
| 124 | +::: |
| 125 | + |
| 126 | +:::{sd-row} |
| 127 | +```{sd-item} |
| 128 | +Light to dark |
| 129 | +``` |
| 130 | +```{sd-item} |
| 131 | +{tags-white}`foo, bar` \ |
| 132 | +{tags-light}`foo, bar` \ |
| 133 | +{tags-muted}`foo, bar` \ |
| 134 | +{tags-dark}`foo, bar` \ |
| 135 | +{tags-black}`foo, bar` |
| 136 | +``` |
| 137 | +```{sd-item} |
| 138 | +```markdown |
| 139 | +{tags-white}`foo, bar` \ |
| 140 | +{tags-light}`foo, bar` \ |
| 141 | +{tags-muted}`foo, bar` \ |
| 142 | +{tags-dark}`foo, bar` \ |
| 143 | +{tags-black}`foo, bar` |
| 144 | +``` |
| 145 | +::: |
| 146 | + |
| 147 | +:::: |
| 148 | + |
| 149 | +````{note} |
| 150 | +While the table above only presents Markdown syntax, reStructuredText syntax is |
| 151 | +also supported. |
| 152 | +
|
| 153 | +```{eval-rst} |
| 154 | +:tag-warning:`REVIEW!` |
| 155 | +:tags-primary:`foo, bar` |
| 156 | +``` |
| 157 | +
|
| 158 | +```restructuredtext |
| 159 | +:tag-warning:`REVIEW!` |
| 160 | +:tags-primary:`foo, bar` |
| 161 | +``` |
| 162 | +```` |
| 163 | + |
| 164 | + |
| 165 | +--- |
| 166 | + |
| 167 | +_This page is written in Markedly Structured Text (MyST Markdown)._ |
| 168 | + |
| 169 | + |
| 170 | +[semantic colors]: https://sphinx-design.readthedocs.io/en/latest/css_classes.html#colors |
0 commit comments