Skip to content

Components API Reference

This page contains the API reference for component classes and form components that are bundled with Starlette-Templates. All components are built using Pydantic models for type safety and validation.

The base class for all components is ComponentModel. All components extend this class and define their own properties and templates. Components must specify a template property that points to the Jinja2 template used for rendering. The template path is relative to the template loaders configured in the Jinja environment in [JinjaEnvMiddleware][starlette_templates.middleware.JinjaEnvMiddleware]. The Jinja2 template can access all properties defined on the component model.

ComponentModel

Base class for renderable UI components. Components should inherit from this class.

Components are rendered using Jinja2 templates, which can be organized and loaded via the application's Jinja2 environment template loaders configured in JinjaMiddleware.

class HeaderComponent(ComponentModel):
    template: str = "components/header.html"
    title: str
    subtitle: str

header = HeaderComponent(title="Welcome", subtitle="Enjoy your stay")
rendered_html = await header.render(request)

The context method can be overridden to provide custom context data for the Jinja templates.

class UserCardComponent(ComponentModel):
    template: str = "components/user_card.html"
    user_id: int

    def context(self) -> dict[str, t.Any]:
        user = get_user_from_db(self.user_id)
        return {"user": user}

user_card = UserCardComponent(user_id=42)
rendered_html = await user_card.render(request)

Attributes:

  • id (str) –

    Unique identifier for this component. Auto-generated by default.

  • template (str) –

    Path to the Jinja2 template used to render this component. Required.

Methods:

  • prepare_field_params

    Transform form field params before component instantiation.

  • context

    Context variables to set in parent template when this component is used.

  • render

    Render this component to HTML.

model_config class-attribute instance-attribute

model_config = ConfigDict(
    arbitrary_types_allowed=True, extra="allow"
)

id class-attribute instance-attribute

id: str = Field(default_factory=generate_component_id)

Unique identifier for this component. Auto-generated by default.

template instance-attribute

template: str

Path to the Jinja2 template used to render this component.

prepare_field_params classmethod

prepare_field_params(
    params: dict[str, Any], field_value: Any
) -> dict[str, Any]

Transform form field params before component instantiation.

Override in subclasses that need special handling when used with FormModel. For example, Select components need to convert choices to SelectOption objects, and Checkbox components need to set checked state from the field value.

By default, this method sets the 'value' param to the field value.

Parameters:

  • params (dict[str, Any]) –

    Parameters from the form field's json_schema_extra

  • field_value (Any) –

    The current value of the form field

Returns:

  • dict[str, Any]

    Modified params dict ready for component instantiation

context

context(
    jinja_context: dict[str, Any], request: Request
) -> dict[str, Any]

Context variables to set in parent template when this component is used.

Override this method to set context variables that should be available to the parent template. For example, components can set library inclusion flags like include_datatables or any other context variables.

Parameters:

  • jinja_context (dict[str, Any]) –

    The current Jinja2 rendering context

  • request (Request) –

    The Starlette Request object

Returns:

  • dict[str, Any]

    Dictionary of context variables to merge into parent template context

render async

render(request: Request, **kwargs) -> Markup

Render this component to HTML.

Form Components

These components are designed to work with the FormModel for building Pydantic-based forms with validation and rendering.

Input

Bootstrap form input component.

Methods:

Attributes:

  • template (str) –

    Bootstrap input form control component.

  • name (str) –

    Input name attribute.

  • label (str | None) –

    Input label.

  • type (str) –

    Input type, e.g., text, email, password, number, tel, url, etc.

  • value (str | None) –

    Input value.

  • placeholder (str | None) –

    Placeholder text.

  • help_text (str | None) –

    Help text below input.

  • required (bool) –

    Whether the input is required.

  • disabled (bool) –

    Whether the input is disabled.

  • readonly (bool) –

    Whether the input is readonly.

  • validation_state (str | None) –

    Validation state: valid, invalid.

  • validation_message (str | None) –

    Validation feedback message.

  • prepend (str | None) –

    Prepend text/icon to input.

  • append (str | None) –

    Append text/icon to input.

  • size (str | None) –

    Input size: sm, lg.

template class-attribute instance-attribute

template: str = Field('components/input.html', frozen=True)

