A code editor. Examples: ```python code_editor = mo.ui.code_editor() ``` Attributes: value (str): A string of the code editor contents. Args: value (str, optional): Initial value of the code editor. Defaults to "". language (str, op
| 852 | |
| 853 | @mddoc |
| 854 | class code_editor(UIElement[str, str]): |
| 855 | """ |
| 856 | A code editor. |
| 857 | |
| 858 | Examples: |
| 859 | ```python |
| 860 | code_editor = mo.ui.code_editor() |
| 861 | ``` |
| 862 | |
| 863 | Attributes: |
| 864 | value (str): A string of the code editor contents. |
| 865 | |
| 866 | Args: |
| 867 | value (str, optional): Initial value of the code editor. Defaults to "". |
| 868 | language (str, optional): Language of the code editor. Most major languages |
| 869 | are supported, including "sql", "javascript", "typescript", "html", |
| 870 | "css", "c", "cpp", "rust", and more. Defaults to "python". |
| 871 | placeholder (str, optional): Placeholder text to display when the code editor |
| 872 | is empty. Defaults to "". |
| 873 | theme (Literal["light", "dark"], optional): Theme of the code editor. |
| 874 | Defaults to the editor's default. |
| 875 | disabled (bool, optional): Whether the input is disabled. Defaults to False. |
| 876 | min_height (int, optional): Minimum height of the code editor in pixels. |
| 877 | Defaults to None. |
| 878 | max_height (int, optional): Maximum height of the code editor in pixels. |
| 879 | Defaults to None. |
| 880 | label (str, optional): Markdown label for the element. Defaults to "". |
| 881 | on_change (Callable[[str], None], optional): Optional callback to run when |
| 882 | this element's value changes. Defaults to None. |
| 883 | show_copy_button (bool): Whether to show a button to copy the code |
| 884 | to the clipboard. Defaults to True. |
| 885 | debounce (bool | int, optional): Whether the input is debounced. If number, |
| 886 | debounce by that many milliseconds. If True, then value is only emitted |
| 887 | when the input loses focus. Defaults to False. |
| 888 | """ |
| 889 | |
| 890 | _name: Final[str] = "marimo-code-editor" |
| 891 | |
| 892 | def __init__( |
| 893 | self, |
| 894 | value: str = "", |
| 895 | language: str = "python", |
| 896 | placeholder: str = "", |
| 897 | theme: Literal["light", "dark"] | None = None, |
| 898 | disabled: bool = False, |
| 899 | min_height: int | None = None, |
| 900 | max_height: int | None = None, |
| 901 | show_copy_button: bool = True, |
| 902 | debounce: bool | int = False, |
| 903 | *, |
| 904 | label: str = "", |
| 905 | on_change: Callable[[str], None] | None = None, |
| 906 | ) -> None: |
| 907 | if ( |
| 908 | min_height is not None |
| 909 | and max_height is not None |
| 910 | and min_height > max_height |
| 911 | ): |