Different header for specific routes
Hi everyone
Maybe it's noob question and sorry for that.
It's possible have different layouts for specific routes?
For example transparent header and a header with background in certain routes.
Thanks π
14 Replies
Given
user.tsx
would act as the layout for both the \user
(index.tsx
) and \user\:id
([id].tsx
) routes.
Nested Layouts
Escaping nested RoutesOK, so everytime I want a specific layout I need to create the
<route>.tsx
for layout and the <route>/index.tsx
for the page itself
ThanksUsing Route Groups you can even specify a top level layout for the entire app.
where
(main).tsx
is the top level layout.Thanks π
@peerreynders sorry for the noob question, what's the best way of doing an sticky header that change the colors?
I'm new on solid, sorry about that π¦
That's a CSS issue.
position: sticky;
https://youtu.be/8MaCTDkoVd8
Welcome to front end development.Kevin Powell
YouTube
You probably want position: sticky instead of fixed
Position fixed and sticky have a lot of similarities, but sticky has a few things it does a lot better and a few things that we just canβt do with fixed, so in this video, I compare the difference between the two and also look at a few fun use cases for sticky.
π Links
β
Use position sticky to tell a story with CSS: https://youtu.be/ErSwQhrfbu...
MDN Web Docs
position - CSS: Cascading Style Sheets | MDN
The position CSS property sets how an element is positioned in a document. The top, right, bottom, and left properties determine the final location of positioned elements.
I know that I can use
sticky
, but I want to change the header after the scroll
Like:
- at the beginning be transparent
- after the scroll rende the header with backgroundYou can just build something on the scroll event.
Unlike React, Solid doesn't try to lock up the Web APIs in the attic.
Or use Solid Community Primitives scroll as a starting point.
Solid Primitives
A library of high-quality primitives that extend SolidJS reactivity
Thanks, I'm trying to use a primitive for window size, but it's not being easy.
Probably a noob mistake
This is more to hide the header if it's a mobile or tablet device
Thanks again
Hi @peerreynders
Sorry to bother you
I'm trying to change the colors after the scroll, but isn't working
This is my code
and I have variants on the navigation, like this:
The problem is the colors not being updated after the scroll
Any idea what I'm doing wrong?
Probably not the problem but you will want to replace
mode
and className
with props.mode
and props.className
everywhere. Destructuring breaks reactivity.Yeah is only that
Sorry bad habbits from React