Bootstrap input form control component.

name class-attribute instance-attribute

name: str = Field(..., description='Input name attribute')

Input name attribute.

label class-attribute instance-attribute

label: str | None = Field(
    default=None, description="Input label"
)

Input label.

type class-attribute instance-attribute

type: str = Field(
    default="text",
    description="Input type: text, email, password, number, tel, url, etc.",
)

Input type, e.g., text, email, password, number, tel, url, etc.

value class-attribute instance-attribute

value: str | None = Field(
    default=None, description="Input value"
)

Input value.

placeholder class-attribute instance-attribute

placeholder: str | None = Field(
    default=None, description="Placeholder text"
)

Placeholder text.

help_text class-attribute instance-attribute

help_text: str | None = Field(
    default=None, description="Help text below input"
)

Help text below input.

required class-attribute instance-attribute

required: bool = Field(
    default=False, description="Required field"
)

Whether the input is required.

disabled class-attribute instance-attribute

disabled: bool = Field(
    default=False, description="Disabled input"
)

Whether the input is disabled.

readonly class-attribute instance-attribute

readonly: bool = Field(
    default=False, description="Readonly input"
)

Whether the input is readonly.

validation_state class-attribute instance-attribute

validation_state: str | None = Field(
    default=None,
    description="Validation state: valid, invalid",
)

Validation state: valid, invalid.

validation_message class-attribute instance-attribute

validation_message: str | None = Field(
    default=None, description="Validation feedback message"
)

Validation feedback message.

prepend class-attribute instance-attribute

prepend: str | None = Field(
    default=None, description="Prepend text/icon to input"
)

Prepend text/icon to input.

append class-attribute instance-attribute

append: str | None = Field(
    default=None, description="Append text/icon to input"
)

Append text/icon to input.

size class-attribute instance-attribute

size: str | None = Field(
    default=None, description="Input size: sm, lg"
)

Input size: sm, lg.

prepare_field_params classmethod

prepare_field_params(
    params: dict[str, Any], field_value: Any
) -> dict[str, Any]

Convert field value to string for input element.

Textarea

Bootstrap textarea component.

Methods:

Attributes:

  • template (str) –

    Bootstrap textarea component template.

  • name (str) –

    Textarea name attribute.

  • label (str | None) –

    Textarea label.

  • value (str | None) –

    Textarea value.

  • placeholder (str | None) –

    Placeholder text.

  • help_text (str | None) –

    Help text below textarea.

  • rows (int) –

    Number of rows.

  • required (bool) –

    Whether the textarea is required.

  • disabled (bool) –

    Whether the textarea is disabled.

  • readonly (bool) –

    Whether the textarea is readonly.

  • validation_state (str | None) –

    Validation state: valid, invalid.

  • validation_message (str | None) –

    Validation feedback message.

template class-attribute instance-attribute

template: str = Field(
    "components/textarea.html", frozen=True
)

Bootstrap textarea component template.

name class-attribute instance-attribute

name: str = Field(
    ..., description="Textarea name attribute"
)

Textarea name attribute.

label class-attribute instance-attribute

label: str | None = Field(
    default=None, description="Textarea label"
)

Textarea label.

value class-attribute instance-attribute

value: str | None = Field(
    default=None, description="Textarea value"
)

Textarea value.

placeholder class-attribute instance-attribute

placeholder: str | None = Field(
    default=None, description="Placeholder text"
)

Placeholder text.

help_text class-attribute instance-attribute

help_text: str | None = Field(
    default=None, description="Help text below textarea"
)

Help text below textarea.

rows class-attribute instance-attribute

rows: int = Field(default=3, description='Number of rows')

Number of rows.

required class-attribute instance-attribute

required: bool = Field(
    default=False, description="Required field"
)

Whether the textarea is required.

disabled class-attribute instance-attribute

disabled: bool = Field(
    default=False, description="Disabled textarea"
)

Whether the textarea is disabled.

readonly class-attribute instance-attribute

readonly: bool = Field(
    default=False, description="Readonly textarea"
)

Whether the textarea is readonly.

validation_state class-attribute instance-attribute

validation_state: str | None = Field(
    default=None,
    description="Validation state: valid, invalid",
)

Validation state: valid, invalid.

