Skip to main content

Collapse Database Groups by Default

Learn how to automatically collapse grouped Notion database sections in Super using a simple JavaScript workaround to improve page clarity and user experience.

Written by Charlene

When a grouped database contains many categories or items, having all groups expanded by default can make the page feel overwhelming for visitors.

While collapsing database groups by default is not currently a built-in feature in Super, you can achieve a similar result using the workaround below.

Note: Custom code is available on paid Super plans. An active subscription is required to use this workaround.

How to Set It Up

  1. In your Super dashboard, go to Code → Body.

  2. Paste the following JavaScript snippet into the Body code section.

  3. Save your changes and refresh your site.

This script automatically collapses grouped database sections when the page loads, allowing visitors to expand only the categories they want to view.

<script>
function collapseGroups() {
document.querySelectorAll('.notion-collection-group__section-toggle').forEach(toggle => {
if (!toggle.dataset.collapsed) {
toggle.click();
toggle.dataset.collapsed = 'true';
}
});
}

const observer = new MutationObserver(() => {
collapseGroups();
});

observer.observe(document.body, {
childList: true,
subtree: true
});

collapseGroups();
</script>
Did this answer your question?