Browse Source

feat: basic scroll element with matching css

Eli Khazan 1 year ago
parent
commit
ab2caf6df2
3 changed files with 18 additions and 0 deletions
  1. 12 0
      nicegui/elements/scroll_area.py
  2. 4 0
      nicegui/static/nicegui.css
  3. 2 0
      nicegui/ui.py

+ 12 - 0
nicegui/elements/scroll_area.py

@@ -0,0 +1,12 @@
+from ..element import Element
+
+
+class ScrollArea(Element):
+
+    def __init__(self) -> None:
+        """ScrollArea
+
+        A way of customizing the scrollbars by encapsulating your content.
+        """
+        super().__init__('q-scroll-area')
+        self._classes = ['nicegui-scroll']

+ 4 - 0
nicegui/static/nicegui.css

@@ -64,6 +64,10 @@
   width: 100%;
   height: 16rem;
 }
+.nicegui-scroll {
+  width: 200px;
+  height: 200px;
+}
 .nicegui-log {
   padding: 0.25rem;
   border-width: 1px;

+ 2 - 0
nicegui/ui.py

@@ -47,6 +47,7 @@ __all__ = [
     'radio',
     'row',
     'scene',
+    'scroll_area',
     'select',
     'separator',
     'slider',
@@ -134,6 +135,7 @@ from .elements.query import query
 from .elements.radio import Radio as radio
 from .elements.row import Row as row
 from .elements.scene import Scene as scene
+from .elements.scroll_area import ScrollArea as scroll_area
 from .elements.select import Select as select
 from .elements.separator import Separator as separator
 from .elements.slider import Slider as slider