validation_message class-attribute instance-attribute

validation_message: str | None = Field(
    default=None, description="Validation feedback message"
)

Validation feedback message.

prepare_field_params classmethod

prepare_field_params(
    params: dict[str, Any], field_value: Any
) -> dict[str, Any]

Convert field value to string for textarea element.

Select

Bootstrap select dropdown component.

Methods:

Attributes:

  • template (str) –

    Bootstrap select dropdown component template.

  • name (str) –

    Select name attribute.

  • label (str | None) –

    Select label.

  • options (list[SelectOption]) –

    Select options.

  • help_text (str | None) –

    Help text below select.

  • required (bool) –

    Whether the select is required.

  • disabled (bool) –

    Whether the select is disabled.

  • multiple (bool) –

    Allow multiple selections.

  • size (str | None) –

    Select size: sm, lg.

  • validation_state (str | None) –

    Validation state: valid, invalid.

  • validation_message (str | None) –

    Validation feedback message.

template class-attribute instance-attribute

template: str = Field("components/select.html", frozen=True)

Bootstrap select dropdown component template.

name class-attribute instance-attribute

name: str = Field(..., description='Select name attribute')

Select name attribute.

label class-attribute instance-attribute

label: str | None = Field(
    default=None, description="Select label"
)

Select label.

options class-attribute instance-attribute

options: list[SelectOption] = Field(
    default_factory=list, description="Select options"
)

Select options.

help_text class-attribute instance-attribute

help_text: str | None = Field(
    default=None, description="Help text below select"
)

Help text below select.

required class-attribute instance-attribute

required: bool = Field(
    default=False, description="Required field"
)

Whether the select is required.

disabled class-attribute instance-attribute

disabled: bool = Field(
    default=False, description="Disabled select"
)

Whether the select is disabled.

multiple class-attribute instance-attribute

multiple: bool = Field(
    default=False, description="Allow multiple selections"
)

Allow multiple selections.

size class-attribute instance-attribute

size: str | None = Field(
    default=None, description="Select size: sm, lg"
)

Select size: sm, lg.

validation_state class-attribute instance-attribute

validation_state: str | None = Field(
    default=None,
    description="Validation state: valid, invalid",
)

Validation state: valid, invalid.

validation_message class-attribute instance-attribute

validation_message: str | None = Field(
    default=None, description="Validation feedback message"
)

Validation feedback message.

prepare_field_params classmethod

prepare_field_params(
    params: dict[str, Any], field_value: Any
) -> dict[str, Any]

Convert choices to SelectOption objects with proper selected state.

Checkbox

Bootstrap checkbox component.

Methods:

Attributes:

  • template (str) –

    Bootstrap checkbox component template.

  • name (str) –

    Checkbox name attribute.

  • label (str) –

    Checkbox label.

  • value (str) –

    Checkbox value.

  • checked (bool) –

    Checked state.

  • disabled (bool) –

    Whether the checkbox is disabled.

  • inline (bool) –

    Display inline.

  • validation_state (str | None) –

    Validation state: valid, invalid.

  • validation_message (str | None) –

    Validation feedback message.

template class-attribute instance-attribute

template: str = Field(
    "components/checkbox.html", frozen=True
)

Bootstrap checkbox component template.

name class-attribute instance-attribute

name: str = Field(
    ..., description="Checkbox name attribute"
)

Checkbox name attribute.

label class-attribute instance-attribute

label: str = Field(..., description='Checkbox label')

Checkbox label.

value class-attribute instance-attribute

value: str = Field(
    default="1", description="Checkbox value"
)

Checkbox value.

checked class-attribute instance-attribute

checked: bool = Field(
    default=False, description="Checked state"
)

Checked state.

disabled class-attribute instance-attribute

disabled: bool = Field(
    default=False, description="Disabled checkbox"
)

Whether the checkbox is disabled.

inline class-attribute instance-attribute

inline: bool = Field(
    default=False, description="Display inline"
)

Display inline.

validation_state class-attribute instance-attribute

validation_state: str | None = Field(
    default=None,
    description="Validation state: valid, invalid",
)

Validation state: valid, invalid.

validation_message class-attribute instance-attribute

validation_message: str | None = Field(
    default=None, description="Validation feedback message"
)

