Open bahaha opened 3 hours ago
<header>
<input type="checkbox" id="header-nav" class="hidden" />
<label for="header-nav">
<!-- ... menu ... -->
</label>
</header>
header { /** styles on menu is collapsed */ }
header:has(#header-nav:checked) { /** styles on menu is expanded */ }
const [isExpand, setIsExpand] = useState(false);
use client
directive for componentChoose Approach 1: Pure css only by hidden checkbox with connected label
for
header {
height: var(--header-height);
transition: height .3s;
will-change: height; /** isolate layer to eliminate affected elements on reflow triggered by menu state changes"
}
header.expanded {
height: calc(100% - var(--v-spacing));
}
header {
position: fixed;
clip-path: inset(0 0 calc(100% - var(--collapsed-header-height)) 0 round 12px);
transition: clip-path .3s;
will-change: clip-path;
}
header::before {
content: '';
position: absolute;
inset: 0;
height: var(--collapsed-header-height);
transition: height .3s;
}
Choose Approach 2: Clip-path with pseudo element
for
Header component in the layout used in the public pages
Functional requirement
Non-functional requirement
L
for log-in