Reflex Logo
Docs Logo
Library

/

Data Display

/

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]
-
language
"abap" | "abnf" | ...
-
code
str
-
show_line_numbers
bool
-
starting_line_number
int
-
wrap_long_lines
bool
-
code_tag_props
Dict[str, str | dict[str, str]]
-

Built with Reflex