Validation feedback message.

prepare_field_params classmethod

prepare_field_params(
    params: dict[str, Any], field_value: Any
) -> dict[str, Any]

Set checked state from field value instead of using value.

Radio

Bootstrap radio button component.

Attributes:

  • template (str) –

    Bootstrap radio button component template.

  • name (str) –

    Radio name attribute (same for group).

  • label (str) –

    Radio label.

  • value (str) –

    Radio value.

  • checked (bool) –

    Checked state.

  • disabled (bool) –

    Whether the radio is disabled.

  • inline (bool) –

    Display inline.

  • validation_state (str | None) –

    Validation state: valid, invalid.

  • validation_message (str | None) –

    Validation feedback message.

template class-attribute instance-attribute

template: str = Field('components/radio.html', frozen=True)

Bootstrap radio button component template.

name class-attribute instance-attribute

name: str = Field(
    ..., description="Radio name attribute (same for group)"
)

Radio name attribute (same for group).

label class-attribute instance-attribute

label: str = Field(..., description='Radio label')

Radio label.

value class-attribute instance-attribute

value: str = Field(..., description='Radio value')

Radio value.

checked class-attribute instance-attribute

checked: bool = Field(
    default=False, description="Checked state"
)

Checked state.

disabled class-attribute instance-attribute

disabled: bool = Field(
    default=False, description="Disabled radio"
)

Whether the radio is disabled.

inline class-attribute instance-attribute

inline: bool = Field(
    default=False, description="Display inline"
)

Display inline.

validation_state class-attribute instance-attribute

validation_state: str | None = Field(
    default=None,
    description="Validation state: valid, invalid",
)

Validation state: valid, invalid.

validation_message class-attribute instance-attribute

validation_message: str | None = Field(
    default=None, description="Validation feedback message"
)

Validation feedback message.

Switch

Bootstrap switch component (styled checkbox).

Attributes:

  • template (str) –

    Bootstrap switch component template.

  • name (str) –

    Switch name attribute.

  • label (str) –

    Switch label.

  • value (str) –

    Switch value.

  • checked (bool) –

    Checked state.

  • disabled (bool) –

    Whether the switch is disabled.

  • validation_state (str | None) –

    Validation state: valid, invalid.

  • validation_message (str | None) –

    Validation feedback message.

template class-attribute instance-attribute

template: str = Field("components/switch.html", frozen=True)

Bootstrap switch component template.

name class-attribute instance-attribute

name: str = Field(..., description='Switch name attribute')

Switch name attribute.

label class-attribute instance-attribute

label: str = Field(..., description='Switch label')

Switch label.

value class-attribute instance-attribute

value: str = Field(default='1', description='Switch value')

Switch value.

checked class-attribute instance-attribute

checked: bool = Field(
    default=False, description="Checked state"
)

Checked state.

disabled class-attribute instance-attribute

disabled: bool = Field(
    default=False, description="Disabled switch"
)

Whether the switch is disabled.

validation_state class-attribute instance-attribute

validation_state: str | None = Field(
    default=None,
    description="Validation state: valid, invalid",
)

Validation state: valid, invalid.

validation_message class-attribute instance-attribute

validation_message: str | None = Field(
    default=None, description="Validation feedback message"
)

Validation feedback message.

FileInput

Bootstrap file input component.

Attributes:

  • template (str) –

    Bootstrap file input component template.

  • name (str) –

    File input name attribute.

  • label (str | None) –

    File input label.

  • help_text (str | None) –

    Help text below input.

  • required (bool) –

    Whether the file input is required.

  • disabled (bool) –

    Whether the file input is disabled.

  • multiple (bool) –

    Allow multiple files.

  • accept (str | None) –

    Accepted file types (e.g., 'image/*').

  • validation_state (str | None) –

    Validation state: valid, invalid.

  • validation_message (str | None) –

    Validation feedback message.

template class-attribute instance-attribute

template: str = Field(
    "components/file_input.html", frozen=True
)

Bootstrap file input component template.

name class-attribute instance-attribute

name: str = Field(
    ..., description="File input name attribute"
)

File input name attribute.

label class-attribute instance-attribute

label: str | None = Field(
    default=None, description="File input label"
)

