Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce ui.add_style for CSS, SASS and SCSS #2531

Merged
merged 5 commits into from
Mar 19, 2024
Merged

Introduce ui.add_style for CSS, SASS and SCSS #2531

merged 5 commits into from
Mar 19, 2024

Conversation

falkoschindler
Copy link
Contributor

@falkoschindler falkoschindler commented Feb 9, 2024

This PR introduces an add_style function for adding CSS, SASS and SCSS style definitions to the head HTML:

ui.add_style('''
    .red {
        color: red;
    }
''')
ui.label('This is red with CSS.').classes('red')

ui.add_style('''
    .green {
        background-color: lightgreen;
        .blue {
            color: blue;
        }
    }
''')
with ui.element().classes('green'):
    ui.label('This is blue on green with SCSS.').classes('blue')

ui.add_style('''
    .yellow
        background-color: yellow
        .purple
            color: purple
''', indented=True)
with ui.element().classes('yellow'):
    ui.label('This is purple on yellow with SASS.').classes('purple')

Screenshot 2024-02-09 at 20 19 36

It would be a nice feature for NiceGUI 2.0. But technically it doesn't break anything and, thus, doesn't have to wait for a major release.

Still missing:

  • tests
  • documentation

@falkoschindler falkoschindler added the enhancement New feature or request label Feb 9, 2024
@falkoschindler falkoschindler self-assigned this Feb 9, 2024
@falkoschindler falkoschindler added this to the 2.0.0 milestone Feb 9, 2024
@falkoschindler falkoschindler modified the milestones: 2.0.0, 1.4.19 Mar 13, 2024
@falkoschindler falkoschindler marked this pull request as ready for review March 17, 2024 13:12
@rodja rodja merged commit a0c49a9 into main Mar 19, 2024
7 checks passed
@rodja rodja deleted the add_style branch March 19, 2024 03:37
rodja added a commit that referenced this pull request Mar 22, 2024
rodja added a commit that referenced this pull request Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants