Navigation

The TopNav component is used to create a top navigation.

Basic Collapsible Navigation

Items inside the NavContentToggle will be availble inside the collapsible menu on smaller screens. Items inside NavContent will be visible on smaller screens as well.

Expand/Collapse source code
Copied
Copy source sections
Copy source as is
SSR/CSR
Can be used both on the server and on the client side.
Imports
import live-web.dom
import live-web-view.navigation
Styles
static any[] use = [TopNav]
Content
TopNav{
    NavSections{
        NavContent{
            NavBrand{ A{ href: `#` T`Brand` } }
            NavToggleButton{}
        }
        NavContentToggle{ 
            Ul{ 
                Li{ A{ href: `#` T`Home` } }
                Li{ A{ href: `#` T`Install` } }
                Li{ A{ href: `#` T`Documentation` } }
            }
        }
    }
}

Center Column

Navigation menu with 3 sections.

Expand/Collapse source code
Copied
Copy source sections
Copy source as is
SSR/CSR
Can be used both on the server and on the client side.
Imports
import live-web.dom
import live-web-view.navigation
Styles
static any[] use = [TopNav]
Content
TopNav{ 
    NavSections{
        NavContent{
            NavBrand{ A{ href: `#` T`Brand` } }
            NavToggleButton{}
        }
        NavContentWide{
            Ul{
                Li{ A{ href: '#' T`Wide Link` }}
            }
        }
        NavContentToggle{ 
            Ul{ 
                Li{ A{ href: `#` T`Home` } }
                Li{ A{ href: `#` T`Documentation` } }
            }
        }
    }
}

Wide Content

Items inside the NavContentWide will be invisible on smaller screens.

Expand/Collapse source code
Copied
Copy source sections
Copy source as is
SSR/CSR
Can be used both on the server and on the client side.
Imports
import live-web.dom
import live-web-view.navigation
Styles
static any[] use = [TopNav]
Content
TopNav{ 
    NavSections{
        NavContent{
            NavBrand{ A{ href: `#` T`Brand` } }
            NavToggleButton{}
        }
        NavContentWide{
            Ul{
                Li{ A{ href: '#' T`Wide Link` }}
            }
        }
        NavContentToggle{ 
            Ul{ 
                Li{ A{ href: `#` T`Home` } }
                Li{ A{ href: `#` T`Documentation` } }
            }
        }
    }
}

TopNav can be created from data received on the server side.

Expand/Collapse source code
Copied
Copy source sections
Copy source as is
SSR/CSR
Can be used both on the server and on the client side.
Imports
import live-web.dom
import live-web-view.navigation
Styles
static any[] use = [TopNav]
Content
TopNav{ 
    NavSections{
        data: [
            {
                links: [
                    { type: 'brand', href: '#', label: 'Brand' },
                    { type: 'toggle' }
                ]
            },
            {
                toggle: true,
                links: [
                    { href: '#', label: 'Home' },
                    { href: '#', label: 'About' }
                ]
            },
            {
                toggle: true,
                links: [
                    { href: '#', label: 'Source' }
                ]
            }
        ]
    }
}

You can create a navigation fixed on top of the screen using the NavFixed component:

TopNav{ 
  NavFixed{
    NavSections{
        // ...
    }
  }
}    
Expand/Collapse source code
Copied
Copy source sections
Copy source as is
SSR/CSR
Can be used both on the server and on the client side.
Imports
import live-web.dom
import live-web-view.navigation
Styles
static any[] use = [TopNav]
Content
TopNav{
    NavSections{
        NavContent{
            NavBrand{ A{ href: `#` T`Brand` } }
            NavToggleButton{}
        }
        NavContentToggle{ 
            Ul{ 
                Li{ A{ href: `#` T`Home` } }
                Li{ A{ href: `#` T`Install` } }
                Li{ A{ href: `#` T`Documentation` } }
            }
        }
    }
}