Reflex Cloud - Fast, secure & scalable hosting. One command to deploy.

Code Block

The Code Block component can be used to display code easily within a website. Put in a multiline string with the correct spacing and specify and language to show the desired code.

1
2
3
4
5
def fib(n):
    if n <= 1:
        return n
    else:
        return(fib(n-1) + fib(n-2))

API Reference

rx.code_block

A code block.

PropType | ValuesDefault
theme
Union[Theme, str]
Theme.one_light
language
"abap" | "abnf" | ...
Var.create("python")
code
str
show_line_numbers
bool
starting_line_number
int
wrap_long_lines
bool
custom_style
Dict[str, Union]
{}
code_tag_props
Dict[str, str]
can_copy
bool
False
copy_button
Union[bool, Component, NoneType]
None

Event Triggers

See the full list of default event triggers