Navigation#
- class BasicMenu(*args, **kwargs)[source]#
Bases:
WidgetInitKwargsMixin
Basic menu widget.
A basic menu requires only one class attribute defined,
items
:class MainMenu(BasicMenu): items = [ ('Users', 'core:home'), ('Uploads','core:uploads'), ]
- items = []#
a list of tuples that define the items to list in the menu, where the first element is the menu item text and the second element is the URL name. A third optional element in the tuple can be a dictionary of get arguments
- class BreadcrumbBlock(*args, title_class: Optional[str] = None, **kwargs)[source]#
Bases:
Block
A block that renders a Bootstrap Breadcrumb component.
Typically how you will use this is to define a base set of breadcrumbs (which typically just has your home page in it), and then add additional breadcrumbs in your views.
Example:
from django.views import View from wildewdigets import BreadcrumbItem, BreadcrumbBlock class BaseBreadCrumbs(BreadcrumbBlock): def __init__(self, *args, **kwargs): self.add_breadcrumb('Home', url='/home') class MyView(View): def get_context_data(self, **kwargs): kwargs = super().get_context_data(**kwargs) breadcrumbs = BaseBreadCrumbs() breadcrumbs.add_breadcrumb('MyView') kwargs['breadcrumbs'] = breadcrumbs return kwargs
- Keyword Arguments:
title_class – Apply this string of CSS classes to each breadcrumb title
- add_breadcrumb(title: str, url: Optional[str] = None) → None[source]#
Add a new breadcrumb item to this
BreadcrumbBlock
.Example
>>> breadcrumbs = BreadcrumbBlock() >>> breadcrumbs.add_breadcrumb('Home', url='/home')) >>> breadcrumbs.add_breadcrumb('Project')
This will produce this HTML:
<nav aria-label="breadcrumb"> <ol class="breadcrumb"> <li class="breadcrumb-item"><a href="/home">Home</a></li> <li class="breadcrumb-item active">Project</li> </ol> </nav>
- Parameters:
title – the text for the breadcrumb item
- Keyword Arguments:
url – the url for the breadcrumb item
- get_context_data(*args, **kwargs) → Dict[str, Any][source]#
Update the template context dictionary used when rendering this block.
- Keyword Arguments:
**kwargs – the current context dictionary
- Returns:
The updated context dictionary
- aria_attributes: Dict[str, str] = {'label': 'breadcrumb'}#
Additional
aria-
attributes to set on this block
- breadcrumbs#
The
<ol>
that holds our breadcrumbs
- items: List[BreadcrumbItem] = []#
The list of
BreadcrumbItem
objects from which we will build our breadcrumb HTML
- class BreadcrumbItem(title: str, url: Optional[str] = None)[source]#
Bases:
object
A dataclass that is used to register crumbs with
BreadcrumbBlock
.
- class ClickableNavDropdownControl(menu_id: str, text: Optional[str] = None, icon: Optional[Union[str, TablerMenuIcon]] = None, url: Optional[str] = None, active: bool = False, **kwargs)[source]#
Bases:
Block
This is a variation on
NavDropdownControl
for the cases when the text that controls the open and close of the relatedDropdownMenu
is also a link that should be able to be clicked separately.To implement that, this is a
<div>
with two different links in it:A first link that link that links our
text
tourl
, optionally with an icon.A second link that is just the up/down arrow for the dropdown control. Clicking this is what opens the submenu with CSS id
menu_id
.
Examples
No icon:
>>> control = ClickableNavDropdownControl( 'the-menu-id', text='My Text', url='/destination' )
With an icon:
>>> control2 = ClickableNavDropdownControl( 'the-menu-id', text='My Text', url='/destination', icon='arrow-down-square-fill' )
With a
TablerMenuIcon
:>>> arrow_icon = TablerMenuIcon(icon='arrow-down-square-fill') >>> control3 = ClickableNavDropdownControl( 'the-menu-id', text='My Text', url='/destination', icon=arrow_icon )
- Parameters:
menu_id – The CSS Id to of the dropdown menu that this controls.
- Keyword Arguments:
icon – either the name of a Bootstrap icon, or a
TablerMenuIcon
class or subclasstext – The label for the dropdown control
url – The URL for the item. For Django urls, you will typically do something like
reverse('myapp:view')
orreverse_lazy('myapp:view')
- Raises:
ValueError – no
text
was supplied
- active: bool#
If this is
True
, this control itself is active, but nothing in the relatedDropdownMenu
is
- block: str = 'nav-item--clickable'#
block is the official wildewidgets name of the block; it can’t be changed by constructor kwargs
- icon: Optional[Union[str, TablerMenuIcon]] = None#
Either the name of a Bootstrap icon, or a
TablerMenuIcon
class or subclass
- class DropdownItem(text: Optional[str] = None, icon: Optional[str] = None, active: bool = False, item: Optional[MenuItem] = None, **kwargs)[source]#
Bases:
Link
An entry in a
DropdownMenu
, a submenu class used in aNavDropdownItem
of aMenu
. This is a label with a link to a URL, with an optional icon preceding the label.Typically, you won’t use this directly, but instead it will be created for you from a
MenuItem
specification whenMenuItem.url
is notNone
.Examples
>>> icon = TablerMenuIcon(icon='target') >>> item = DropdownItem(text='Page', url='/page', icon=icon)
>>> menu_item = MenuItem(text='Page', url='/page', icon='target') >>> item = DropdownItem(item=menu_item)
- Kewyword Args:
icon: Either the name of a Bootstrap icon, or a
TablerMenuIcon
object text: The text for the item active:True
if this represents the page we’re currently on item: aMenuItem
- Raises:
ValueError – one or more of the arguments failed validation
- block: str = 'dropdown-item'#
block is the official wildewidgets name of the block; it can’t be changed by constructor kwargs
- icon: Optional[Union[str, TablerMenuIcon]] = None#
this is either the name of a bootstrap icon, or a
TablerMenuIcon
class or subclass
- class DropdownMenu(*items: MenuItem, button_id: Optional[str] = None, **kwargs)[source]#
Bases:
Block
Typically, you won’t use this directly, but instead it will be created for you from a
MenuItem
specification whenMenuItem.url
is notNone
.Examples
>>> items = [ MenuItem(text='One', url='/one', icon='1-circle'), MenuItem(text='Two', url='/two', icon='2-circle'), MenuItem(text='Three', url='/three', icon='3-circle'), ] >>> button = NavDropdownControl( text='My Dropdown Menu', icon='arrow-down-square-fill', button_id='my-button' ) >>> menu = DropdownMenu(*items, button_id=button.button_id)
- Parameters:
*items – the list of
MenuItem
objects to insert into this menu- Keyword Arguments:
button_id – it CSS id for the button
- Raises:
ValueError – one or more of the settings failed validation
- add_item(text: Optional[str] = None, url: Optional[str] = None, icon: Optional[Union[str, TablerMenuIcon]] = None, active: bool = False, item: Optional[MenuItem] = None) → None[source]#
Add a new item to this
DropdownMenu
.- Kewyword Args:
icon: Either the name of a Bootstrap icon, or a
TablerMenuIcon
object text: The text for the item url: The URL for the item active:True
if this represents the page we’re currently on item: aMenuItem
- Raises:
ValueError – one or more of the settings failed validation
- class Menu(*items: MenuItem, title: Optional[str] = None, title_tag: Optional[str] = None, title_css_classes: Optional[str] = None, **kwargs)[source]#
Bases:
Block
A
<div>
with an optional title and a Bootstrap ``ul.navbar-nav` <https://getbootstrap.com/docs/5.2/components/navbar/>`_ for use in aNavbar
.Use this in any of these ways:
Pass in the
items
kwargs to the constructorAdd items with
add_item
Subclass
Menu
, defineitems
, and add additional items withadd_item
Examples
Subclassing:
class MyMenu(Menu): items = [ MenuItem(text='One', url='/one', icon='1-circle'), MenuItem(text='Two', url='/two', icon='2-circle'), MenuItem(text='Three', url='/three', icon='3-circle'), ]
Constructor:
>>> menu = Menu( MenuItem(text='One', url='/one', icon='1-circle'), MenuItem(text='Two', url='/two', icon='2-circle'), MenuItem(text='Three', url='/three', icon='3-circle'), )
Menu.add_item
:>>> menu = Menu() >>> menu.add_item(MenuItem(text='One', url='/one', icon='1-circle')) >>> menu.add_item(MenuItem(text='Two', url='/two', icon='2-circle')) >>> menu.add_item(MenuItem(text='Three', url='/three', icon='3-circle'))
- Parameters:
*items – the list of
MenuItem
objects to insert into this menu- Keyword Arguments:
title – the title for this menu
title_tag – the HTML tag to use for the title
title_css_classes – CSS classes to apply to the title
- Raises:
ValueError – one or more of the settings failed validation
- activate(text: str) → bool[source]#
If
text
is not a URL or path, SetMenuItem.active
toTrue
for the first item we find in ouritems
(searching recursively) whoseMenuItem.text
matchestext
.If
text
is a URL or path, SetMenuItem.active
toTrue
for the first item we find in ouritems
(searching recursively) whoseMenuItem.url
matchestext
.- Parameters:
text – the text to search for among our
items
- Returns:
If we found a match, return
True
, otherwise returnFalse
.
- add_item(item: MenuItem) → None[source]#
Add a single
MenuItem
to ourselves.- Parameters:
item – the menu item to add to ourselves.
- build_menu(items: Iterable[MenuItem]) → None[source]#
Recurse through
items
and build out our menu and any submenus.For each
item
initems
, ifitem.items
is not empty, add a submenu, otherwise add simple item.- Parameters:
items – the list of menu items to add to the list
- get_content(**kwargs) → str[source]#
Actually build out the menu from our list of
MenuItems
. We do this inget_content
instead of in__init__
so that we catch any menu items added viaadd_item
after instantiation.
- class MenuHeading(text: Optional[str] = None, **kwargs)[source]#
Bases:
Block
A Tabler menu specific heading. This is a heading within a
Menu
that sepearates the actual menu items into groups.Typically, you won’t use this directly, but instead it will be created for you from a
MenuItem
specification whenMenuItem.url
isNone
andMenuItem.items
is empty.Example
>>> heading = MenuHeading(text='My Heading')
- Kewyword Args:
text: the text of the heading
- block: str = 'nav-link nav-subtitle'#
block is the official wildewidgets name of the block; it can’t be changed by constructor kwargs
- class MenuItem(text: str, icon: ~typing.Optional[~typing.Union[str, ~wildewidgets.widgets.base.Block]] = None, url: ~typing.Optional[str] = None, items: ~typing.List[~wildewidgets.widgets.navigation.MenuItem] = <factory>, active: bool = False)[source]#
Bases:
object
A menu item definition for a
Menu
.title
is required, but the other attributes are not.Note
We’re defining this dataclass so that you don’t need to build out the entire menu system with the appropriate blocks yourself, but instead can nest
MenuItem
objects and have us do it for you.If no
url
is provided, we will consider this item to be a section title in theMenu
.- set_active(text: str) → bool[source]#
If
text
looks like a URL or path, look at oururl
and setactive
toTrue
if they are equal.If
text
does not look like a URL or path, look at ourtext
and setactive
toTrue
.If we find no match, set
active
to False, and try doingset_active
on ouritems
. Stop looking when we find the first item that matchestext
.
- class NavDropdownControl(text: Optional[str] = None, icon: Optional[Union[str, TablerMenuIcon]] = None, active: bool = False, button_id: Optional[str] = None, **kwargs)[source]#
Bases:
Link
This is a dropdown control that opens a submenu from within either a
Menu
or a :py:class`DropdownMenu` within aMenu
. It consists of a label with optional icon in front, plus a arrow that toggles direction when the menu opens and closes.Examples
No icon:
>>> control = NavDropdownControl(text='My Control')
With an icon:
>>> control2 = NavDropdownControl(text='My Control', icon='arrow-down-square-fill')
With a
TablerMenuIcon
:>>> arrow_icon = TablerMenuIcon(icon='arrow-down-square-fill') >>> control3 = NavDropdownControl(text='My Control', icon=arrow_icon)
- Keyword Arguments:
icon – either the name of a Bootstrap icon, or a
TablerMenuIcon
class or subclasstext – The label for the dropdown control
button_id – The CSS Id to assign to this button. We need this to tie the button to the actual
DropdownItem
- Raises:
ValueError – no
text
was supplied
- active: bool#
This item is active, but nothing in the related
DropdownMenu
is
- aria_attributes: Dict[str, str] = {'expanded': 'false'}#
Additional
aria-
attributes to set on this block
- block: str = 'nav-link'#
block is the official wildewidgets name of the block; it can’t be changed by constructor kwargs
- button_id: Optional[str] = None#
The CSS Id to assign to this button. We need this to tie the button to the actual
TablerDropdownItem
- data_attributes: Dict[str, str] = {'auto-close': 'true', 'toggle': 'dropdown'}#
Additional
data-bs-
attributes to set on this block
- icon: Optional[Union[str, TablerMenuIcon]] = None#
Either the name of a Bootstrap icon, or a
TablerMenuIcon
class or subclass
- class NavDropdownItem(*items: MenuItem, text: Optional[str] = None, icon: Optional[str] = None, url: Optional[str] = None, active: bool = False, **kwargs)[source]#
Bases:
Block
An item in a
Menu
that opens a dropdown submenu.Typically, you won’t use this directly, but instead it will be created for you from a
MenuItem
specification whenMenuItem.items
is not empty.Examples
>>> sub_items = [ MenuItem(text='One', url='/one', icon='1-circle'), MenuItem(text='Two', url='/two', icon='2-circle'), MenuItem(text='Three', url='/three', icon='3-circle'), ] >>> item = NavDropdownItem(*sub_items, text='My Submenu', icon='target') >>> menu = Menu(item)
- Parameters:
*items – the list of
MenuItem
objects to insert into this menu- Keyword Arguments:
text – the text for the menu item
icon – this is either the name of a Bootstrap icon, or a
TablerMenuIcon
class or subclass
- Raises:
ValueError – one or more of the settings failed validation
- get_context_data(**kwargs) → Dict[str, Any][source]#
Overrides
wildewidgets.widgets.base.Block.get_context_data
.Show our menu if either
active
isTrue
or any item in ourmenu
is active. We do this here instead of in our constructor so that any menu item activation that happens after instance construction time is accounted for.
- active#
The control for opening the dropdown menu is active, but nothing in the related
DropdownMenu
is active
- block: str = 'nav-item dropdown'#
block is the official wildewidgets name of the block; it can’t be changed by constructor kwargs
- control: Union[NavDropdownControl, ClickableNavDropdownControl]#
The control that opens and closes
menu
- icon: Optional[Union[str, TablerMenuIcon]] = None#
this is either the name of a bootstrap icon, or a
TablerMenuIcon
class or subclass
- menu: DropdownMenu#
The
DropdownMenu
thatcontrol
opens
- class NavItem(text: Optional[str] = None, icon: Optional[Union[str, TablerMenuIcon]] = None, url: Optional[str] = None, active: bool = False, item: Optional[MenuItem] = None, **kwargs)[source]#
Bases:
Block
An entry in a
Menu
, the top level menu class used in aNavbar
in the menu section. This is a label with a link to a URL, with an optional icon preceding the label.Typically, you won’t use this directly, but instead it will be created for you from a
MenuItem
specification.If
url
and theurl
kwarg areNone
, this will be a heading instead of an item that links to a URL.Examples
With keyword arguments:
>>> icon = TablerMenuIcon(icon='target') >>> item = NavItem(text='Page', url='/page', icon=icon)
With a
MenuItem
:>>> menu_item = MenuItem(text='Page', url='/page', icon='target') >>> item2 = NavItem(item=menu_item)
Adding a in-menu heading:
>>> item3 = NavItem(text='My Heading')
- Kewyword Args:
icon: Either the name of a Bootstrap icon, or a
TablerMenuIcon
object text: The text for the item url: The URL for the item active:True
if this represents the page we’re currently on item: aMenuItem
- Raises:
ValueError – one or more of the settings failed validation
- block: str = 'nav-item'#
block is the official wildewidgets name of the block; it can’t be changed by constructor kwargs
- icon: Optional[Union[str, TablerMenuIcon]] = None#
Either the name of a Bootstrap icon, or a
TablerMenuIcon
object
- class NavLinkToggle(text: Optional[str] = None, icon: Optional[Union[str, TablerMenuIcon]] = None, active: bool = False, collapse_id: Optional[str] = None, **kwargs)[source]#
Bases:
Link
This is a control for a
wildewidgets.widgets.structure.CollapseWidget
that is some text with an open/closed indicator. Clicking on the text opens or closes theCollapseWidget
.This differs from
wildewidgets.widgets.buttons.CollapseButton
in that it doesn’t have button styling, and has the open/closed indicator.- Keyword Arguments:
icon – Either the name of a Bootstrap icon, or a
TablerMenuIcon
objecttext – The text for the item
active –
True
if this represents the page we’re currently oncollapse_id – the CSS id of the
wildewidgets.widgets.structure.CollapseWidget
- active: bool#
This item is active, but nothing in the related
DropdownMenu
is
- aria_attributes: Dict[str, str] = {'expanded': 'false'}#
Additional
aria-
attributes to set on this block
- block: str = 'nav-link'#
block is the official wildewidgets name of the block; it can’t be changed by constructor kwargs
- data_attributes: Dict[str, str] = {'toggle': 'collapse'}#
Additional
data-bs-
attributes to set on this block
- icon: Optional[Union[str, TablerMenuIcon]] = None#
Either the name of a Bootstrap icon, or a
TablerMenuIcon
class or subclass
- class Navbar(*blocks: Block, contents_id: Optional[str] = None, branding: Optional[Block] = None, hide_below_viewport: Optional[str] = None, container_size: Optional[str] = None, dark: Optional[bool] = None, background_color: Optional[str] = None, **kwargs)[source]#
Bases:
Block
A horizontal Bootstrap Navbar.
Examples
With a subclass:
class MyMenu(Menu): items = [MenuItem(text='One', url='/one', icon='target)] class MyNavbar(Navbar): branding = LinkedImage(src='/static/branding.png', alt='My Brand', url='#') contents = [MyMenu()]
With
Navbar
constructor arguments:>>> branding = LinkedImage(src='/static/branding.png', alt='My Brand', url='#') >>> items = [MenuItem(text='One', url='/one'), ... ] >>> menu = Menu(*items) >>> sidebar = Navbar(menu, branding=branding)
Adding menus later:
>>> items2 = [MenuItem(text='Foo', url='/foo'), ... ] >>> menu2 = Menu(*items) >>> sidebar.add_to_menu_section(menu2)
Note
You can add other things to the menu section than just menus. For instance, a search form:
class SearchFormBlock(Block): ... class MyMenu(Menu): items = [MenuItem(text='One', url='/one', icon='target)] class MyNavbar(Navbar): branding = LinkedImage(src='/static/branding.png', alt='My Brand', url='#') contents = [SearchFormBlock(), MyMenu()]
- Parameters:
*blocks – a list of
wildewidget.Block
(or subclass) instances to be added to this container- Keyword Arguments:
branding – A block that will be displayed at the top of the container. A good choice might be a
LinkedImage
orImage
logo_width – The width for the logo image. Any valid value for CSS
width
will be accepted.title – A title. If
logo
isNone
, this will be used in its place. If logo is notNone
, this will be used as the imagealt
attribute.contents_id – the CSS id of the menu container. Typically you won’t need to change this unless you have namespace collisions with other CSS ids on your page.
- activate(text: str) → bool[source]#
Loop through all the
Menu
blocks inmenu_container
and set the first menu item we find that matchestext
to be active.- Parameters:
text – the value to which to compare to menu items
- Returns:
If we actually did set an item to be active, return
True
, otherwise returnFalse
- add_blocks() → None[source]#
Overrides
wildewidgets.widgets.base.Block.add_blocks
.We’re overriding
wildewidgets.widgets.base.Block.add_blocks
here so that it does nothing because we need to add menus not to our top level tag content, but only to the menu section of ourselves, :py;attr:menu_container.menu_container
doesn’t exist yet when we run the constructor forwildewidgets.widgets.base.Block
, which is whereadd_blocks
runs.
- add_to_menu_section(block: Block) → None[source]#
Add a block to the menu specfic section of the sidebar,
menu_container
. The menu specific section will be hidden and controlled by the hamburger menu when we drop below a specific viewport.Warning
Use this to add your blocks to this
Navbar
instead of usingadd_block
.- Parameters:
block – the block to add to the menu section
- build_brand() → None[source]#
Build our
.navbar-brand
block and add it toinner
, our content container. We’re doing this in a method here so we can override it in subclasses.
- VALID_BACKGROUND_COLORS: List[str] = ['blue', 'azure', 'indigo', 'purple', 'pink', 'red', 'orange', 'yellow', 'lime', 'green', 'teal', 'cyan', 'white']#
Valid background colors. Note that these are Tabler colors, not Bootstrap colors. We use Tabler colors because Tabler also defines an appropriate foreground color for each background color.
- VALID_BREAKPOINTS: List[str] = ['sm', 'md', 'lg', 'xl', 'xxl']#
Valid values for
navbar-expand-
. From Navbar: How It Works
- background_color: Optional[str] = None#
#1d273b
- Type:
If
dark
isTrue
, set the background color. Default
- block: str = 'navbar'#
block is the official wildewidgets name of the block; it can’t be changed by constructor kwargs
- contents_id: str = 'sidebar-menu'#
the CSS id of the menu container. Typically you won’t need to change this unless you have namespace collisions with other CSS ids on your page.
- class NavbarMixin[source]#
Bases:
object
This is a Django class based view mixin that offers methods and attributes for managing how your
Navbar
classes get rendered in your template.To use
MenuMixin
, you must, in the template for your view, render themenu
andsubmenu
context parameters with thewildewidgets
template tag. These will be theNavbar
subclasses thatMenuMixin.get_context_data
adds to the template context. For example:<html> <head> {# wildewdigets css and js requirements #} </head> <body> {% wildewidgets menu %} <div class="page"> ... {% wildewidgets submenu %} ... </div> </body> </html
Example
This is the most basic example of how to use
NavbarMixin
to manage aNavbar
with aMenu
inside it and have one of the menu items be marked as active:from django.views import View from django.urls import reverse_lazy from wildewidgets import ( TablerVerticalNavbar, Menu, MenuItem, NavbarMixin ) class MainMenu(Menu): items = [ MenuItem( text='Projects', icon='bookshelf', url=reverse_lazy('myapp:project--list') ), MenuItem( text='Users', icon='users', url=reverse_lazy('myapp:users--list') ) ] class NavigationSidebar(TablerVerticalNavbar): branding = LinkedImage( image_src=static("myapp/images/logo.png"), image_width='100%', image_alt="My App", url="/" ) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.add_to_menu_section(MainMenu()) class MyView(NavbarMixin, View): navbar_class = NavigationSidebar menu_item = 'Projects' ...
This defines our navbar
NavigationSidebar
, addsMainMenu` to it, assigns it as our main menu (via ``MyView.navbar_class
), and activates the “Projects” item in the main menu (viaMyView.menu_item
).If we wanted to have a secondary navbar also, just define a new
Navbar
subclass, with asecondary_menu_item
:class SecondaryMenu(Menu): ... class ContextualNavbar(Navbar): ... class MyView(NavbarMixin, View): navbar_class = NavigationSidebar menu_item = 'Projects' secondary_navbar_class = ContextualNavbar secondary_menu_item = 'The item' ...
- get_context_data(**kwargs) → Dict[str, Any][source]#
Add our main navbar and our secondary navbar (if we have one) to the context data for our view as the
menu
andsubmenu
kwargs, respectively- Returns:
The updated context data.
- get_menu_item() → Optional[str][source]#
Return the text or URL of an item to set active among the menus in our main
Navbar
class.- Returns:
The class of the
Navbar
subclass to use for our main menu.
- get_navbar() → Navbar[source]#
Instantiate and return our
Navbar
subclass for our main navbar.- Returns:
The instantiated
Navbar
subclass instance to use for our main navbar.
- get_navbar_class() → Type[Navbar][source]#
Return the
Navbar
subclass for the main menu. Overriding this will allow you to programmatically determine your at view time.- Returns:
The class of the
Navbar
subclass to use for our main menu.
- get_secondary_menu_item() → Optional[str][source]#
Return the text of an item to set active in our secondary menu
- get_secondary_navbar() → Optional[Navbar][source]#
Instantiate and return our
Navbar
subclass for our secondary navbar.- Returns:
The instantiated
Navbar
subclass instance to use for our secondary menu, if any.
- get_secondary_navbar_class() → Optional[Type[Navbar]][source]#
Return our
Navbar
subclass for the secondary navbar.- Returns:
The class of the
Navbar
subclass to use for our secondary navbar, if any.
- menu_item: Optional[str] = None#
The text or URL of an item in one of our
navbar_class
menus to set active
- secondary_menu_item: Optional[str] = None#
The text or URL of an item in one of our
secondary_navbar_class
menus to set active
- class NavigationTogglerButton(target: Optional[str] = None, label: Optional[str] = None, **kwargs)[source]#
Bases:
Block
The
navbar-toggler
button for hiding and showing menus in responsive Bootstrap Navbar containers , styled with some Tabler styling. This is the hamburger icon that causes the menus to appear and disappear when we drop below a specific viewport size.Example:
>>> toggler = NavigationTogglerButton(target='the_target')
- Keyword Arguments:
target – the CSS id of the tag to toggle
label – the ARIA label of this button
- aria_attributes: Dict[str, str] = {'expanded': 'false'}#
Additional
aria-
attributes to set on this block
- block: str = 'navbar-toggler'#
block is the official wildewidgets name of the block; it can’t be changed by constructor kwargs
- class TablerVerticalNavbar(*args, wide: Optional[bool] = None, **kwargs)[source]#
Bases:
Navbar
Make this a Tabler vertical dark navbar.
Make the navbar vertical instead of horizontal
dark
is alwaysTrue
Fix width of sidebar at 15rem, unless
wide
isTrue
, when we set it to 18rem.CSS
position
is alwaysfixed
.Supply some open/close animations.
Some caveats:
container_size
is ignored
Example
>>> branding = LinkedImage( src='/static/branding.png', alt='My Brand', url='https://example.com', width='100%` ) >>> items = [MenuItem(text='One', url='/one'), ... ] >>> menu = TablerMenu(*items) >>> sidebar = TablerVerticalNavbar(menu, branding=branding)
- Keyword Arguments:
wide – If
True
, make the navbar width be 18rem instead of 15rem
- build_brand() → None[source]#
Overrides
Navbar.build_brand
.Wrap our branding in an
<h1>
and give that<h1>
thenavbar-brand
class because that’s how Tabler does it.