2 questions on layout #1204
-
Question 1for example, an editor is created, in which the buttons lie on the top. For nice looking and ease of use, the
thanks from nicegui import ui
with ui.column():
with ui.row():
ui.label("open")
ui.icon('File Open', color='primary').classes('text-5xl')
ui.label("save")
ui.icon('save', color='primary').classes('text-5xl')
ui.separator()
input = ui.textarea(label='Text', placeholder='start typing')
ui.run(native=True) |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
question 2what if I want the label's font size, icon size scale accroding to window size; but at the same time, they should keep a minimal size if the window is shrink too small? |
Beta Was this translation helpful? Give feedback.
-
Hi @retsyo! Question 1That's a bit tricky. I ended up adjusting the main content container to fill the screen vertically. This can be done using Furthermore I added a custom CSS definition to have the q-field__control element inside the QInput fill the vertical space. Otherwise the textarea itself wouldn't grow with its container. # let the main content container fill the screen and prevent wrapping
ui.query('.nicegui-content').classes('h-screen no-wrap')
with ui.row():
ui.label("open")
ui.icon('File Open', color='primary').classes('text-5xl')
ui.label("save")
ui.icon('save', color='primary').classes('text-5xl')
ui.separator() # now the separator fills the width
# define some custom CSS to make the textarea fill the height of the QInput component
ui.add_head_html('<style>.large-textarea .q-field__control { height: 100%; } </style>')
input = ui.textarea(label='Text', placeholder='start typing').classes('w-full h-full large-textarea') Question 2You can use CSS functions like ui.label("Hello world!").style('font-size: max(12pt, 5vh)') |
Beta Was this translation helpful? Give feedback.
-
Hello By adding from nicegui import ui
with ui.column().classes('w-full'):
with ui.row():
ui.label("open")
ui.icon('File Open', color='primary').classes('text-5xl')
ui.label("save")
ui.icon('save', color='primary').classes('text-5xl')
ui.separator()
input = ui.textarea(label='Text', placeholder='start typing').classes('w-full')
ui.run(native=True) |
Beta Was this translation helpful? Give feedback.
Hi @retsyo!
Question 1
That's a bit tricky. I ended up adjusting the main content container to fill the screen vertically. This can be done using
ui.query
to select the element with class name "nicegui-content".Furthermore I added a custom CSS definition to have the q-field__control element inside the QInput fill the vertical space. Otherwise the textarea itself wouldn't grow with its container.