File input label.

help_text class-attribute instance-attribute

help_text: str | None = Field(
    default=None, description="Help text below input"
)

Help text below input.

required class-attribute instance-attribute

required: bool = Field(
    default=False, description="Required field"
)

Whether the file input is required.

disabled class-attribute instance-attribute

disabled: bool = Field(
    default=False, description="Disabled input"
)

Whether the file input is disabled.

multiple class-attribute instance-attribute

multiple: bool = Field(
    default=False, description="Allow multiple files"
)

Allow multiple files.

accept class-attribute instance-attribute

accept: str | None = Field(
    default=None,
    description="Accepted file types (e.g., 'image/*')",
)

Accepted file types (e.g., 'image/*').

validation_state class-attribute instance-attribute

validation_state: str | None = Field(
    default=None,
    description="Validation state: valid, invalid",
)

Validation state: valid, invalid.

validation_message class-attribute instance-attribute

validation_message: str | None = Field(
    default=None, description="Validation feedback message"
)

Validation feedback message.

Range

Bootstrap range slider component.

Attributes:

  • template (str) –

    Bootstrap range slider component template.

  • name (str) –

    Range name attribute.

  • label (str | None) –

    Range label.

  • min (float) –

    Minimum value.

  • max (float) –

    Maximum value.

  • step (float) –

    Step increment.

  • value (float) –

    Current value.

  • disabled (bool) –

    Whether the range is disabled.

  • help_text (str | None) –

    Help text below range.

  • validation_state (str | None) –

    Validation state: valid, invalid.

  • validation_message (str | None) –

    Validation feedback message.

template class-attribute instance-attribute

template: str = Field('components/range.html', frozen=True)

Bootstrap range slider component template.

name class-attribute instance-attribute

name: str = Field(..., description='Range name attribute')

Range name attribute.

label class-attribute instance-attribute

label: str | None = Field(
    default=None, description="Range label"
)

Range label.

min class-attribute instance-attribute

min: float = Field(default=0, description='Minimum value')

Minimum value.

max class-attribute instance-attribute

max: float = Field(default=100, description="Maximum value")

Maximum value.

step class-attribute instance-attribute

step: float = Field(default=1, description="Step increment")

Step increment.

value class-attribute instance-attribute

value: float = Field(
    default=50, description="Current value"
)

Current value.

disabled class-attribute instance-attribute

disabled: bool = Field(
    default=False, description="Disabled range"
)

Whether the range is disabled.

help_text class-attribute instance-attribute

help_text: str | None = Field(
    default=None, description="Help text below range"
)

Help text below range.

validation_state class-attribute instance-attribute

validation_state: str | None = Field(
    default=None,
    description="Validation state: valid, invalid",
)

Validation state: valid, invalid.

validation_message class-attribute instance-attribute

validation_message: str | None = Field(
    default=None, description="Validation feedback message"
)

Validation feedback message.

ChoicesSelect

Choices.js enhanced select component.

Methods:

Attributes:

  • id (str) –

    Element ID for the select.

  • template (str) –

    Choices.js select component template.

  • name (str) –

    Select name attribute.

  • label (str | None) –

    Select label.

  • options (list[ChoiceOption | ChoiceGroup]) –

    Select options or option groups.

  • placeholder (str) –

    Placeholder text.

  • search_enabled (bool) –

    Enable search functionality.

  • search_placeholder (str) –

    Search placeholder.

  • multiple (bool) –

    Allow multiple selections.

  • remove_button (bool) –

    Show remove button for selected items.

  • max_item_count (int | None) –

    Max items that can be selected (for multiple).

  • help_text (str | None) –

    Help text below select.

  • required (bool) –

    Whether the select is required.

  • disabled (bool) –

    Whether the select is disabled.

  • validation_state (str | None) –

    Validation state: valid, invalid.

  • validation_message (str | None) –

    Validation feedback message.

id instance-attribute

id: str

Element ID for the select.

template class-attribute instance-attribute

template: str = Field(
    "components/choices_select.html", frozen=True
)

Choices.js select component template.

name class-attribute instance-attribute

name: str = Field(..., description='Select name attribute')

Select name attribute.

label class-attribute instance-attribute

label: str | None = Field(
    default=None, description="Select label"
)

