Lists and List Items #512
Replies: 7 comments 6 replies
-
Can you, please give more information about what you mean with "listtile" and "bottom navigation"? |
Beta Was this translation helpful? Give feedback.
-
listTile Like this is similar to the list on WhatsApp and bottom nav like on instagram . to move to home , search and account actually it can be done manually. but is there anything directly like that. but if you can't . It doesn't matter . this is just a request |
Beta Was this translation helpful? Give feedback.
-
ListTileCurrently there is no dedicated NiceGUI element. But since Quasar has QList, you can use the generic with ui.element('q-list').props('bordered separator'):
with ui.element('q-item'):
with ui.element('q-item-section'):
ui.label('Hello World!')
with ui.element('q-item'):
with ui.element('q-item-section').props('avatar'):
ui.element('q-avatar').props('icon=bluetooth')
with ui.element('q-item-section'):
ui.label('Bluetooth')
with ui.element('q-item'):
with ui.element('q-item-section').props('avatar'):
ui.element('q-avatar').props('icon=wifi')
with ui.element('q-item-section'):
ui.label('WiFi') Bottom NavigationSure, you can put tabs into the page footer: with ui.footer().classes('justify-center'):
with ui.tabs() as tabs:
ui.tab('Home', icon='home')
ui.tab('About', icon='info')
with ui.tab_panels(tabs, value='Home').classes('w-full'):
with ui.tab_panel('Home'):
ui.label('This is the first tab')
with ui.tab_panel('About'):
ui.label('This is the second tab') |
Beta Was this translation helpful? Give feedback.
-
First-class support for |
Beta Was this translation helpful? Give feedback.
-
I'm trying to make my own implementation for from dataclasses import dataclass
from typing import Any, Callable, Optional
from nicegui import ui
from nicegui.client import Client
@dataclass
class ItemData:
id: str
label: str
icon: Optional[str] = None
class Item(ui.element):
def __init__(
self,
tag: str = 'q-item',
*,
_client: Client | None = None,
data: Optional[ItemData] = None,
on_click: Optional[Callable[..., Any]] = None
):
super().__init__(tag, _client=_client)
self.data = data
self.on_click = on_click
self.setup_ui()
def setup_ui(self):
with self:
if self.data.icon:
with ui.element('q-item-section').props('avatar'):
ui.element('q-avatar').props(f'icon={self.data.icon}')
with ui.element('q-item-section'):
ui.label(self.data.label)
self.on('click', lambda e: self.handle_click(e))
def handle_click(self, e):
self.props('active')
self.on_click(e)
class List(ui.element):
def __init__(
self,
tag: str = 'q-list',
*,
_client: Client | None = None,
data_list: Optional[list[ItemData]] = None,
on_click: Optional[Callable[..., Any]] = None
):
super().__init__(tag, _client=_client)
self.data_list = data_list
self.on_click = on_click
self.setup_ui()
def setup_ui(self):
with self:
for data in self.data_list:
item = Item(data=data, on_click=self.on_click)
item.props('clickable v-ripple')
data_list = [
ItemData(id='home', label='Home', icon='home'),
ItemData(id='analytics', label='Dashboard', icon='analytics'),
]
List(data_list=data_list, on_click=lambda e: ui.notify(f'Selected id: {e.sender.data.id}'))
ui.run() |
Beta Was this translation helpful? Give feedback.
-
@elcone |
Beta Was this translation helpful? Give feedback.
-
Great news: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
is there any ui component for listtile and bottom navigation other than having to make it yourself
Beta Was this translation helpful? Give feedback.
All reactions