Skip to content

Commit 8b0e6d0

Browse files
committed
Make the theme-switcher sticky
1 parent 8cd9e60 commit 8b0e6d0

1 file changed

Lines changed: 25 additions & 5 deletions

File tree

demo/styles.css

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -319,10 +319,11 @@ h1 {
319319
}
320320

321321
.theme-switcher {
322-
position: absolute;
323-
top: 1.5rem;
324-
right: 1.5rem;
322+
position: relative; /* Default inside flex containers (like sidebars) */
325323
display: flex;
324+
align-items: center;
325+
height: 40px;
326+
box-sizing: border-box;
326327
background: var(--card-bg);
327328
border: 1px solid var(--card-border);
328329
border-radius: 30px;
@@ -331,6 +332,13 @@ h1 {
331332
z-index: 10;
332333
}
333334

335+
body > .theme-switcher {
336+
position: fixed; /* Fixed to viewport on main page list view */
337+
top: 2rem;
338+
right: 2rem;
339+
z-index: 20;
340+
}
341+
334342
.theme-btn {
335343
background: transparent;
336344
border: none;
@@ -382,9 +390,9 @@ html[data-theme="light"] body::after {
382390
.grid {
383391
grid-template-columns: 1fr;
384392
}
385-
.theme-switcher {
393+
body > .theme-switcher {
386394
position: static;
387-
margin: 0 auto 2rem;
395+
margin: 1.5rem auto;
388396
width: max-content;
389397
}
390398
}
@@ -514,16 +522,28 @@ html[data-theme="light"] body::after {
514522
display: flex;
515523
justify-content: space-between;
516524
align-items: center;
525+
position: sticky;
526+
top: 0;
527+
z-index: 15;
528+
margin-top: -1.5rem;
529+
margin-bottom: 1.5rem;
517530
}
518531

519532
.shell-back {
520533
display: inline-flex;
521534
align-items: center;
522535
gap: 0.5rem;
536+
background: var(--card-bg);
537+
border: 1px solid var(--card-border);
538+
border-radius: 30px;
539+
padding: 0 1rem;
540+
height: 40px;
541+
box-sizing: border-box;
523542
color: var(--text-secondary);
524543
text-decoration: none;
525544
font-weight: 600;
526545
transition: var(--transition);
546+
backdrop-filter: blur(16px);
527547
}
528548

529549
.shell-back:hover {

0 commit comments

Comments
 (0)