Select label.

options class-attribute instance-attribute

options: list[ChoiceOption | ChoiceGroup] = Field(
    default_factory=list
)

Select options or option groups.

placeholder class-attribute instance-attribute

placeholder: str = Field(
    default="Select an option",
    description="Placeholder text",
)

Placeholder text.

search_enabled class-attribute instance-attribute

search_enabled: bool = Field(
    default=True, description="Enable search functionality"
)

Enable search functionality.

search_placeholder class-attribute instance-attribute

search_placeholder: str = Field(
    default="Type to search",
    description="Search placeholder",
)

Search placeholder.

multiple class-attribute instance-attribute

multiple: bool = Field(
    default=False, description="Allow multiple selections"
)

Allow multiple selections.

remove_button class-attribute instance-attribute

remove_button: bool = Field(
    default=True,
    description="Show remove button for selected items",
)

Show remove button for selected items.

max_item_count class-attribute instance-attribute

max_item_count: int | None = Field(
    default=None,
    description="Max items that can be selected (for multiple)",
)

Max items that can be selected (for multiple).

help_text class-attribute instance-attribute

help_text: str | None = Field(
    default=None, description="Help text below select"
)

Help text below select.

required class-attribute instance-attribute

required: bool = Field(
    default=False, description="Required field"
)

Whether the select is required.

disabled class-attribute instance-attribute

disabled: bool = Field(
    default=False, description="Disabled select"
)

Whether the select is disabled.

validation_state class-attribute instance-attribute

validation_state: str | None = Field(
    default=None,
    description="Validation state: valid, invalid",
)

Validation state: valid, invalid.

validation_message class-attribute instance-attribute

validation_message: str | None = Field(
    default=None, description="Validation feedback message"
)

Validation feedback message.

prepare_field_params classmethod

prepare_field_params(
    params: dict[str, Any], field_value: Any
) -> dict[str, Any]

Convert choices to ChoiceOption objects with proper selected state.

DatePicker

Flatpickr date picker component.

Methods:

Attributes:

  • id (str) –

    Element ID for the date picker.

  • template (str) –

    Flatpickr date picker component template.

  • name (str) –

    Input name attribute.

  • label (str | None) –

    Input label.

  • value (str | None) –

    Initial date value (YYYY-MM-DD).

  • placeholder (str | None) –

    Placeholder text.

  • mode (str) –

    Selection mode: single, multiple, range.

  • enable_time (bool) –

    Enable time picker.

  • time_24hr (bool) –

    Use 24-hour time format.

  • date_format (str) –

    Date format string.

  • min_date (str | None) –

    Minimum selectable date.

  • max_date (str | None) –

    Maximum selectable date.

  • disable_dates (list[str]) –

    Dates to disable.

  • inline (bool) –

    Display calendar inline.

  • help_text (str | None) –

    Help text below input.

  • required (bool) –

    Whether the date picker is required.

  • disabled (bool) –

    Whether the date picker is disabled.

  • validation_state (str | None) –

    Validation state: valid, invalid.

  • validation_message (str | None) –

    Validation feedback message.

id instance-attribute

id: str

Element ID for the date picker.

template class-attribute instance-attribute

template: str = Field(
    "components/datepicker.html", frozen=True
)

Flatpickr date picker component template.

name class-attribute instance-attribute

name: str = Field(..., description='Input name attribute')

Input name attribute.

label class-attribute instance-attribute

label: str | None = Field(
    default=None, description="Input label"
)

Input label.

value class-attribute instance-attribute

value: str | None = Field(
    default=None,
    description="Initial date value (YYYY-MM-DD)",
)

Initial date value (YYYY-MM-DD).

placeholder class-attribute instance-attribute

placeholder: str | None = Field(
    default="Select date", description="Placeholder text"
)

Placeholder text.

mode class-attribute instance-attribute

mode: str = Field(
    default="single",
    description="Selection mode: single, multiple, range",
)

Selection mode: single, multiple, range.

enable_time class-attribute instance-attribute

enable_time: bool = Field(
    default=False, description="Enable time picker"
)

Enable time picker.

time_24hr class-attribute instance-attribute

time_24hr: bool = Field(
    default=True, description="Use 24-hour time format"
)

