I want to share you a css snippet that improves the integration of embed queries in notes.
Use case
I love the dataview plugin, but sometime its to complicated for certain searches, to search in the body of notes, without dvFiels and without knowing javascript. So I often use embed queries to obtain the result of a search in a note.
However, the embed queries really stand out from the rest of the note with the highlights and gray background, so I created this snippet that removes the gray background, hides the search icon, extends the embed query container so you don’t have to scroll and makes the text apprence similar to the note.
I use it in combination with the obsidian query control.
Usage
All the embeded queries will have improvements. You can put 2 cssclass to better improve:
- query-list: removes the number of matches on the right, and removes the borders from the results; a setting with the style setting plugin lets you quickly remove or restore them.
- query-neutral: removes highlighting from matching text
The snippet
/* voir l'ensemble des résultats sur la page sans scroller */
.internal-query .search-result-container {
height: fit-content;
min-height: fit-content;
max-height: none;
}
.markdown-preview-view .internal-query .search-result-container {
height: fit-content;
min-height: fit-content;
max-height: none;
}
/* Cache l'icone de recherche */
.internal-query .internal-query-header-icon {
display: none;
}
/* cache l'icone de recherche */
.markdown-preview-view .internal-query .internal-query-header-icon {
display: none;
}
/* Modifie les embed query */
.search-empty-state {
color: var(--text-normal);
border: none;
font-size: 0;
margin: 0 0 0;
padding-left: 0;
}
.tree-item-inner {
color: var(--text-normal);
}
.internal-query .search-result-container {
padding: var(--size-4-2);
border: 0px solid var(--background-modifier-border);
background-color: var(--background-primary);
border-radius: var(--radius-m);
min-width: 0;
}
.internal-query {
margin: 0;
border-top: 0px solid var(--background-modifier-border);
}
.search-result-file-matches {
color: var(--text-normal);
}
.internal-query .search-result-container {
border: 0px solid var(--background-modifier-border) !important;
}
.query-list .search-result-file-matches {
box-shadow: 0 0 0 var(--embed-query-border) var(--background-modifier-border);
}
.query-list .tree-item-flair {
font-size: 0;
--background-modifier-hover: none;
}
.query-list .tree-item-flair:hover {
font-size: 0;
--background-modifier-hover: none;
background-color: var(--background-primary);
}
.query-neutral .search-result-file-matched-text {
background-color: transparent !important;
}
/* @settings
name: control embed query
id: hide-control-embed-query
settings:
-
id: embed-query-border
title: largeur de la bordure
description: largeur de la bordure autour des résultats, 0 pour pas de bordure, 1 pour des bordures
type: variable-number
default: 0
format: px
*/
Exemples
with renderMarkdown by query control
And in a list: