CSS snippets let you style Grid and Masonry views in ways the plugin's settings don't cover.
To learn more about snippets, including how to add one to your vault, refer to CSS snippets.
Use Obsidian's variables
Cards take their colors, fonts, and spacing from Obsidian's own CSS variables, so a theme or snippet that changes them changes the cards too. For example, this snippet changes Obsidian's normal text color, which card titles use too, in the light and dark color schemes:
.theme-light {
--text-normal: #2e3440;
}
.theme-dark {
--text-normal: #e5e9f0;
}
Variables
Dynamic Views also has variables of its own. Set them on body to change every view, or on a class of your own to change one view. For more information, refer to Style a single view.
Cards
| Variable | Default | Description |
|---|---|---|
--dynamic-views-card-border-radius | 8px | Card corner radius. Images at the card's edge follow it. |
--dynamic-views-card-padding | 8px | Space between the card's edge and its content. |
--dynamic-views-path-separator-padding | 0.15em | Space on either side of the / between folder names in a path. |
--dynamic-views-icon-shadow | Two soft dark drop shadows | Shadow behind icons drawn over images, such as the URL button. Takes a filter value, such as none. |
--dynamic-views-embedded-height | The view's Embedded height | Maximum height of a base in a note, in place of the view's Embedded height. none removes the limit. |
Images
Thumbnail
| Variable | Default | Description |
|---|---|---|
--dynamic-views-thumbnail-border-radius | 4px | Corner radius. |
--dynamic-views-thumbnail-crop-position | center | With Fit set to Crop, which part of the image stays in view, such as top. |
--dynamic-views-thumbnail-contain-position | center | With Fit set to Contain, where the image sits in its box, such as top. |
Cover
| Variable | Default | Description |
|---|---|---|
--dynamic-views-cover-border-radius | 0px | Corner radius where the cover meets the card's content. |
--dynamic-views-cover-inset | 0px | Space between the card's edge and the cover. |
--dynamic-views-left-right-cover-height | 150px | Minimum height of a card with the cover on the left or right. |
--dynamic-views-cover-crop-position | center | With Fit set to Crop, which part of the image stays in view, such as top. |
--dynamic-views-cover-contain-position | center | With Fit set to Contain, where the image sits in its box, such as top. |
Poster
| Variable | Default | Description |
|---|---|---|
--dynamic-views-poster-crop-position | center | With Fit set to Crop, which part of the image stays in view, such as top. |
--dynamic-views-poster-contain-position | center | With Fit set to Contain, where the image sits in its box, such as top. |
--dynamic-views-poster-overlay-blur | 3px | With the Overlay display mode, blur of the poster while its details show over it. 0px turns it off. |
--dynamic-views-poster-overlay-dark | 70 | With the Overlay display mode, how much a dark tint darkens the poster while its details show, in percent. |
--dynamic-views-poster-overlay-light | 70 | With the Overlay display mode, how much a light tint lightens the poster while its details show, in percent. |
Backdrop
| Variable | Default | Description |
|---|---|---|
--dynamic-views-backdrop-crop-position | center | Which part of the image stays in view, such as top. |
--dynamic-views-backdrop-overlay-dark | 60 | How much a dark tint darkens the backdrop, in percent. |
--dynamic-views-backdrop-overlay-light | 70 | How much a light tint lightens the backdrop, in percent. |
--dynamic-views-backdrop-overlay-blur | 0px | Blur of the backdrop. |
Classes you can target
| Class | What it styles |
|---|---|
.card | Card |
.card-title | Card title |
.card-title-icon | Icon from the Icon property |
.card-title-ext | File type badge |
.card-subtitle | Card subtitle |
.card-text-preview | Text preview |
.property | Property row |
.property-name-inline | Property name inline with the value |
.property-name-above | Property name above the value |
.property-value | Property value |
.card-cover, .card-thumbnail, .card-poster, .card-backdrop | Image, by image format |
.card-url-button | URL button |
To style only one image format, start the selector with its class on the card: .image-format-cover, .image-format-thumbnail, .image-format-poster, or .image-format-backdrop. To style only one layout, start it with [data-view-type="dynamic-views-grid"] or [data-view-type="dynamic-views-masonry"].
Style a single view
To apply a snippet to one view only, give that view a class of its own. In the View settings, under CSS classes, enter a class name, for example reading-list.
Then start each selector in your snippet with that class:
.reading-list .card-title {
font-family: serif;
}
The class goes on the view's own container, so the snippet only changes cards in that view.
For a base in a note, you can instead add the class to the note's cssclasses property. The snippet then applies to every view of the base shown in that note.
Example
This snippet gives every card rounder corners and more space inside, keeps the top of cover images in view, and sets titles in a serif font in one view:
body {
--dynamic-views-card-border-radius: 16px;
--dynamic-views-card-padding: 12px;
--dynamic-views-cover-crop-position: top;
}
.reading-list .card-title {
font-family: serif;
}