mk_compfn
mk_compfn (compcls, tag=None, name=None, xcls='', **compkw)
Create a FastHTML component function for a Garden CSS class
| compcls |
|
|
Base CSS class (e.g. ‘c-btn’) |
| tag |
NoneType |
None |
HTML tag function to use (defaults to name) |
| name |
NoneType |
None |
Component function name (defaults to clstoname(compcls)) |
| xcls |
str |
|
Extra classes to always include |
| compkw |
VAR_KEYWORD |
|
|
Create a button component by passing the Garden CSS class to mk_compfn:
This creates a Btn function that wraps the c-btn class. Use it like any FastHTML component:
btn = Btn('Click me')
print(btn)
<btn class="c-btn ">Click me</btn>
Garden modifiers start with --. Pass them via cls and they’ll be prefixed automatically:
pill = Btn('Click me', cls='--pill')
print(pill)
<btn class="c-btn c-btn--pill ">Click me</btn>