Skip to content

Commit 91292c4

Browse files
authored
[Markdown] Document image theme context display (#2111)
* [Markdown] Document image theme context display * Simplify text * Small improvement * Small improvement
1 parent ee4dc99 commit 91292c4

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

docs/hub/model-cards.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,34 @@ Yes, you can add custom tags to your model by adding them to the `tags` field in
279279

280280
You can add a `not-for-all-audiences` tag to your model card metadata. When this tag is present, a message will be displayed on the model page indicating that the model is not for all audiences. Users can click through this message to view the model card.
281281

282+
### How can I display different images for dark and light mode?
283+
284+
You can display different versions of an image optimized for each theme. This is particularly useful for logos, diagrams, or screenshots that need different color schemes to maintain visibility and aesthetics across light and dark modes. To use this feature, you'll need to provide both versions of your image.
285+
286+
**For images uploaded via the markdown editor**
287+
288+
When you upload an image directly from the markdown editor (using drag-and-drop), append the URI fragment `#hf-light-mode-only` or `#hf-dark-mode-only` to the end of the image URL to specify which theme it should display in:
289+
290+
```markdown
291+
Image only displays when viewing in light mode
292+
![Logo](https://cdn-uploads.huggingface.co/production/uploads/logo-light.png#hf-light-mode-only)
293+
294+
Image only displays when viewing in dark mode
295+
![Logo](https://cdn-uploads.huggingface.co/production/uploads/logo-dark.png#hf-dark-mode-only)
296+
```
297+
298+
**For already hosted images**
299+
300+
If you want to reference images that are already hosted without re-uploading them, use HTML `<img>` tags with the following Tailwind CSS classes to specify which theme it should display in:
301+
302+
```html
303+
// Image only displays when viewing in dark mode
304+
<img class="hidden dark:block" src="https://hf.co/logo-dark.png" alt="Logo" />
305+
306+
// Image only displays when viewing in light mode
307+
<img class="dark:hidden" src="https://hf.co/logo-light.png" alt="Logo" />
308+
```
309+
282310
### Can I write LaTeX in my model card?
283311

284312
Yes! The Hub uses the [KaTeX](https://katex.org/) math typesetting library to render math formulas server-side before parsing the Markdown.

0 commit comments

Comments
 (0)