@layer components { /* Centered title with space for two buttons on either side */ .header { --header-gap: 0.5ch; --btn-icon-size: 1rem; --header-btn-size: 2rem; --header-button-count: 0; --header-actions-width: calc((var(--header-btn-size) + var(--header-gap)) * var(--header-button-count)); align-items: center; display: flex; padding: var(--block-space-half) var(--inline-space); /* Change the grid size depending on how many buttons are present */ &:has(.header__actions > *:nth-child(1)) { --header-button-count: 1; } &:has(.header__actions > *:nth-child(2)) { --header-button-count: 2; } &:has(.header__actions > *:nth-child(3)) { --header-button-count: 3; } } .header__actions { display: flex; font-size: var(--text-x-small); gap: var(--header-gap); inline-size: var(--header-actions-width); min-inline-size: fit-content; } .header__actions--start { margin-inline-end: auto; } .header__actions--end { margin-inline-start: auto; justify-content: flex-end; } .header__title { color: inherit; font-size: var(--text-large); font-weight: 900; margin: 0 auto; text-align: center; } }