Use 24-hour time format.

date_format class-attribute instance-attribute

date_format: str = Field(
    default="Y-m-d", description="Date format string"
)

Date format string.

min_date class-attribute instance-attribute

min_date: str | None = Field(
    default=None, description="Minimum selectable date"
)

Minimum selectable date.

max_date class-attribute instance-attribute

max_date: str | None = Field(
    default=None, description="Maximum selectable date"
)

Maximum selectable date.

disable_dates class-attribute instance-attribute

disable_dates: list[str] = Field(
    default_factory=list, description="Dates to disable"
)

Dates to disable.

inline class-attribute instance-attribute

inline: bool = Field(
    default=False, description="Display calendar inline"
)

Display calendar inline.

help_text class-attribute instance-attribute

help_text: str | None = Field(
    default=None, description="Help text below input"
)

Help text below input.

required class-attribute instance-attribute

required: bool = Field(
    default=False, description="Required field"
)

Whether the date picker is required.

disabled class-attribute instance-attribute

disabled: bool = Field(
    default=False, description="Disabled input"
)

Whether the date picker is disabled.

validation_state class-attribute instance-attribute

validation_state: str | None = Field(
    default=None,
    description="Validation state: valid, invalid",
)

Validation state: valid, invalid.

validation_message class-attribute instance-attribute

validation_message: str | None = Field(
    default=None, description="Validation feedback message"
)

Validation feedback message.

prepare_field_params classmethod

prepare_field_params(
    params: dict[str, Any], field_value: Any
) -> dict[str, Any]

Convert date/datetime values to ISO string format.

SubmitButton

Bootstrap submit button component for forms.

Methods:

Attributes:

  • template (str) –

    Bootstrap submit button component template.

  • text (str) –

    Button text.

  • button_type (str) –

    Button type: submit, button, reset.

  • name (str | None) –

    Button name attribute.

  • classes (list[str]) –

    CSS classes.

  • disabled (bool) –

    Whether the button is disabled.

  • form (str | None) –

    Form element the button is associated with.

  • formaction (str | None) –

    URL where form data is sent.

  • formenctype (str | None) –

    How form data is encoded.

  • formmethod (str | None) –

    HTTP method when button is clicked.

  • formnovalidate (bool) –

    Whether to bypass form validation.

  • formtarget (str | None) –

    Where to display response.

template class-attribute instance-attribute

template: str = Field(
    "components/submit_button.html", frozen=True
)

Bootstrap submit button component template.

text class-attribute instance-attribute

text: str = Field(
    default="Submit", description="Button text"
)

Button text.

button_type class-attribute instance-attribute

button_type: str = Field(
    default="submit",
    description="Button type: submit, button, reset",
)

Button type: submit, button, reset.

name class-attribute instance-attribute

name: str | None = Field(
    default=None, description="Button name attribute"
)

Button name attribute.

classes class-attribute instance-attribute

classes: list[str] = Field(
    default_factory=lambda: ["btn", "btn-primary"],
    description="CSS classes",
)

CSS classes.

disabled class-attribute instance-attribute

disabled: bool = Field(
    default=False, description="Disabled button"
)

Whether the button is disabled.

form class-attribute instance-attribute

form: str | None = Field(
    default=None,
    description="Form element the button is associated with",
)

Form element the button is associated with.

formaction class-attribute instance-attribute

formaction: str | None = Field(
    default=None, description="URL where form data is sent"
)

URL where form data is sent.

formenctype class-attribute instance-attribute

formenctype: str | None = Field(
    default=None, description="How form data is encoded"
)

How form data is encoded.

formmethod class-attribute instance-attribute

formmethod: str | None = Field(
    default=None,
    description="HTTP method when button is clicked",
)

HTTP method when button is clicked.

formnovalidate class-attribute instance-attribute

formnovalidate: bool = Field(
    default=False,
    description="Whether to bypass form validation",
)

Whether to bypass form validation.

formtarget class-attribute instance-attribute

formtarget: str | None = Field(
    default=None, description="Where to display response"
)

Where to display response.

prepare_field_params classmethod

prepare_field_params(
    params: dict[str, Any], field_value: Any
) -> dict[str, Any]

Submit buttons don't use field values.