You can get the paragraphs in your nodes ready for the ToC module using these Twig templates.
frontend
Option 1:
:root {
--Color-Border: black;
--Color-Background: white;
--Spacing-01: 1rem;
--Spacing-02: 1.5rem;
}
body {
background: var(--Color-Background);
}
.table--color-border {
border-collapse: collapse;
tbody th {
text-align: left;
}
thead th,
tbody th {
padding: var(--Spacing-01) var(--Spacing-02) var(--Spacing-01) calc(25px / 2);
&:first-child {
padding-left: 0;
}
}
thead th {
border: none;
box-shadow: inset 0 -1px 0 0 var(--Color-Border),
inset 0 1px 0 0 var(--Color-Border);
text-align: left;
}
tbody td {
text-align: center;
}
tbody th,
tbody td {
font-weight: 400;
border-right: 25px solid var(--Color-Background);
border-bottom: 1px solid var(--Color-Border);
width: max-content;
&:last-child {
border-right: none;
}
}
}
.table--pseudo-elements {
border-collapse: collapse;
thead th {
border-top: 1px solid var(--Color-Border);
border-bottom: 1px solid var(--Color-Border);
}
td,
th {
padding: var(--Spacing-02) var(--Spacing-01);
}
td,
th:not(thead th) {
position: relative;
text-align: center;
&:first-child {
text-align: left;
padding: var(--Spacing-02) var(--Spacing-01) var(--Spacing-02) 0;
&::after {
content: '';
position: absolute;
left: 0;
bottom: 0;
width: calc(100% - var(--Spacing-01));
border-bottom: 1px solid var(--Color-Border);
}
}
&:last-child {
padding: var(--Spacing-02) 0 var(--Spacing-02) var(--Spacing-01);
&::after {
content: '';
position: absolute;
left: 0.5rem;
bottom: 0;
width: calc(100% - var(--Spacing-01));
border-bottom: 1px solid var(--Color-Border);
}
}
&::after {
content: '';
position: absolute;
left: var(--Spacing-01);
bottom: 0;
width: calc(100% - var(--Spacing-02));
border-bottom: 1px solid var(--Color-Border);
}
}
}How it works
border-bottom: 1px solid black;border-right: 25px solid white;
The right border isn't really intended as a border. It's acting as a fake column gap because its color matches the page background.
Disadvantage: depends on matching background color
Option 2:
:root {
--Color-Border: black;
--Spacing-01: 1rem;
--Spacing-02: 1.5rem;
}
.table--pseudo-elements {
border-collapse: collapse;
thead th {
border-top: 1px solid var(--Color-Border);
border-bottom: 1px solid var(--Color-Border);
}
td,
th {
padding: var(--Spacing-02) var(--Spacing-01);
}
td,
th:not(thead th) {
position: relative;
text-align: center;
&:first-child {
text-align: left;
padding: var(--Spacing-02) var(--Spacing-01) var(--Spacing-02) 0;
&::after {
content: '';
position: absolute;
left: 0;
bottom: 0;
width: calc(100% - var(--Spacing-01));
border-bottom: 1px solid var(--Color-Border);
}
}
&:last-child {
padding: var(--Spacing-02) 0 var(--Spacing-02) var(--Spacing-01);
&::after {
content: '';
position: absolute;
left: 0.5rem;
bottom: 0;
width: calc(100% - var(--Spacing-01));
border-bottom: 1px solid var(--Color-Border);
}
}
&::after {
content: '';
position: absolute;
left: var(--Spacing-01);
bottom: 0;
width: calc(100% - var(--Spacing-02));
border-bottom: 1px solid var(--Color-Border);
}
}
}How it works
Instead of using actual borders, every cell draws its own Pseudo-element border and reduced the width which creates the visual gap.width: calc(100% - var(--Spacing-02));
Disadvantage: much more code and maintenance
Option 3 (preferred):
:root {
--Color-Border: black;
--Spacing-01: 1rem;
--Spacing-02: 1.5rem;
}
.table--seperated-borders {
border-collapse: separate;
border-spacing: var(--Spacing-02) 0;
margin-left: calc(-1 * var(--Spacing-02));
margin-right: calc(-1 * var(--Spacing-02));
thead {
border: none;
box-shadow: inset 0 -1px 0 0 var(--Color-Border),
inset 0 1px 0 0 var(--Color-Border);
}
tbody td {
text-align: center;
}
td,
th {
border-bottom: 1px solid var(--Color-Border);
padding: var(--Spacing-02) var(--Spacing-01) var(--Spacing-02) 0;
}
}How it works
Uses the table model as intended. The browser creates real gaps between cells. Then each cell simply gets border-bottom: 1px solid black;. But this creates spacing outside the first and last column too.
This is why it is compensating with:
margin-left: calc(-1 * var(--Spacing-02));margin-right: calc(-1 * var(--Spacing-02));
The thead gets a solid line via box-shadow.
Disadvantage: creates outer gaps that often require compensation
How to create tables with collapsed and separated borders
Hide HTML comments in Chrome and Firefox browser inspector
/* Default theme */
:root {
--Background-Color: #fff;
--Text-Color: #000;
}
/* Dark theme */
@media (prefers-color-scheme: dark) {
:root {
--Background-Color: #000;
--Text-Color: #fff;
}
}
Consider the user's preference for dark or light system colors
{
"name": "Foo project",
"scripts": {
"sass-dev": "sass --watch --update --style=expanded src/scss:dist/css",
"sass-prod": "sass --no-source-map --style=compressed src/scss:dist/css"
},
"devDependencies": {
"sass": "^1.86.0"
}
}