Browse Source

add demo about styling Markdown content (fixes #4403)

Falko Schindler 2 weeks ago
parent
commit
13ee793403
1 changed files with 17 additions and 0 deletions
  1. 17 0
      website/documentation/content/markdown_documentation.py

+ 17 - 0
website/documentation/content/markdown_documentation.py

@@ -75,4 +75,21 @@ def markdown_new_content():
     ui.button('Change Content', on_click=lambda: markdown.set_content('This is new content'))
     ui.button('Change Content', on_click=lambda: markdown.set_content('This is new content'))
 
 
 
 
+@doc.demo('Styling elements inside Markdown', '''
+    To style HTML elements inside a `ui.markdown` element, you can add custom CSS rules for the "nicegui-markdown" class.
+''')
+def markdown_styling():
+    ui.add_css('''
+        .nicegui-markdown a {
+            color: orange;
+            text-decoration: none;
+        }
+        .nicegui-markdown a:hover {
+            color: orange;
+            text-decoration: underline;
+        }
+    ''')
+    ui.markdown('This is a [link](https://example.com).')
+
+
 doc.reference(ui.markdown)
 doc.reference(ui.markdown)