Create custom renderers
Stay organized with collections
Save and categorize content based on your preferences.
To create a custom renderer, you need to subclass the Renderer
class. Refer to the renderer concept docs for more
information about what a renderer is and what it does.
class CustomRenderer extends Blockly.blockRendering.Renderer {
constructor() {
super();
}
}
Without any customization, the default renderer looks like this:
You can also subclass one of the other built-in renderers
and then override parts of it.
class CustomRenderer extends Blockly.thrasos.Renderer {
constructor() {
super();
}
}
Subclass other renderer components
The actual shape of the block is determined by the
subcomponents of the renderer.
By default, the Renderer
class provides working versions of
all the renderer components. This lets you modify a
single component, without having to worry about the others.
For example, if you want to
change the shapes of connections, you can override the
constants without having to touch the other components.
Check out the renderer component docs for more
information about what each individual component does.
Override factory methods
After subclassing the renderer components, you need to
override the Renderer
's factory methods for the components you
subclassed. This lets the renderer properly wire the different components
together.
There is a method for each kind of component:
Register the renderer
Finally, once you've completed the creation of your custom renderer, you need to
register it. This associates the renderer with a string so that you can pass it
to your configuration options.
Blockly.blockRendering.register('custom_renderer', CustomRenderer);
const workspace = Blockly.inject(blocklyDiv, {
renderer: 'custom_renderer',
});
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-06-13 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-06-13 UTC."],[[["\u003cp\u003eTo create custom renderers in Blockly, you need to subclass the \u003ccode\u003eRenderer\u003c/code\u003e class and potentially its subcomponents like constants, render info, path objects, and drawers.\u003c/p\u003e\n"],["\u003cp\u003eCustom renderers allow you to change the visual appearance of blocks, including connection shapes and overall block structure, by overriding factory methods for specific components.\u003c/p\u003e\n"],["\u003cp\u003eAfter creating the custom renderer, register it with a unique string using \u003ccode\u003eBlockly.blockRendering.register()\u003c/code\u003e to use it within your workspace configuration.\u003c/p\u003e\n"],["\u003cp\u003eBefore starting with custom renderers, it's recommended to review the renderer concept documentation and complete the custom renderers codelab for foundational knowledge.\u003c/p\u003e\n"]]],[],null,["# Create custom renderers\n\n| **Note:** If you haven't read through the [renderer concept docs](/blockly/guides/create-custom-blocks/renderers/concepts/renderer) or completed the [custom renderers codelab](https://blocklycodelabs.dev/codelabs/custom-renderer/index.html) we recommend doing those first!\n\nTo create a custom renderer, you need to subclass the [`Renderer`](/blockly/reference/js/blockly.blockrendering_namespace.renderer_class)\nclass. Refer to the [renderer concept docs](/blockly/guides/create-custom-blocks/renderers/concepts/renderer) for more\ninformation about what a renderer is and what it does. \n\n class CustomRenderer extends Blockly.blockRendering.Renderer {\n constructor() {\n super();\n }\n }\n\nWithout any customization, the default renderer looks like this:\n\nYou can also subclass one of the other [built-in renderers](/blockly/guides/create-custom-blocks/renderers/overview#built-in_renderers)\nand then override parts of it. \n\n class CustomRenderer extends Blockly.thrasos.Renderer {\n constructor() {\n super();\n }\n }\n\nSubclass other renderer components\n----------------------------------\n\nThe actual shape of the block is determined by the\n[subcomponents](/blockly/guides/create-custom-blocks/renderers/concepts/overview) of the renderer.\n\nBy default, the [`Renderer`](/blockly/reference/js/blockly.blockrendering_namespace.renderer_class) class provides working versions of\nall the [renderer components](/blockly/guides/create-custom-blocks/renderers/concepts/overview). This lets you modify a\nsingle component, without having to worry about the others.\n\nFor example, if you want to\n[change the shapes of connections](/blockly/guides/create-custom-blocks/renderers/create-custom-renderers/connection-shapes), you can override the\n[constants](/blockly/guides/create-custom-blocks/renderers/concepts/constants) without having to touch the other components.\n\nCheck out the [renderer component docs](/blockly/guides/create-custom-blocks/renderers/concepts/overview) for more\ninformation about what each individual component does.\n\nOverride factory methods\n------------------------\n\nAfter subclassing the [renderer components](/blockly/guides/create-custom-blocks/renderers/concepts/overview), you need to\noverride the [`Renderer`](/blockly/reference/js/blockly.blockrendering_namespace.renderer_class)'s factory methods for the components you\nsubclassed. This lets the renderer properly wire the different components\ntogether.\n\nThere is a method for each kind of component:\n\n- [`makeConstants_`](/blockly/reference/js/blockly.blockrendering_namespace.renderer_class.makeconstants__1_method)\n- [`makeRenderInfo_`](/blockly/reference/js/blockly.blockrendering_namespace.renderer_class.makerenderinfo__1_method)\n- [`makePathObject`](/blockly/reference/js/blockly.blockrendering_namespace.renderer_class.makepathobject_1_method) (note there is no underscore)\n- [`makeDrawer_`](/blockly/reference/js/blockly.blockrendering_namespace.renderer_class.makedrawer__1_method)\n\nRegister the renderer\n---------------------\n\nFinally, once you've completed the creation of your custom renderer, you need to\nregister it. This associates the renderer with a string so that you can pass it\nto your [configuration options](/blockly/guides/configure/web/configuration_struct). \n\n Blockly.blockRendering.register('custom_renderer', CustomRenderer);\n\n const workspace = Blockly.inject(blocklyDiv, {\n renderer: 'custom_renderer',\n });"]]