BLACK FRIDAY: 50% OFF all Pro plans Code: BLACKFRIDAY50
Pro from $10 a year or $30 lifetime, no code needed: Code: BLACKFRIDAY50
Ends Cyber Monday, 30 Nov. Lock in the price today. Code: BLACKFRIDAY50
Get 50% Off

Code Block block guide

Free

How to add the Code Block block and what every setting does. It is free in Bright Addons Blocks Library on WordPress.org, and Bright Addons Blocks Pro includes it too.

Start

Add the block

Code with syntax colors, line numbers, highlighted lines, a file name and a copy button.

  1. Install the plugin

    Install Bright Addons Blocks Library from Plugins > Add New (search “Bright Addons Blocks”), or use Blocks Pro, which includes it.
  2. Add the block

    Open a page or post in the block editor, press +, and search for “Code Block”. It is in the Bright Addons category.
  3. Set it up

    Open the block sidebar and work through Code, Lines, Copy button, Look and Colors.
  4. Publish

    Preview the page on desktop, tablet and phone, then publish. The block loads its own CSS and JavaScript only on pages that use it.

Panel 1 of 5

Code

Open the block sidebar and find the Code panel.

Setting What it does Choices
Language Choose one. Plain text, HTML / XML, CSS, SCSS, JavaScript, TypeScript, JSX, TSX, JSON, PHP, Python, Bash / Shell
Code Shown exactly as typed. It is never run. –
File name (optional) Text you type. –
Show the language On or off. –
Language label (optional) Leave empty to use the language name. –

Panel 2 of 5

Lines

Open the block sidebar and find the Lines panel.

Setting What it does Choices
Line numbers On or off. –
First line number From 1 to 100000. –
Highlight lines Line numbers separated by commas. Ranges like 5-7 work too. –
Wrap long lines Off: long lines scroll sideways. –

Panel 3 of 5

Copy button

Open the block sidebar and find the Copy button panel.

Setting What it does Choices
Show the copy button On or off. –
Button text Text you type. –
Text after copying Text you type. –

Panel 4 of 5

Look

Open the block sidebar and find the Look panel.

Setting What it does Choices
Theme Choose one. Dark, Light
Font size (px) From 11 to 22. –
Max height (px) 0 shows all the code. Longer code scrolls inside the box. From 0 to 1200. –

Panel 5 of 5

Colors

Open the block sidebar and find the Colors panel.

Setting What it does Choices
Background Color picker. –
Text Color picker. –
Accent (highlighted lines, functions) Color picker. –

Questions

Good to know

Is the Code Block block free?

Yes. Code Block is one of the 62 free blocks of Bright Addons Blocks Library on WordPress.org. Bright Addons Blocks Pro includes it as well.

Do I need Elementor for this block?

No. It is a block for the WordPress block editor (Gutenberg). Elementor is not needed. If you use Bright Addons Pro for Elementor on the same site, both plugins work side by side.

Will it slow down my pages?

No. Each block loads only its own small CSS and JavaScript, and only on pages where it is used. Blocks you do not need can be switched off in Bright Blocks.

Does it work with my theme?

Yes. The blocks work with block themes and classic themes, and follow your theme fonts. Wide and full width alignment are supported.

Can I animate it?

Yes. Open Entrance animation in the sidebar and pick one of 40 animations with its duration and delay. Visitors who prefer reduced motion see no animation.

Bright Addons Blocks

Build with every block

Blocks Pro adds 99 Pro blocks, Pro effects for every block, Theme Templates and popups to the 62 free blocks.