Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
/*
* Collapsible blocks (native <details>/<summary>) in note content, shared by the editor, read-only
* notes, the share theme and the print view. Editor-only rules are in `collapsible.css` and the
* client's `style.css`.
*/
.ck-content details.trilium-collapsible {
--collapsible-block-background: var(--card-background-color);
--collapsible-block-summary-background: var(--card-background-color);
--collapsible-block-summary-delimiter-color: var(--main-background-color);
--_border-radius: 8px;
--_block-padding: .75rem;
--_inline-padding: 1rem;
--_margin-between-collapsibles: 3px;
--_content-indent: 2rem;
--_arrow-gap: 2rem;
position: relative;
overflow: hidden;
isolation: isolate;
margin: 1em 0;
border-radius: var(--_border-radius);
background: var(--collapsible-block-background);
padding: var(--_block-padding) var(--_inline-padding) var(--_block-padding) var(--_content-indent);
&:not(& + &):has(+ details.trilium-collapsible) {
/* First collapsibile from the series */
margin-bottom: var(--_margin-between-collapsibles);
border-end-start-radius: 0;
border-end-end-radius: 0;
}
& + &:has(+ details.trilium-collapsible) {
/* Middle collapsibile blocks from the series */
margin-bottom: var(--_margin-between-collapsibles);
margin-top: 0;
border-radius: 0;
}
& + &:not(:has(+ details.trilium-collapsible)) {
/* The last collapsibile from the series */
margin-top: 0;
border-start-start-radius: 0;
border-start-end-radius: 0;
}
> summary {
position: relative;
left: calc(0px - var(--_content-indent ) / 2);
width: calc(100% + var(--_content-indent));
padding-left: var(--_arrow-gap);
cursor: pointer;
font-weight: 500;
outline: none;
list-style: none; /* native marker replaced by the custom arrow below */
&::-webkit-details-marker {
display: none;
}
&::after {
display: block;
content: "";
z-index: -1;
position: absolute;
top: calc(0px - (var(--_block-padding) + 1px));
left: calc(0px - var(--_content-indent ) / 2);
width: calc(100% + var(--_inline-padding) * 2 + 1px);
height: calc(100% + var(--_block-padding) * 2 + 1px);
background: var(--collapsible-block-summary-background);
}
&:hover::after {
background: var(--card-background-hover-color);
}
}
&[open] > summary {
margin-bottom: calc(var(--_block-padding) * 2);
&::after {
border-bottom: 2px solid var(--collapsible-block-summary-delimiter-color);
}
}
>*:last-child:not(summary) {
margin-bottom: 0;
}
}
/*
* Custom arrow, shared by every view. In the editor it is a real <span> (inserted by the
* editing downcast) because it needs click and keyboard handlers; elsewhere that span
* doesn't exist — the arrow is deliberately not part of the saved HTML — so the data view
* (read-only text notes, markdown preview) draws it on the summary instead and lets the
* native <details> toggle do the work. Both share the geometry and the glyph below.
*/
.ck-content details.trilium-collapsible > summary > .trilium-collapsible-arrow,
.ck-content:not(.ck-editor__editable) details.trilium-collapsible > summary::before {
position: absolute;
left: 0;
top: -0.05em;
width: 1lh;
height: 1lh;
display: flex;
justify-content: center;
align-items: center;
font-family: boxicons;
cursor: pointer;
user-select: none;
/* Scaled rather than sized with font-size, so the box keeps the summary's line metrics
* and the arrow stays centred on the first line of the title. */
transform: scale(1.3);
transition: transform 0.15s ease;
}
.ck-content details.trilium-collapsible > summary > .trilium-collapsible-arrow::before,
.ck-content:not(.ck-editor__editable) details.trilium-collapsible > summary::before {
content: "\ea50";
}
.ck-content details.trilium-collapsible[open] > summary > .trilium-collapsible-arrow,
.ck-content:not(.ck-editor__editable) details.trilium-collapsible[open] > summary::before {
transform: scale(1.3) rotate(90deg);
}