## Code Use Code to display code without syntax highlighting. Category: Typography ### Inline Code ```python import dash_mantine_components as dmc component = dmc.Code("app = Dash(__name__)") ``` ### Block Code ```python import dash_mantine_components as dmc component = dmc.Code( """from dash import Dash import dash_mantine_components as dmc app = Dash(__name__) app.layout = dmc.Button("Settings") if __name__ == "__main__": app.run_server(debug=True)""", block=True, ) ``` ### Colors ```python import dash_mantine_components as dmc code = "import collections" component = dmc.Group( children=[ dmc.Code(code, color=color) for color in ["red", "blue", "green", "pink"] ], ) ``` ### Syntax Highlighting In case you need syntax highlight like in all code examples on this documentation, use [dmc.CodeHighlight](/components/code-highlight) component. ### Styles API This component supports Styles API. With Styles API, you can customize styles of any inner element. See the Styling and Theming sections of these docs for more information. | Name | Static selector | Description | |:-------------|:-------------------|:----------------------------------------------| | root | .mantine-Code-root | Root element | ### Keyword Arguments #### Code - children (a list of or a singular dash component, string or number; optional): Content. - id (string; optional): Unique ID to identify this component in Dash callbacks. - aria-* (string; optional): Wild card aria attributes. - attributes (boolean | number | string | dict | list; optional): Passes attributes to inner elements of a component. See Styles API docs. - block (boolean; optional): If set code will be rendered inside `pre`, `False` by default. - className (string; optional): Class added to the root element, if applicable. - classNames (dict; optional): Adds custom CSS class names to inner elements of a component. See Styles API docs. - color (optional): Key of `theme.colors` or any valid CSS color, controls `background-color` of the code, by default value is calculated based on color scheme. - darkHidden (boolean; optional): Determines whether component should be hidden in dark color scheme with `display: none`. - data-* (string; optional): Wild card data attributes. - hiddenFrom (string; optional): Breakpoint above which the component is hidden with `display: none`. - lightHidden (boolean; optional): Determines whether component should be hidden in light color scheme with `display: none`. - loading_state (dict; optional): Object that holds the loading state object coming from dash-renderer. For use with dash<3. `loading_state` is a dict with keys: - mod (string | dict | list of string | dicts; optional): Element modifiers transformed into `data-` attributes. For example: "xl" or {"data-size": "xl"}. Can also be a list of strings or dicts for multiple modifiers. Falsy values are removed. - styles (boolean | number | string | dict | list; optional): Adds inline styles directly to inner elements of a component. See Styles API docs. - tabIndex (number; optional): tab-index. - variant (string; optional): variant. - visibleFrom (string; optional): Breakpoint below which the component is hidden with `display: none`.