Skip to content

molecule_input

Displays a molecule sketcher widget and maps its value to the backend as a string + toolkit.Molecule object.

Basic use

{% htmx_molecule_input %}
from simmate.website.htmx.components import (
    HtmxComponent,
    MoleculeInput,
)


class TargetFormView(HtmxComponent, MoleculeInput):

    class Meta:
        javascript_exclude = (
            *HtmxComponent.Meta.javascript_exclude,
            *MoleculeInput.Meta.javascript_exclude,
        )

Parameters

Parameter Description
name The unique name or identifier for the input field. This should match the name of your class attribute in the backend.
Type: str, Default: "molecule"
label The display label for the input field. If not provided, the name may be used as the label.
Type: str, Default: None
show_label Whether to display the label alongside the input field.
Type: bool, Default: True
help_text Optional helper text to be shown alongside the input field.
Type: str, Default: None
load_button Whether to display a button that loads the molecule from the sketcher and the replaces the sketcher with the molecule image.
Type: bool, Default: True
defer Whether to defer processing or submission of the input value.
Type: bool, Default: True
many_molecules Whether to allow input of multiple molecules (e.g., as a list or batch input).
Type: bool, Default: False
export_format The format to export the molecule as. Options are mol and smiles.
Type: str, Default: "mol"

For the molecule sketcher:

Parameter Description
allow_sketcher_input Whether to allow molecule input via a sketcher widget.
Type: bool, Default: True
sketcher_input_label The label to display above the sketcher input.
Type: str, Default: "Draw Molecule"

For the text input area:

Parameter Description
allow_text_input Whether to allow molecule input via a text area (e.g., SMILES, mol block).
Type: bool, Default: False
text_input_label The label to display above the text input area.
Type: str, Default: "Paste Molecule Text"

For the reference input area:

Parameter Description
allow_reference_input Whether to allow molecule input via a reference ID (e.g. PubChem CID).
Type: bool, Default: False
reference_input_label The label to display above the reference input field.
Type: str, Default: "Molecule Ref. ID"
reference_input_placeholder Placeholder text for the reference input field.
Type: str, Default: "12345"

For the "custom input" area (e.g., IDs from other table):

Parameter Description
allow_custom_input Whether to allow a custom input field (e.g., for IDs or external references).
Type: bool, Default: False
custom_input_label The label to display above the custom input field.
Type: str, Default: "Custom Input"
custom_input_placeholder Placeholder text for the custom input field.
Type: str, Default: "12345"