Skip to content

Commit

Permalink
feat: support styling input field of ChatInput
Browse files Browse the repository at this point in the history
Some users have been confused about why the value they give to the `style` prop of `ChatInput` does not get applied to the input field. This makes it possible to style that component.
  • Loading branch information
iisakkirotko committed Sep 27, 2024
1 parent 806114f commit de1c6fa
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions solara/lab/components/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def ChatInput(
send_callback: Optional[Callable] = None,
disabled: bool = False,
style: Optional[Union[str, Dict[str, str]]] = None,
input_text_style: Optional[Union[str, Dict[str, str]]] = None,
classes: List[str] = [],
):
"""
Expand All @@ -56,11 +57,13 @@ def ChatInput(
* `send_callback`: A callback function for when the user presses enter or clicks the send button.
* `disabled`: Whether the input should be disabled. Useful for disabling sending further messages while a chatbot is replying,
among other things.
* `style`: CSS styles to apply to the component. Either a string or a dictionary. These styles are applied to the container component.
* `style`: CSS styles to apply to the `solara.Row` containing the input field and submit button. Either a string or a dictionary.
* `input_text_style`: CSS styles to apply to the `InputText` part of the component. Either a string or a dictionary.
* `classes`: A list of CSS classes to apply to the component. Also applied to the container.
"""
message, set_message = solara.use_state("") # type: ignore
style_flat = solara.util._flatten_style(style)
input_text_style_flat = solara.util._flatten_style(input_text_style)

if "align-items" not in style_flat:
style_flat += " align-items: center;"
Expand All @@ -79,7 +82,7 @@ def send(*ignore_args):
rounded=True,
filled=True,
hide_details=True,
style_="flex-grow: 1;",
style_="flex-grow: 1;" + input_text_style_flat,
disabled=disabled,
)

Expand Down

0 comments on commit de1c6fa

Please sign in to comment.