Navigation (Nav, NavBar, Tabs, etc.) API Reference
Nav, NavBar, DowDownNav, and Tab examples
Nav
def ex_nav2():
mbrs1 = [Li(A('Option 1'), cls='uk-active'), Li(A('Option 2')), Li(A('Option 3'))]
mbrs2 = [Li(A('Child 1')), Li(A('Child 2')),Li(A('Child 3'))]
return NavContainer(
NavHeaderLi("NavHeaderLi"),
*mbrs1,
Li(A(href='')(Div("Subtitle Ex",NavSubtitle("NavSubtitle text to be shown")))),
NavDividerLi(),
NavParentLi(
A('Parent Name'),
NavContainer(*mbrs2,parent=False),
),
)
Navbars
Fully responsive simple navbar using the high level API. This will collapse to a hamburger menu on mobile devices. See the Scrollspy example for a more complex navbar example.
def ex_navbar1():
return NavBar(A("Page1",href='/rt1'),
A("Page2",href='/rt2'),
A("Page3",href='/rt3'),
brand=H3('My Blog'))
def ex_navbar2():
return NavBar(
A(Input(placeholder='search')),
A(UkIcon("rocket")),
A('Page1',href='/rt1'),
A("Page2", href='/rt3'),
brand=DivLAligned(Img(src='/api_reference/logo.svg'),UkIcon('rocket',height=30,width=30)))
Drop Down Navs
Tabs
A tabs can use any method of navigation (htmx, or href). However, often these are use in conjunction with switchers do to this client side
def ex_tabs1():
return Container(
TabContainer(
Li(A("Active",href='#', cls='uk-active')),
Li(A("Item",href='#')),
Li(A("Item",href='#')),
Li(A("Disabled",href='#', cls='uk-disabled')),
uk_switcher='connect: #component-nav; animation: uk-animation-fade',
alt=True),
Ul(id="component-nav", cls="uk-switcher")(
Li(H1("Tab 1")),
Li(H1("Tab 2")),
Li(H1("Tab 3"))))
API Docs
NavBar
SourceNavBar(*c, brand=h3(('Title',),{'class': 'uk-h3 '}), right_cls='items-center space-x-4', mobile_cls='space-y-4', sticky: bool = False, uk_scrollspy_nav: bool | str = False, cls='p-4', scrollspy_cls=<ScrollspyT.underline: 'navbar-underline'>, menu_id=None) -> fastcore.xml.FT
Creates a responsive navigation bar with mobile menu support
c
Component for right side of navbar (Often A tag links)brand
Brand/logo component for left sideright_cls
Spacing for desktop linksmobile_cls
Spacing for mobile linkssticky
Whether to stick to the top of the page while scrollinguk_scrollspy_nav
Whether to use scrollspy for navigationcls
Classes for navbarscrollspy_cls
Scrollspy class (usually ScrollspyT.*)menu_id
ID for menu container (used for mobile toggle)
Returns: Responsive NavBar
TabContainer
SourceTabContainer(*li, cls='', alt=False, **kwargs) -> fastcore.xml.FT
A TabContainer where children will be different tabs
li
Componentscls
Additional classes on theUl
alt
Whether to use an alternative tab stylekwargs
Returns: Tab container
NavContainer
SourceNavContainer(*li, cls=<NavT.primary: 'uk-nav-primary'>, parent=True, uk_nav=False, uk_scrollspy_nav=False, sticky=False, **kwargs) -> fastcore.xml.FT
Creates a navigation container (useful for creating a sidebar navigation). A Nav is a list (NavBar is something different)
li
List items are navigation elements (SpecialLi
such asNavParentLi
,NavDividerLi
,NavHeaderLi
,NavSubtitle
,NavCloseLi
can also be used)cls
Additional classes on the navparent
Whether this nav is a parent or sub navuk_nav
True for default collapsible behavior, see frankenui docs for more advanced optionsuk_scrollspy_nav
Activates scrollspy linking each itemA
tagshref
to content'sid
attributesticky
Whether to stick to the top of the page while scrollingkwargs
Returns: FT Component that is a list of Li
styled for a sidebar navigation menu
NavT
Option | Value | Option | Value |
---|---|---|---|
default | uk-nav-default | primary | uk-nav-primary |
secondary | uk-nav-secondary |
NavCloseLi
SourceNavCloseLi(*c, cls=(), **kwargs) -> fastcore.xml.FT
Creates a navigation list item with a close button
c
Componentscls
Additional classes on the likwargs
Returns: Navigation list item with a close button
NavSubtitle
SourceNavSubtitle(*c, cls=<TextPresets.muted_sm: 'text-gray-500 dark:text-gray-200 text-sm'>, **kwargs) -> fastcore.xml.FT
Creates a navigation subtitle
c
Componentscls
Additional classes on the divkwargs
Returns: Navigation subtitle
NavHeaderLi
SourceNavHeaderLi(*c, cls=(), **kwargs) -> fastcore.xml.FT
Creates a navigation list item with a header
c
Componentscls
Additional classes on the likwargs
Returns: Navigation list item with a header
NavDividerLi
SourceNavDividerLi(*c, cls=(), **kwargs) -> fastcore.xml.FT
Creates a navigation list item with a divider
c
Componentscls
Additional classes on the likwargs
Returns: Navigation list item with a divider
NavParentLi
SourceNavParentLi(*nav_container, cls=(), **kwargs) -> fastcore.xml.FT
Creates a navigation list item with a parent nav for nesting
nav_container
NavContainer
container for a nested nav withparent=False
)cls
Additional classes on the likwargs
Returns: Navigation list item
DropDownNavContainer
SourceDropDownNavContainer(*li, cls=<NavT.primary: 'uk-nav-primary'>, parent=True, uk_nav=False, uk_dropdown=True, **kwargs) -> fastcore.xml.FT
A Nav that is part of a DropDown
li
Componentscls
Additional classes on the navparent
Whether to use a parent navuk_nav
True for default collapsible behavior, see https://franken-ui.dev/docs/nav#component-options for more advanced optionsuk_dropdown
Whether to use a dropdownkwargs
Returns: DropDown nav container