Field
Example:
Code example:
from htmy import ComponentType, html
from htmui.basecoat.field import field, fieldset
def example() -> ComponentType:
return html.form(
fieldset(
field(
html.label("Title", for_="title-input"),
html.input_(id="title-input", type="text", required=""),
),
field(
html.label("Description", for_="description-input"),
html.textarea(id="description-input"),
),
title="New Issue",
subtitle=html.p("Fill out the form to create a new issue."),
),
class_="w-full max-w-md space-y-4",
)
Component implementation:
For more details, see the BasecoatUI documentation.
from htmy import ComponentType, PropertyValue, html, join_classes
__version__ = "0.1.0"
__framework__ = "BasecoatUI"
__framework_version__ = "0.3"
__framework_url__ = "https://basecoatui.com/components/field/"
def fieldset(
*children: ComponentType,
title: ComponentType,
subtitle: ComponentType = None,
class_: str | None = None,
**kwargs: PropertyValue,
) -> ComponentType:
return html.fieldset(
html.legend(title),
subtitle,
*children,
class_=join_classes("fieldset", class_),
**kwargs,
)
def field(
*children: ComponentType,
class_: str | None = None,
**kwargs: PropertyValue,
) -> ComponentType:
return html.div(*children, class_=join_classes("field", class_), role="group", **kwargs)