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
cComponent for right side of navbar (Often A tag links)brandBrand/logo component for left sideright_clsSpacing for desktop linksmobile_clsSpacing for mobile linksstickyWhether to stick to the top of the page while scrollinguk_scrollspy_navWhether to use scrollspy for navigationclsClasses for navbarscrollspy_clsScrollspy class (usually ScrollspyT.*)menu_idID 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
liComponentsclsAdditional classes on theUlaltWhether 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)
liList items are navigation elements (SpecialLisuch asNavParentLi,NavDividerLi,NavHeaderLi,NavSubtitle,NavCloseLican also be used)clsAdditional classes on the navparentWhether this nav is a parent or sub navuk_navTrue for default collapsible behavior, see frankenui docs for more advanced optionsuk_scrollspy_navActivates scrollspy linking each itemAtagshrefto content'sidattributestickyWhether 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
cComponentsclsAdditional 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
cComponentsclsAdditional classes on the divkwargs
Returns: Navigation subtitle
NavHeaderLi
SourceNavHeaderLi(*c, cls=(), **kwargs) -> fastcore.xml.FT Creates a navigation list item with a header
cComponentsclsAdditional 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
cComponentsclsAdditional 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_containerNavContainercontainer for a nested nav withparent=False)clsAdditional 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
liComponentsclsAdditional classes on the navparentWhether to use a parent navuk_navTrue for default collapsible behavior, see https://franken-ui.dev/docs/nav#component-options for more advanced optionsuk_dropdownWhether to use a dropdownkwargs
Returns: DropDown nav container