Stacked Nav
def create_nav_with_bookmarks(self, view): bookmarks = self.get_bookmarks() nav = Nav(view).use_layout(PillLayout(stacked=True)) return nav.with_bookmarks(bookmarks)
Nav with dropdown and embedded form
def create_nav_with_dropdown(self, view): class FormWithFormLayout(Form): def __init__(self, view, name): super().__init__(view, name) self.use_layout(FormLayout()) model_object = ModelObject() self.layout.add_input(TextInput(self, model_object.fields.text_input_field, placeholder=True), hide_label=True, help_text='This help displays inline') self.layout.add_input(PasswordInput(self, model_object.fields.password_field)) self.define_event_handler(model_object.events.do_something) btn = self.add_child(ButtonInput(self, model_object.events.do_something, style='primary')) menu = Nav(view).use_layout(PillLayout(content_justification='justified')) menu.add_bookmark(self.view.as_bookmark().with_description('This page')) sub_menu = DropdownMenu(view) for bookmark in self.get_sub_menu_bookmarks(): sub_menu.add_bookmark(bookmark) sub_menu.add_divider() sub_menu.add_header(H(view, 6, text='My header')) sub_menu.add_bookmark(self.get_divided_bookmark()) sub_menu.add_divider() sub_menu.add_form(FormWithFormLayout(view, 'form_in_menu')) menu.add_dropdown('Dropdown title', sub_menu) return menu
Navbar with brand text, nav, dropdown. Resize page to see it collapse
def create_nav_with_all_features(self, view): navbar = Navbar(view, css_id='myNavbar') navbar.use_layout(ResponsiveLayout('md', colour_theme='light', bg_scheme='light', collapse_brand_with_content=True)) navbar.layout.set_brand_text('MyBrandText') bookmarks = self.get_bookmarks() navbar_nav = Nav(view).use_layout(TabLayout(content_justification='fill')).with_bookmarks(bookmarks) navbar_nav.set_id('nav_has_id') sub_menu = DropdownMenu(view) for bookmark in self.get_sub_menu_bookmarks(): sub_menu.add_bookmark(bookmark) navbar_nav.add_dropdown('Dropdown', sub_menu) navbar.layout.add(navbar_nav) navbar_form = Form(view, 'navbarForm').use_layout(InlineFormLayout()) model_object = ModelObject() self.define_event_handler(model_object.events.do_something) navbar_form.add_child(InputGroup(None, TextInput(navbar_form, model_object.fields.text_input_field, placeholder='Search'), ButtonInput(navbar_form, model_object.events.do_something.with_label('🔍'), style='primary'))) navbar.layout.add(navbar_form) return navbar