Spaces:
Sleeping
Sleeping
File size: 45,010 Bytes
d467ea7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 |
"""Reference to all FrankenUI Components"""
from fasthtml.common import *
from monsterui.all import *
# from nbdev.showdoc import *
from utils import create_flippable_card, fn2code_string
from enum import EnumType
from collections.abc import Callable
'''
Any variable starting with docs_ is a function that generates a section of the API reference.
These are automatically added to the docs sidebar so you don't have to do anything other than add the function using create_doc_section.
'''
from inspect import signature, getdoc, getsourcefile, getsourcelines
# Utilities
def get_github_url(func):
"Create GitHub URL for function, assuming AnswerDotAI/MonsterUI repo"
file = getsourcefile(func).split('MonsterUI/')[-1]
line = getsourcelines(func)[-1]
file = file.replace('/opt/venv/lib/python3.12/site-packages/','')
return f"https://github.com/AnswerDotAI/MonsterUI/blob/main/{file}#L{line}"
def get_github_url(func):
"Create GitHub URL for function, assuming AnswerDotAI/MonsterUI repo"
try:
file = getsourcefile(func)
line = getsourcelines(func)[-1]
# Get path after monsterui/ (case insensitive)
file = file.lower()
if 'monsterui/' in file:
file = file.split('monsterui/')[-1]
elif 'site-packages/' in file:
file = file.split('site-packages/')[-1]
return f"https://github.com/AnswerDotAI/MonsterUI/blob/main/monsterui/{file}#L{line}"
except:
return None
from fastcore.docments import docments, docstring, get_name
def show_doc(func) -> str:
"Convert a Google-style docstring to markdown"
params = docments(func, args_kwargs=True)
funcname = get_name(func)
doc = docstring(func)
par, ret = None, None
if params:
par = Div(Strong('Params'),
Ul(*[Li(render_md(f"`{name}` {desc if desc else ''}",class_map_mods={'p':'leading-relaxed'}), cls='') for name, desc in params.items() if name != 'return'], cls='uk-list-disc space-y-2 mb-6 ml-6'))
if 'return' in params and params['return']: ret = render_md(f"**Returns:** {params['return']}")
return Div(
DivFullySpaced(
render_md(f"### {funcname}"),
A("Source", href=get_github_url(func), cls='text-primary hover:text-primary-focus underline')),
Pre(Code(f"{funcname}{signature(func)}",
cls='hljs language-python px-1 block overflow-x-auto'),
cls='bg-base-200 rounded-lg p-4 mb-6'),
Div(Blockquote(render_md(doc), cls='pl-4 border-l-4 border-primary mb-6'), par, ret, cls='ml-10'))
def enum_to_html_table(enum_class):
"Creates a compact multi-column table display for enum documentation"
items = list(enum_class.__members__.items())
n_cols = min(4, max(2, round((len(items) ** 0.5))))
# Create header/cell pairs with borders
def make_pair(opt, val, i):
border = 'border-l border-base-300 pl-4' if i > 0 else ''
return [Th('Option', cls=border), Th('Value')] if opt == 'header' else [Td(opt, cls=border), Td(val)]
# Build rows with padding for incomplete final row
rows = []
for i in range(0, len(items), n_cols):
cells = []
for j in range(n_cols):
name, val = items[i + j] if i + j < len(items) else ('', '')
cells.extend(make_pair(name, val.value if val else '', j))
rows.append(Tr(*cells))
return Div(
Hr(cls='uk-divider-icon my-2'),
DivFullySpaced(H3(enum_class.__name__, cls='my-2'), P(I(enum_class.__doc__), cls='text-sm')),
Table(
Thead(Tr(*make_pair('header', '', 0) * n_cols)),
Tbody(*rows),
cls=(TableT.hover, 'uk-table-small uk-table-justify uk-table-middle')))
def render_content(c):
"Renders content by type"
if isinstance(c, str): return render_md(c) # Strings are rendered as markdown
elif isinstance(c, EnumType): return enum_to_html_table(c) # Enums are rendered as tables
elif isinstance(c, FT): return c # FastHTML tags are rendered as themselves
elif isinstance(c, tuple): # Tuples are rendered as cards with source and output that can be flipped
extra_cls = c[2] if len(tuple(c)) == 3 else None
return create_flippable_card(c[0], c[1], extra_cls)
elif isinstance(c, Callable): # Callables are rendered as documentation via show_doc
return show_doc(c)
# _html = show_doc(c, renderer=BasicHtmlRenderer)._repr_html_()
# return NotStr(apply_classes(_html, class_map_mods={"table":'uk-table uk-table-hover uk-table-small'}))
else: return c
def create_doc_section(*content, title):
return lambda: Div(Container(*map(render_content, content)))
def string2code_string(code: str) -> tuple: return eval(code), code
# Sliders
def ex_sliders_1():
return Slider(*[Img(src=f'https://picsum.photos/200/200?random={i}') for i in range(10)])
def ex_sliders_2():
def _card(i): return Card(H3(f'Card {i}'), P(f'Card {i} content'))
return Slider(*[_card(i) for i in range(10)])
def ex_sliders_3():
def _card(i): return Card(H3(f'Card {i}'), P(f'Card {i} content'))
return Slider(*[_card(i) for i in range(10)], items_cls='gap-10', uk_slider='autoplay: true; autoplay-interval: 1000')
docs_sliders = create_doc_section(
H1("Carousel Sliders API Reference"),
"Here is a simple example of a slider:",
fn2code_string(ex_sliders_1),
"Here is a slider with cards:",
fn2code_string(ex_sliders_2),
"Here is a slider with cards and autoplay:",
fn2code_string(ex_sliders_3),
"Typically you want to use the `Slider` component, but if you need more control you can use the `SliderContainer`, `SliderItems`, and `SliderNav` components.",
Slider,
SliderContainer,
SliderItems,
SliderNav,
title="Sliders")
# Accordions
def ex_accordion_1():
return Div(
H2("Accordion Header"),
Accordion(
AccordionItem(
"Section 1",
P("Content for the first section."),
P("More content here."),
),
AccordionItem(
"Section 2",
P("Content for the second section."),
Label("A label inside!"),
li_kwargs={"id": "section-2"},
),
AccordionItem(
"Section 3 - The last one!", P("Content for the third section.")
),
multiple=False,
animation=True,
),
),
def ex_accordion_2():
return Div(
H2("Accordion Header"),
Accordion(
AccordionItem(
"Section 1",
P("Content for the first section."),
P("More content here."),
open=True,
),
AccordionItem(
"Section 2",
P("Content for the second section."),
Label("A label inside!"),
li_kwargs={"id": "section-2"},
),
AccordionItem(
"Section 3 - The last one!", P("Content for the third section.")
),
multiple=True,
animation=True,
),
),
def ex_accordion_3():
return Div(
H2("Accordion Header"),
Accordion(
AccordionItem(
"Section 1",
P("Content for the first section."),
P("More content here."),
),
AccordionItem(
"Section 2",
P("Content for the second section."),
Label("A label inside!"),
li_kwargs={"id": "section-2"},
),
AccordionItem(
"Section 3 - The last one!", P("Content for the third section.")
),
multiple=False,
animation=False,
),
),
docs_accordion_link = create_doc_section(
H1("Accordion API Reference"),
Div(id='accordion'), # for linking to in release post
H3("Example Accordions"),
P("A simple accordion with fluid collapsing and expanding animation where only a single Section can be exanded at any time."),
fn2code_string(ex_accordion_1),
P("An accordion with fluid collapsing and expanding animation where one section is already expanded at startup and multiple section can be expanded at any time."),
fn2code_string(ex_accordion_2),
P("An accordion with no collapsing and expanding animation where only a single Section can be exanded at any time."),
fn2code_string(ex_accordion_3),
H3("API Reference"),
Accordion,
AccordionItem,
title="Accordion")
# Buttons
def ex_buttons():
return Grid(
Button("Default"),
Button("Primary", cls=ButtonT.primary),
Button("Secondary", cls=ButtonT.secondary),
Button("Danger", cls=ButtonT.destructive),
Button("Text", cls=ButtonT.text),
Button("Link", cls=ButtonT.link),
Button("Ghost", cls=ButtonT.ghost),
)
def ex_links():
return Div(cls='space-x-4')(
A('Default Link'),
A('Muted Link', cls=AT.muted),
A('Text Link', cls=AT.text),
A('Reset Link', cls=AT.reset),
A('Primary Link', cls=AT.primary),
A('Classic Link', cls=AT.classic),)
docs_button_link = create_doc_section(
H1("Buttons & Links API Reference"),
Div(id='button'), # for linking to in release post
fn2code_string(ex_buttons),
fn2code_string(ex_links),
Button,
ButtonT,
AT,
title="Buttons & Links")
# Theme
def ex_theme_switcher():
return ThemePicker()
docs_theme_headers = create_doc_section(
H1("Theme and Headers API Reference"),
"""
To get headers with a default theme use `hdrs=Theme.<color>.headers()`. For example for the blue theme you would use `hdrs=Theme.blue.headers()`. The theme integrated together different frameworks and allows tailwind, FrankenUI, HighlighJS, and DaisyUI components to work well together.
Tailwind, FrankenUI and DaisyUI are imported by default. You must use DaisyUI headers to use anything in the `daisy` module, and FrankenUI headers to use anything in the `franken` module.
HighlightJS is not added by default, but you can add it by setting `highlightjs=True` in the headers function. The `render_md` function will use HighlightJS for code blocks.
Theme options are:""",
Card(Grid(map(P,Theme)),cls='mb-8'),
H3("Theme Picker", id='theme'),
fn2code_string(ex_theme_switcher),
ThemePicker,
H3("Custom Themes"),
render_md("""
1. You can use [this theme](https://github.com/AnswerDotAI/MonsterUI/blob/main/docs/custom_theme.css) as a starting point.
2. Add the theme to your headers as a link like this `Link(rel="stylesheet", href="/custom_theme.css", type="text/css")`
3. Then add the theme to the `ThemePicker` component. For example `ThemePicker(custom_themes=[('Grass', '#10b981')])`
"""),
"Themes are controlled with `bg-background text-foreground` classes on the `Body` tag. `fast_app` and `FastHTML` will do this for you automatically so you typically do not have to do anything",
fast_app,
FastHTML,
Blockquote(P("Users have said ", A("this site", href="https://ui.jln.dev/"), " is helpful in creating your own themes.")),
title="Headers")
# Typography
def ex_headings():
return Div(
Titled("Titled"),
H1("Level 1 Heading (H1)"),
H2("Level 2 Heading (H2)"),
H3("Level 3 Heading (H3)"),
H4("Level 4 Heading (H4)"),
H5("Level 5 Heading (H5)"),
H6("Level 6 Heading (H6)"),
)
def ex_semantic_elements():
return Div(
H2("Semantic HTML Elements Demo"),
# Text formatting examples
P("Here's an example of ", Em("emphasized (Em)"), " and ", Strong("strong (Strong)"), " text."),
P("Some ", I("italic text (I)"), " and ", Small("smaller text (Small)"), " in a paragraph."),
P("You can ", Mark("highlight (Mark)"), " text, show ", Del("deleted (Del)"), " and ",
Ins("inserted (Ins)"), " content."),
P("Chemical formulas use ", Sub("subscripts (Sub)"), " and ", Sup("superscripts (Sup)"),
" like H", Sub("2"), "O."),
# Quote examples
Blockquote(
P("The only way to do great work is to love what you do."),
Cite("Steve Jobs (Cite)")),
P("As Shakespeare wrote, ", Q("All the world's a stage (Q)"), "."),
# Time and Address
P("Posted on ", Time("2024-01-29", datetime="2024-01-29")),
Address(
"Mozilla Foundation (Address)",
Br(),
"331 E Evelyn Ave (Address)",
Br(),
"Mountain View, CA 94041 (Address)",
Br(),
"USA (Address)"),
# Technical and definition examples
P(
Dfn("HTML (Dfn)"), " (",
Abbr("HyperText Markup Language (Abbr)", title="HyperText Markup Language"),
") is the standard markup language for documents designed to be displayed in a web browser."),
P("Press ", Kbd("Ctrl (Kbd)"), " + ", Kbd("C (Kbd)"), " to copy."),
P("The command returned: ", Samp("Hello, World! (Samp)")),
P("Let ", Var("x (Var)"), " be the variable in the equation."),
# Figure with caption
Figure(
PicSumImg(),
Caption("Figure 1: An example image with caption (Caption)")),
# Interactive elements
Details(
Summary("Click to show more information (Summary)"),
P("This is the detailed content that is initially hidden (P)")),
# Data representation
P(
Data("123 (Data)", value="123"), " is a number, and here's a Meter showing progress: ",
Meter(value=0.6, min=0, max=1)),
P(
"Temperature: ",
Meter(value=-1, min=-10, max=40, low=0, high=30, optimum=21),
" (with low/high/optimum values)"),
P(
Data("β¬42.00", value="42"),
" - price example with semantic value"),
# Output example
P("Form calculation result: ", Output("The sum is 42 (Output)", form="calc-form", for_="num1 num2")),
# Meta information example
Section(
H3("Blog Post Title (H3)"),
Small("By John Doe β’ 5 min read (Small)"),
P("Article content here...")),
# Text decoration examples
P("This text has ",U("proper name annotation (U)"), " and this is ",S("outdated information (S)"), " that's been superseded."),
cls='space-y-4'
)
def ex_textpresets():
return Grid(*[Div(P(f"This is {preset.name} text", cls=preset.value)) for preset in TextPresets])
def ex_textt():
return Grid(*[Div(P(f"This is {s.name} text", cls=s.value)) for s in TextT])
def ex_other():
return Div(
CodeSpan("This is a CodeSpan element"),
Blockquote("This is a blockquote element"),
CodeBlock("#This is a CodeBlock element\n\ndef add(a,b): return a+b"))
docs_typography = create_doc_section(
H1("Typography API Reference"),
P("Ready to go semantic options that cover most of what you need based on the HTML spec"),
fn2code_string(ex_headings),
fn2code_string(ex_semantic_elements),
fn2code_string(ex_other),
P("Styling text is possibly the most common style thing to do, so we have a couple of helpers for discoverability inside python. `TextPresets` is intended to be combinations are are widely applicable and used often, where `TextT` is intended to be more flexible options for you to combine together yourself."),
H5("TextPresets.*"),
fn2code_string(ex_textpresets),
H5("TextT.*"),
fn2code_string(ex_textt),
H3("API Reference"),
TextPresets,
TextT,
H1, H2, H3, H4, H5, H6,
CodeSpan, Blockquote, CodeBlock,
Em, Strong, I, Small, Mark, Sub, Sup, Del, Ins,
Dfn, Abbr, Q, Kbd, Samp, Var,
Figure, Caption,
Details, Summary,
Meter, Data, Output,
Address, Time,
title="Text Style")
# Notifications
def ex_alerts1(): return Alert("This is a plain alert")
def ex_alerts2(): return Alert("Your purchase has been confirmed!", cls=AlertT.success)
def ex_alerts3():
return Alert(
DivLAligned(UkIcon('triangle-alert'),
P("Please enter a valid email.")),
cls=AlertT.error)
def ex_toasts1():
return Toast("First Example Toast", cls=(ToastHT.start, ToastVT.bottom), dur=300)
def ex_toasts2():
return Toast("Second Example Toast", alert_cls=AlertT.info, dur=300)
docs_notifications = create_doc_section(
H1("Alerts & Toasts API Reference"),
H3("Alerts"),
P("The simplest alert is a div wrapped with a span:"),
fn2code_string(ex_alerts1),
P("Alert colors are defined by the alert styles:"),
fn2code_string(ex_alerts2),
P("It often looks nice to use icons in alerts: "),
fn2code_string(ex_alerts3),
Alert, AlertT,
DividerLine(),
H3("Toasts"),
P("To define a toast with a particular location, add horizontal or vertical toast type classes:"),
fn2code_string(ex_toasts1),
P("To define toast colors, set the class of the alert wrapped by the toast:"),
fn2code_string(ex_toasts2),
P("Toasts will disappear automatically after 5 seconds. To change the duration of the toast set the `dur` param like this `Toast('Content', dur=10)`."),
P("Here's a demo ", A("app", href="https://gallery.fastht.ml/split/dynamic_user_interface_(htmx)/toast", target="_blank", rel="noopener noreferrer", cls='underline'), " showing how to trigger a toast.", cls='mt-4'),
Toast, ToastHT, ToastVT,
title="Alerts & Toasts")
# Containers
def ex_articles():
return Article(
ArticleTitle("Sample Article Title"),
Subtitle("By: John Doe"),
P('lorem ipsum dolor sit amet consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'))
def ex_containers():
return Container(
"This is a sample container with custom styling.",
cls=ContainerT.xs,
style="background-color: #FFA500; color: #000000")
docs_containers = create_doc_section(
H1("Articles, Containers & Sections API Reference"),
ArticleMeta,
ArticleTitle,
Article,
fn2code_string(ex_articles),
Container,
ContainerT,
fn2code_string(ex_containers),
Section,
SectionT,
title="Articles, Containers & Sections"
)
# Cards
def ex_card():
return Card(
Form(LabelInput("Input"),
LabelRange("Range")),
header=Div(
CardTitle("Header"),
P("A card with header and footer",cls=TextPresets.muted_sm)),
footer=DivLAligned(Button("Footer Submit Button")))
def Tags(cats): return Div(cls='space-x-2')(map(Label, cats))
def ex_card2_wide():
def Tags(cats): return DivLAligned(map(Label, cats))
return Card(
DivLAligned(
A(Img(src="https://picsum.photos/200/200?random=12", style="width:200px"),href="#"),
Div(cls='space-y-3 uk-width-expand')(
H4("Creating Custom FastHTML Tags for Markdown Rendering"),
P("A step by step tutorial to rendering markdown in FastHTML using zero-md inside of DaisyUI chat bubbles"),
DivFullySpaced(map(Small, ["Isaac Flath", "20-October-2024"]), cls=TextT.muted),
DivFullySpaced(
Tags(["FastHTML", "HTMX", "Web Apps"]),
Button("Read", cls=(ButtonT.primary,'h-6'))))),
cls=CardT.hover)
def ex_card2_tall():
def Tags(cats): return DivLAligned(map(Label, cats))
return Card(
Div(
A(Img(src="https://picsum.photos/400/200?random=14"), href="#"),
Div(cls='space-y-3 uk-width-expand')(
H4("Creating Custom FastHTML Tags for Markdown Rendering"),
P("A step by step tutorial to rendering markdown in FastHTML using zero-md inside of DaisyUI chat bubbles"),
DivFullySpaced(map(Small, ["Isaac Flath", "20-October-2024"]), cls=TextT.muted),
DivFullySpaced(
Tags(["FastHTML", "HTMX", "Web Apps"]),
Button("Read", cls=(ButtonT.primary,'h-6'))))),
cls=CardT.hover)
def ex_card3():
def team_member(name, role, location="Remote"):
return Card(
DivLAligned(
DiceBearAvatar(name, h=24, w=24),
Div(H3(name), P(role))),
footer=DivFullySpaced(
DivHStacked(UkIcon("map-pin", height=16), P(location)),
DivHStacked(*(UkIconLink(icon, height=16) for icon in ("mail", "linkedin", "github")))))
team = [
team_member("Sarah Chen", "Engineering Lead", "San Francisco"),
team_member("James Wilson", "Senior Developer", "New York"),
team_member("Maria Garcia", "UX Designer", "London"),
team_member("Alex Kumar", "Product Manager", "Singapore"),
team_member("Emma Brown", "DevOps Engineer", "Toronto"),
team_member("Marcus Johnson", "Frontend Developer", "Berlin")
]
return Grid(*team, cols_sm=1, cols_md=1, cols_lg=2, cols_xl=3)
docs_cards = create_doc_section(
H1("Cards API Reference"),
H3("Example Usage"),
fn2code_string(ex_card),
(*fn2code_string(ex_card2_wide),'sm:block'),
(*fn2code_string(ex_card2_tall),'sm:hidden'),
fn2code_string(ex_card3),
H3("API Reference"),
Card,
CardTitle,
CardT,
P("The remainder of these are only needed if you're doing something really special. They are used in the `Card` function to generate the boilerplate for you.", cls='my-6'),
CardContainer,
CardHeader,
CardBody,
CardFooter,
title="Cards"
)
# Lists
def ex_lists():
list_options = [(style,str(cls)) for style,cls in ListT.__members__.items()]
lists = [Div(H4(f"{style} List:"), Ul(Li("Item 1"), Li("Item 2"), cls=cls)) for style, cls in list_options]
return Grid(*lists)
docs_lists = create_doc_section(
H1("Lists API Reference"),
fn2code_string(ex_lists),
ListT,
title="Lists")
# Forms
def ex_formlabel():
return FormLabel("Form Label")
def ex_input():
return Div(
Input(placeholder="Enter text"),
LabelInput(label="Input", id='myid'))
def ex_checkbox():
return Div(
CheckboxX(),
LabelCheckboxX(label="Checkbox", id='checkbox1'))
def ex_range():
return Div(
Range(),
Range(label='kg', value="25,75", min=20, max=75),
LabelRange('Basic Range', value='50', min=0, max=100, step=1),
LabelRange('Range with Label', value='75', min=0, max=100, step=5, label_range=True),
LabelRange('Multiple Values', value='25,75', min=0, max=100, step=5, label_range=True),
LabelRange('Custom Range', value='500', min=0, max=1000, step=100, label_range=True)
)
def ex_switch():
return Div(
Switch(id="switch"),
LabelSwitch(label="Switch", id='switch'))
def ex_textarea():
return Div(
TextArea(placeholder="Enter multiple lines of text"),
LabelTextArea(label="TextArea", id='myid'))
def ex_radio():
return Div(
Radio(name="radio-group", id="radio1"),
LabelRadio(label="Radio", id='radio1',cls='flex items-center space-x-4'))
def ex_insertable_select1():
fruit_opts = ['apple', 'orange', 'banana', 'mango']
return Grid(
Select(Option('Apple', value='apple'),
Option('Orange', value='orange'),
Option('Banana', value='banana'),
Option('Mango', value='mango'),
id="fruit", icon=True, insertable=True, placeholder="Choose a fruit..."),
Select(Optgroup(label="Fruit")(
*map(lambda l: Option(l.capitalize(), value=l), sorted(fruit_opts))),
id="fruit", icon=True, insertable=True, placeholder="Choose a fruit...",
cls_custom="button: uk-input-fake justify-between w-full; dropdown: w-full"))
def ex_select():
return Div(
Select(map(Option, ["Option 1", "Option 2", "Option 3"])),
LabelSelect(map(Option, ["Option 1", "Option 2", "Option 3"]), label="Select", id='myid'))
def ex_progress():
return Progress(value=20, max=100)
def ex_form():
relationship = ["Parent",'Sibling', "Friend", "Spouse", "Significant Other", "Relative", "Child", "Other"]
return Div(cls='space-y-4')(
DivCentered(
H3("Emergency Contact Form"),
P("Please fill out the form completely", cls=TextPresets.muted_sm)),
Form(cls='space-y-4')(
Grid(LabelInput("First Name",id='fn'), LabelInput("Last Name",id='ln')),
Grid(LabelInput("Email", id='em'), LabelInput("Phone", id='ph')),
H3("Relationship to patient"),
Grid(*[LabelCheckboxX(o) for o in relationship], cols=4, cls='space-y-3'),
LabelInput("Address", id='ad'),
LabelInput("Address Line 2", id='ad2'),
Grid(LabelInput("City", id='ct'), LabelInput("State", id='st')),
LabelInput("Zip", id='zp'),
DivCentered(Button("Submit Form", cls=ButtonT.primary))))
def ex_upload():
return Div(Upload("Upload Button!", id='upload1'),
UploadZone(DivCentered(Span("Upload Zone"), UkIcon("upload")), id='upload2'),
cls='space-y-4')
docs_forms = create_doc_section(
H1("Forms and User Inputs API Reference"),
H3("Example Form"),
P(f"This form was live coded in a 5 minute video ",
A("here",href="https://www.loom.com/share/0916e8a95d524c43a4d100ee85157624?start_and_pause=1",
cls=AT.muted), cls=TextPresets.muted_sm),
fn2code_string(ex_form),
fn2code_string(ex_upload),
FormLabel,
fn2code_string(ex_formlabel),
Input,
fn2code_string(ex_input),
LabelInput,
LabelCheckboxX,
LabelSwitch,
LabelRange,
LabelTextArea,
LabelRadio,
LabelSelect,
Progress,
fn2code_string(ex_progress),
Radio,
fn2code_string(ex_radio),
CheckboxX,
fn2code_string(ex_checkbox),
Range,
fn2code_string(ex_range),
Switch,
fn2code_string(ex_switch),
TextArea,
fn2code_string(ex_textarea),
Select,
fn2code_string(ex_select),
H3("Example: Insertable Select"),
Caption("In a production app, the user-inserted option would be saved server-side (db, session etc.)"),
fn2code_string(ex_insertable_select1),
Legend,
Fieldset,
title="Forms")
# Lightbox
def ex_lightbox1():
return LightboxContainer(
LightboxItem(Button("Open"), href='https://picsum.photos/id/100/1280/720.webp', data_alt='A placeholder image to demonstrate the lightbox', data_caption='This is my super cool caption'),
)
def ex_lightbox2():
return LightboxContainer(
LightboxItem(Button("Open"), href='https://picsum.photos/id/100/1280/720.webp', data_alt='A placeholder image to demonstrate the lightbox', data_caption='Image 1'),
LightboxItem(href='https://picsum.photos/id/101/1280/720.webp', data_alt='A placeholder image to demonstrate the lightbox', data_caption='Image 2'),
LightboxItem(href='https://picsum.photos/id/102/1280/720.webp', data_alt='A placeholder image to demonstrate the lightbox', data_caption='Image 3'),
)
def ex_lightbox3():
return LightboxContainer(
LightboxItem(Button("mp4"), href='https://yootheme.com/site/images/media/yootheme-pro.mp4'),
LightboxItem(Button("Youtube"), href='https://www.youtube.com/watch?v=c2pz2mlSfXA'),
LightboxItem(Button("Vimeo"), href='https://vimeo.com/1084537'),
LightboxItem(Button("Iframe"), data_type='iframe', href='https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d4740.819266853735!2d9.99008871708242!3d53.550454675412404!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x0%3A0x3f9d24afe84a0263!2sRathaus!5e0!3m2!1sde!2sde!4v1499675200938'))
docs_lightbox = create_doc_section(
H1("Lightbox API Reference"),
fn2code_string(ex_lightbox1),
fn2code_string(ex_lightbox2),
fn2code_string(ex_lightbox3),
LightboxContainer,
LightboxItem,
title="Lightbox")
# Modals
def ex_modal():
return Div(
Button("Open Modal",data_uk_toggle="target: #my-modal" ),
Modal(ModalTitle("Simple Test Modal"),
P("With some somewhat brief content to show that it works!", cls=TextPresets.muted_sm),
footer=ModalCloseButton("Close", cls=ButtonT.primary),id='my-modal'))
docs_modals = create_doc_section(
H1("Modals API Reference"),
H3("Example Modal"),
fn2code_string(ex_modal),
Modal,
P("If you want to trigger a htmx event on close (like calling a route) you can use `hx_trigger='hidden'` to catch the close event."),
ModalCloseButton,
P("The remainder of the Modal functions below are used internally by the `Modal` function for you. You shouldn't need to use them unless you're doing something really special."),
ModalTitle,
ModalFooter,
ModalBody,
ModalHeader,
ModalDialog,
ModalContainer,
title="Modals")
# Layout
def ex_grid():
return Grid(
Div(
P("Column 1 Item 1"),
P("Column 1 Item 2"),
P("Column 1 Item 3")),
Div(
P("Column 2 Item 1"),
P("Column 2 Item 2"),
P("Column 2 Item 3")),
Div(
P("Column 3 Item 1"),
P("Column 3 Item 2"),
P("Column 3 Item 3")))
def ex_product_grid():
products = [
{"name": "Laptop", "price": "$999", "img": "https://picsum.photos/200/100?random=1"},
{"name": "Smartphone", "price": "$599", "img": "https://picsum.photos/200/100?random=2"},
{"name": "Headphones", "price": "$199", "img": "https://picsum.photos/200/100?random=3"},
{"name": "Smartwatch", "price": "$299", "img": "https://picsum.photos/200/100?random=4"},
{"name": "Tablet", "price": "$449", "img": "https://picsum.photos/200/100?random=5"},
{"name": "Camera", "price": "$799", "img": "https://picsum.photos/200/100?random=6"},
]
product_cards = [
Card(
Img(src=p["img"], alt=p["name"], style="width:100%; height:100px; object-fit:cover;"),
H4(p["name"], cls="mt-2"),
P(p["price"], cls=TextPresets.bold_sm),
Button("Add to Cart", cls=(ButtonT.primary, "mt-2"))
) for p in products
]
return Grid(*product_cards, cols_lg=3)
def ex_fully_spaced_div():
return DivFullySpaced(
Button("Left", cls=ButtonT.primary),
Button("Center", cls=ButtonT.secondary),
Button("Right", cls=ButtonT.destructive)
)
def ex_centered_div():
return DivCentered(
H3("Centered Title"),
P("This content is centered both horizontally and vertically.")
)
def ex_l_aligned_div():
return DivLAligned(
Img(src="https://picsum.photos/100/100?random=1", style="max-width: 100px;"),
H4("Left Aligned Title"),
P("Some text that's left-aligned with the title and image.")
)
def ex_r_aligned_div():
return DivRAligned(
Button("Action", cls=ButtonT.primary),
P("Right-aligned text"),
Img(src="https://picsum.photos/100/100?random=3", style="max-width: 100px;")
)
def ex_v_stacked_div():
return DivVStacked(
H2("Vertical Stack"),
P("First paragraph in the stack"),
P("Second paragraph in the stack"),
Button("Action Button", cls=ButtonT.secondary)
)
def ex_h_stacked_div():
return DivHStacked(
Div(H4("Column 1"), P("Content for column 1")),
Div(H4("Column 2"), P("Content for column 2")),
Div(H4("Column 3"), P("Content for column 3"))
)
docs_layout = create_doc_section(
H1("Layout (Flex and Grid) API Reference"),
P("This page covers `Grid`s, which are often used for general structure, `Flex` which is often used for layout of components that are not grid based, padding and positioning that can help you make your layout look good, and dividers that can help break up the page", cls=TextPresets.muted_sm),
H2("Grid"),
fn2code_string(ex_grid),
Grid,
H4("Practical Grid Example"),
fn2code_string(ex_product_grid),
H2("Flex"),
P("Play ",
A("Flex Box Froggy", href="https://flexboxfroggy.com/", cls=AT.muted),
" to get an understanding of flex box.",
cls=TextPresets.muted_sm),
DivFullySpaced,
fn2code_string(ex_fully_spaced_div),
DivCentered,
fn2code_string(ex_centered_div),
DivLAligned,
fn2code_string(ex_l_aligned_div),
DivRAligned,
fn2code_string(ex_r_aligned_div),
DivVStacked,
fn2code_string(ex_v_stacked_div),
DivHStacked,
fn2code_string(ex_h_stacked_div),
FlexT,
title="Layout")
# Dividers
def ex_dividers():
return Div(
P("Small Divider"),
Divider(cls=DividerT.sm),
DivCentered(
P("Vertical Divider"),
Divider(cls=DividerT.vertical)),
DivCentered("Icon Divider"),
Divider(cls=DividerT.icon))
def ex_dividersplit():
return DividerSplit(P("Or continue with", cls=TextPresets.muted_sm))
def ex_dividerline():
return DividerLine()
docs_dividers = create_doc_section(
H1("Dividers API Reference"),
Divider,
DividerT,
fn2code_string(ex_dividers),
DividerSplit,
fn2code_string(ex_dividersplit),
DividerLine,
fn2code_string(ex_dividerline),
title="Dividers")
# Navigation
def ex_nav1():
mbrs1 = [Li(A('Option 1'), cls='uk-active'), Li(A('Option 2')), Li(A('Option 3'))]
return NavContainer(*mbrs1)
def ex_nav2():
mbrs1 = [Li(A('Option 1'), cls='uk-active'), Li(A('Option 2')), Li(A('Option 3'))]
mbrs2 = [Li(A('Child 1')), Li(A('Child 2')),Li(A('Child 3'))]
return NavContainer(
NavHeaderLi("NavHeaderLi"),
*mbrs1,
Li(A(href='')(Div("Subtitle Ex",NavSubtitle("NavSubtitle text to be shown")))),
NavDividerLi(),
NavParentLi(
A('Parent Name'),
NavContainer(*mbrs2,parent=False),
),
)
def ex_navbar1():
return NavBar(A("Page1",href='/rt1'),
A("Page2",href='/rt2'),
A("Page3",href='/rt3'),
brand=H3('My Blog'))
def ex_navbar2():
return NavBar(
A(Input(placeholder='search')),
A(UkIcon("rocket")),
A('Page1',href='/rt1'),
A("Page2", href='/rt3'),
brand=DivLAligned(Img(src='/api_reference/logo.svg'),UkIcon('rocket',height=30,width=30)))
def ex_navdrop():
return Div(
Button("Open DropDown"),
DropDownNavContainer(Li(A("Item 1",href=''),Li(A("Item 2",href='')))))
def ex_tabs1():
return Container(
TabContainer(
Li(A("Active",href='#', cls='uk-active')),
Li(A("Item",href='#')),
Li(A("Item",href='#')),
Li(A("Disabled",href='#', cls='uk-disabled')),
uk_switcher='connect: #component-nav; animation: uk-animation-fade',
alt=True),
Ul(id="component-nav", cls="uk-switcher")(
Li(H1("Tab 1")),
Li(H1("Tab 2")),
Li(H1("Tab 3"))))
def ex_tabs2():
return Container(
TabContainer(
Li(A("Active",href='javascript:void(0);', cls='uk-active')),
Li(A("Item",href='javascript:void(0);')),
Li(A("Item",href='javascript:void(0);')),
Li(A("Disabled", cls='uk-disabled'))))
docs_navigation = create_doc_section(
H1("Navigation (Nav, NavBar, Tabs, etc.) API Reference"),
H1("Nav, NavBar, DowDownNav, and Tab examples"),
Divider(),
H2("Nav"),
fn2code_string(ex_nav1),
fn2code_string(ex_nav2),
H2("Navbars", id='navbars'),
"Fully responsive simple navbar using the high level API. This will collapse to a hamburger menu on mobile devices. See the Scrollspy example for a more complex navbar example.",
fn2code_string(ex_navbar1),
fn2code_string(ex_navbar2),
H2("Drop Down Navs"),
fn2code_string(ex_navdrop),
H2("Tabs"),
fn2code_string(ex_tabs2),
P("A tabs can use any method of navigation (htmx, or href). However, often these are use in conjunction with switchers do to this client side", cls=TextPresets.muted_sm),
fn2code_string(ex_tabs1),
H1("API Docs"),
NavBar,
TabContainer,
NavContainer,
NavT,
NavCloseLi,
NavSubtitle,
NavHeaderLi,
NavDividerLi,
NavParentLi,
DropDownNavContainer,
title="Navigation")
# Steps
def ex_steps2():
return Steps(
LiStep("Account Created", cls=StepT.primary),
LiStep("Profile Setup", cls=StepT.neutral),
LiStep("Verification", cls=StepT.neutral),
cls="w-full")
def ex_steps3():
return Steps(
LiStep("Project Planning", cls=StepT.success, data_content="π"),
LiStep("Design Phase", cls=StepT.success, data_content="π‘"),
LiStep("Development", cls=StepT.primary, data_content="π οΈ"),
LiStep("Testing", cls=StepT.neutral, data_content="π"),
LiStep("Deployment", cls=StepT.neutral, data_content="π"),
cls=(StepsT.vertical, "min-h-[400px]"))
docs_steps = create_doc_section(
H1("Steps API Reference"),
fn2code_string(ex_steps2),
fn2code_string(ex_steps3),
H1("API Docs"),
Steps,
StepsT,
LiStep,
StepT,
title="Steps")
# Tables
def ex_tables0():
return Table(
Thead(Tr(Th('Name'), Th('Age'), Th('City'))),
Tbody(Tr(Td('Alice'), Td('25'), Td('New York')),
Tr(Td('Bob'), Td('30'), Td('San Francisco')),
Tr(Td('Charlie'), Td('35'), Td('London'))),
Tfoot(Tr(Td('Total'), Td('90'))))
def ex_tables1():
header = ['Name', 'Age', 'City']
body = [['Alice', '25', 'New York'],
['Bob', '30', 'San Francisco'],
['Charlie', '35', 'London']]
footer = ['Total', '90']
return TableFromLists(header, body, footer)
def ex_tables2():
def body_render(k, v):
match k.lower():
case 'name': return Td(v, cls='font-bold')
case 'age': return Td(f"{v} years")
case _: return Td(v)
header_data = ['Name', 'Age', 'City']
body_data =[{'Name': 'Alice', 'Age': 30, 'City': 'New York'},
{'Name': 'Bob', 'Age': 25, 'City': 'London'}]
return TableFromDicts(header_data, body_data,
header_cell_render=lambda v: Th(v.upper()),
body_cell_render=body_render)
docs_tables = create_doc_section(
H1("Tables API Reference"),
fn2code_string(ex_tables0),
fn2code_string(ex_tables1),
fn2code_string(ex_tables2),
Table,
TableFromLists,
TableFromDicts,
TableT,
Tbody,
Th,
Td,
title="Tables")
# Icons
def ex_dicebear():
return DivLAligned(
DiceBearAvatar('Isaac Flath',10,10),
DiceBearAvatar('Aaliyah',10,10),
DiceBearAvatar('Alyssa',10,10))
def ex_picsum():
return Grid(PicSumImg(100,100), PicSumImg(100,100, blur=6),PicSumImg(100,100, grayscale=True))
def ex_icon():
return Grid(
UkIcon('chevrons-right', height=15, width=15),
UkIcon('bug', height=15, width=15),
UkIcon('phone-call', height=15, width=15),
UkIcon('maximize-2', height=15, width=15),
UkIcon('thumbs-up', height=15, width=15),)
def ex_iconlink():
return DivLAligned(
UkIconLink('chevrons-right'),
UkIconLink('chevrons-right', button=True, cls=ButtonT.primary))
docs_icons_images = create_doc_section(
H1("Icons & Images API Reference"),
H1("Avatars"),
fn2code_string(ex_dicebear),
DiceBearAvatar,
H1("PlaceHolder Images"),
fn2code_string(ex_picsum),
PicSumImg,
H1("Icons"),
P("Icons use Lucide icons - you can find a full list of icons in their docs.", cls=TextPresets.muted_sm),
fn2code_string(ex_icon),
UkIcon,
fn2code_string(ex_iconlink),
UkIconLink,
title="Icons")
# Markdown
def ex_markdown():
md = '''# Example Markdown
+ With **bold** and *italics*
+ With a [link](https://github.com)
### And a subheading
> This is a blockquote
This supports inline latex: $e^{\\pi i} + 1 = 0$ as well as block latex thanks to Katex.
$$
\\frac{1}{2\\pi i} \\oint_C \\frac{f(z)}{z-z_0} dz
$$
And even syntax highlighting thanks to Highlight.js! (Just make sure you set `highlightjs=True` in the headers function)
```python
def add(a, b):
return a + b
```
'''
return render_md(md)
def ex_markdown2():
md = '''With custom **bold** style\n\n > But no extra quote style because class_map overrides all default styled'''
return render_md(md, class_map={'b': 'text-red-500'})
def ex_markdown3():
md = '''With custom **bold** style\n\n > But default quote style because class_map_mods replaces sepecified styles and leaves the rest as default'''
return render_md(md, class_map_mods={'b': 'text-red-500'})
def ex_applyclasses():
return apply_classes('<h1>Hello, World!</h1><p>This is a paragraph</p>')
def ex_applyclasses2():
from mistletoe import markdown, HTMLRenderer
md = markdown('# Hi\n[a link](www.google.com)', renderer=HTMLRenderer)
return Safe(apply_classes(md))
docs_markdown = create_doc_section(
H1("Markdown + automated HTML styling API Reference"),
fn2code_string(ex_markdown),
render_md("You can overwrite the default styling for markdown rendering with your own css classes with `class_map"),
fn2code_string(ex_markdown2),
render_md("You can modify the default styling for markdown rendering with your own css classes with `class_map_mods"),
fn2code_string(ex_markdown3),
render_md("This uses the `apply_classes` function, which can be used to apply classes to html strings. This is useful for applying styles to any html you get from an external source."),
fn2code_string(ex_applyclasses),
render_md("One common external source is a markdown renderer. MonsterUI uses tailwind css for styling so you don't get any styling without specifying classes, `apply_classes` can do that for you."),
fn2code_string(ex_applyclasses2),
apply_classes,
title="Markdown + HTML Frankification")
docs_html = create_doc_section(
H1("HTML Styling API Reference"),
fn2code_string(ex_applyclasses),
title="HTML Styling")
def ex_loading1():
return Loading()
def ex_loading2():
types = [LoadingT.spinner, LoadingT.dots, LoadingT.ring, LoadingT.ball, LoadingT.bars, LoadingT.infinity]
sizes = [LoadingT.xs, LoadingT.sm, LoadingT.md, LoadingT.lg]
rows = [Div(*[Loading((t,s)) for s in sizes], cls='flex gap-4') for t in types]
return Div(*rows, cls='flex flex-col gap-4')
docs_loading = create_doc_section(
H1("Loading Indicators API Reference"),
fn2code_string(ex_loading1),
fn2code_string(ex_loading2),
Loading,
LoadingT,
title="Loading")
# Charts
def ex_line_chart():
return ApexChart(
opts={
"chart": {"type":"line", "zoom":{"enabled": False}, "toolbar":{"show":False}},
"series": [{"name":"Desktops", "data": [186, 305, 237, 73, 209, 214, 355]}],
"xaxis": {"categories":["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul"]}
},
cls='max-w-md max-h-md'
)
def ex_pie_chart():
return ApexChart(
opts={
"chart": {"type":"pie", "zoom":{"enabled": False}, "toolbar":{"show":False}},
"series": [186, 305, 237, 73, 209, 214, 355],
"labels": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul"]
},
cls='max-w-md max-h-md'
)
docs_charts = create_doc_section(
H1("Charts API Reference"),
P(
"MonsterUI supports ", A("ApexCharts", href="https://apexcharts.com/", cls='underline'),
", a javascript library for rendering different charts like line and pie charts. ",
"See the full list of chart types ", A("here.", href="https://apexcharts.com/javascript-chart-demos/", cls='underline'),
),
P("To render a chart you'll need to include the ApexChart js in your app headers like this"),
CodeSpan("app, rt = fast_app(hdrs=Theme.blue.headers(apex_charts=True))"),
P("Then create an " , CodeSpan("ApexChart"), " component as shown in the examples below."),
P("Generally, you should be able to take any chart from the ApexChart docs, convert the chart's options var to a python dict and plug it straight into MonsterUI's ApexChart component."),
H2("Example usage", cls="mt-4"),
H4("Line chart", cls="mt-4"),
fn2code_string(ex_line_chart),
H4("Pie chart", cls="mt-4"),
fn2code_string(ex_pie_chart),
ApexChart,
title="Charts"
)
|