Repository: gradio-app/gradio
File: gradio/components/textbox.py (Python)

Code before:
class InputHTMLAttributes:
    """
    A dataclass for specifying HTML attributes for the input/textarea element. If any of these attributes are not provided, the browser will use its default value.
    Parameters:
        autocapitalize: The autocapitalize attribute for the input/textarea element. Can be "off", "none", "on", "sentences", "words", or "characters".
        autocorrect: The autocorrect attribute for the input/textarea element. Can be True (enabled) or False (disabled).
        spellcheck: The spellcheck attribute for the input/textarea element. Can be True (enabled) or False (disabled).
        autocomplete: The autocomplete attribute for the input/textarea element. Can be "on", "off", or specific values like "email", "current-password", "new-password", etc.
        tabindex: The tabindex attribute for the input/textarea element. An integer specifying the tab order.
        enterkeyhint: The enterkeyhint attribute for the input/textarea element. Can be "enter", "done", "go", "next", "previous", "search", or "send".
        lang: The lang attribute for the input/textarea element. A string containing a language code (e.g., "en", "es", "fr").
        aria_label: The aria-label attribute for the input/textarea element. A string providing an accessible name for screen readers.
        aria_describedby: The aria-describedby attribute for the input/textarea element. A string containing IDs of elements that describe this element.
        aria_placeholder: The aria-placeholder attribute for the input/textarea element. A string providing placeholder text for screen readers.
    """

    autocapitalize: Optional[str] = None
    autocorrect: Optional[bool] = None
    spellcheck: Optional[bool] = None
    autocomplete: Optional[str] = None
    tabindex: Optional[int] = None
    enterkeyhint: Optional[str] = None
    lang: Optional[str] = None
    aria_label: Optional[str] = None
    aria_describedby: Optional[str] = None
    aria_placeholder: Optional[str] = None


@document()
class Textbox(FormComponent):
    """
    Creates a textarea for user to enter string input or display string output.

    Demos: hello_world, diff_texts, sentence_builder
    Guides: creating-a-chatbot, real-time-speech-recognition
    """

    EVENTS = [
        Events.change,
        Events.input,
        Events.select,
        Events.submit,
        Events.focus,
        Events.blur,
        Events.stop,
        Events.copy,
    ]

    def __init__(
        self,
        value: str | I18nData | Callable | None = None,

Review comment (suggestion):
I think we should make these types more specific and ensure they match the possible attribute values. 

Code after:
class InputHTMLAttributes:
    """
    A dataclass for specifying HTML attributes for the input/textarea element. If any of these attributes are not provided, the browser will use its default value.
    Parameters:
        autocapitalize: The autocapitalize attribute for the input/textarea element. Can be "off", "none", "on", "sentences", "words", or "characters".
        autocorrect: The autocorrect attribute for the input/textarea element. Can be True (enabled) or False (disabled).
        spellcheck: The spellcheck attribute for the input/textarea element. Can be True (enabled) or False (disabled).
        autocomplete: The autocomplete attribute for the input/textarea element. Can be "on", "off", or specific values like "email", "current-password", "new-password", etc.
        tabindex: The tabindex attribute for the input/textarea element. An integer specifying the tab order.
        enterkeyhint: The enterkeyhint attribute for the input/textarea element. Can be "enter", "done", "go", "next", "previous", "search", or "send".
        lang: The lang attribute for the input/textarea element. A string containing a language code (e.g., "en", "es", "fr").
        aria_label: The aria-label attribute for the input/textarea element. A string providing an accessible name for screen readers.
        aria_describedby: The aria-describedby attribute for the input/textarea element. A string containing IDs of elements that describe this element.
        aria_placeholder: The aria-placeholder attribute for the input/textarea element. A string providing placeholder text for screen readers.
    """

    autocapitalize: Optional[
        Literal["off", "none", "on", "sentences", "words", "characters"]
    ] = None
    autocorrect: Optional[Literal["on", "off"]] = None
    spellcheck: Optional[bool] = None
    autocomplete: Optional[str] = None
    tabindex: Optional[int] = None
    enterkeyhint: Optional[
        Literal["enter", "done", "go", "next", "previous", "search", "send"]
    ] = None
    lang: Optional[str] = None
    aria_label: Optional[str] = None
    aria_describedby: Optional[str] = None
    aria_placeholder: Optional[str] = None


@document()
class Textbox(FormComponent):
    """
    Creates a textarea for user to enter string input or display string output.

    Demos: hello_world, diff_texts, sentence_builder
    Guides: creating-a-chatbot, real-time-speech-recognition
    """

    EVENTS = [
        Events.change,
        Events.input,
        Events.select,
        Events.submit,
        Events.focus,
        Events.blur,
        Events.stop,
        Events.copy,
    ]