Reflex Logo

Intro

Gallery

Hosting

Learn

Components

Recipes

API Reference

Onboarding

Library

/

Datadisplay

/

Codeblock

The CodeBlock 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))
rx.code_block(
    """def fib(n):
    if n <= 1:
        return n
    else:
        return(fib(n-1) + fib(n-2))""",
    language="python",
    show_line_numbers=True,
)

A code block.

PropTypeDefault ValueValues
theme
Literal
"one-light"
language
Literal
"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]

Event Triggers

See the full list of default event triggers
← CalloutDataEditor →

Did you find this useful?

HomeGalleryChangelogIntroductionHosting