Search...Search plugins and themes...
⌘K
Sign in
  • Get started
  • Download
  • Pricing
  • Enterprise
  • Account
  • Obsidian
  • Overview
  • Sync
  • Publish
  • Canvas
  • Mobile
  • Web Clipper
  • CLI
  • Learn
  • Help
  • Developers
  • Changelog
  • About
  • Roadmap
  • Blog
  • Resources
  • System status
  • License overview
  • Terms of service
  • Privacy policy
  • Security
  • Community
  • Plugins
  • Themes
  • Discord
  • Forum / 中文论坛
  • Merch store
  • Brand guidelines
Follow us
DiscordTwitterBlueskyThreadsMastodonYouTubeGitHub
© 2026 Obsidian

CSS Resource Variables

valleytheknightvalleytheknight31 downloads

Map a local vault file (image, font, anything) to a CSS custom property, so any theme or snippet can reference your own local files with var().

Add to Obsidian
  • Overview
  • Scorecard
  • Updates2

Map a file already in your vault to a CSS custom property, so any theme or snippet whose CSS reads that variable name picks up your file automatically.

The problem this solves

Obsidian's theme and snippet CSS gets injected as raw text into the app, with no folder context of its own. A relative path like url("images/backdrop.jpg") can't resolve to a real file, and file:///app://local/ URLs are blocked by the app for security. The only way to get a real, loadable URL for a local file is Obsidian's own plugin API (getResourcePath()), which only a plugin can call. If a theme or snippet author wants to let you plug in your own local image, font, or other asset, this is that missing piece.

This plugin does one thing: pick a file, name a CSS variable, done. Every theme's own CSS decides what to do with that variable; this plugin has no opinion about styling.

How to use it

  1. Open Settings -> CSS Resource Variables.
  2. Click Add mapping, and pick a file from your vault.
  3. Type a variable name (no leading --, that gets added automatically). Use whatever name the consuming theme or snippet's CSS already expects; check its own docs for the exact name it reads.
  4. Any CSS anywhere in your vault that reads var(--your-name) now resolves to your file. This is re-resolved automatically every time Obsidian loads, and it follows the file if you rename or move it.

What you can do with it

Give a theme a custom background image, if that theme exposes a variable for it:

/* in the theme's own CSS */
.some-note-type .markdown-preview-view {
  background-image: var(--my-backdrop);
}

Map any image in your vault to my-backdrop, and that note type now shows your photo as its background, offline, no bundled default, no network call.

Use your own font in a theme or snippet, without base64-encoding it yourself:

@font-face {
  font-family: "My Custom Font";
  src: var(--my-font-file);
}

Map a .ttf/.otf/.woff2 file in your vault to my-font-file, and that @font-face rule picks it up.

Anything else that takes a url(...) value. The plugin always wraps the resolved path in url("...") for you, so any CSS property that accepts a URL works the same way.

Settings reference

Setting What it does
Add mapping Opens a file picker; after you choose a file, type its CSS variable name in the new field that appears
File icon (per mapping) Change which file this mapping points to
Trash icon (per mapping) Remove the mapping and clear its CSS variable immediately

Good to know

  • Only the vault-relative file path is stored, never a resolved URL. Resolved URLs are session-specific in Obsidian and would break on the next launch if cached, so this plugin re-resolves on every load instead.
  • No network calls, no telemetry. This plugin reads file paths and resolves them through Obsidian's own API, nothing else.
  • Removing a mapping clears its CSS variable immediately, so a deleted mapping doesn't leave a stale value behind.
  • Two mappings can't usefully share the same variable name; the plugin warns you if you pick one that's already in use, but doesn't block it, in case that's genuinely what you want.

Contributing

Issues and pull requests are welcome.

Support

If this plugin is useful to you, you can buy me a coffee.

License

MIT

HealthExcellent
ReviewSatisfactory
About
Map a vault file to a CSS custom property so themes and snippets can reference it via var(--name). Provide local images, fonts, or other assets to theme/snippet CSS without network calls or base64 embedding; paths auto-resolve and follow files when renamed or moved.
CSSThemingImages
Details
Current version
1.0.1
Last updated
6 days ago
Created
7 days ago
Updates
2 releases
Downloads
31
Compatible with
Obsidian 1.1.0+
Platforms
Desktop, Mobile
License
MIT
Report bugRequest featureReport plugin
Sponsor
Buy Me a Coffee
Author
valleytheknightvalleytheknight
GitHubchrisairbrown-del
  1. Community
  2. Plugins
  3. CSS
  4. CSS Resource Variables

Related plugins

Style Settings

Adjust theme, plugin, and snippet CSS variables.

Auto Card Link

Automatically fetches metadata from a URL and makes it as a card-styled link.

Background Image

Specify a remote URL as the background image, and a few settings to tweak the experience.

Contextual Typography

Add a data-tag-name attribute to all top-level divs in preview mode containing the child's tag name, allowing contextual typography styling.

Minimal Theme Settings

Control the colors and fonts in Minimal Theme.

Hider

Hide interface elements such as tooltips, status bar, titlebar, and more.

Share Note

Instantly share/publish a note, with the full theme and content exactly like you see in Obsidian. Data is shared encrypted by default, and only you and the person you send it to have the key.

Admonition

Admonition block-styled content.

Ink

Handwriting and drawing directly between paragraphs using a digital pen, stylus, or Apple pencil.

Custom Frames

Turn web apps into panes using iframes with custom styling. Also comes with presets for Google Keep, Todoist and more.