Code Block Nodes
plate/code-block-nodeFreeComponent
A code block with syntax highlighting and language selection.
Live preview
live · rendered by the registry
Rendered by plate on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://platejs.org/r/code-block-node.jsonSource
1'use client';23import * as React from 'react';45import { formatCodeBlock, isLangSupported } from '@platejs/code-block';6import { BracesIcon, Check, CheckIcon, CopyIcon } from 'lucide-react';7import { type TCodeBlockElement, type TCodeSyntaxLeaf, NodeApi } from 'platejs';8import {9 type PlateElementProps,10 type PlateLeafProps,11 PlateElement,12 PlateLeaf,13} from 'platejs/react';14import { useEditorRef, useElement, useReadOnly } from 'platejs/react';1516import { Button } from '@/components/ui/button';17import {18 Command,19 CommandEmpty,20 CommandGroup,21 CommandInput,22 CommandItem,23 CommandList,24} from '@/components/ui/command';25import {26 Popover,27 PopoverContent,28 PopoverTrigger,29} from '@/components/ui/popover';30import { cn } from '@/lib/utils';3132type CodeBlockElementProps = PlateElementProps<TCodeBlockElement> & {33 showLanguageLabel?: boolean;34};3536const codeBlockLanguages: { label: string; value: string }[] = [37 { label: 'Auto', value: 'auto' },38 { label: 'Plain Text', value: 'plaintext' },39 { label: 'ABAP', value: 'abap' },40 { label: 'Agda', value: 'agda' },41 { label: 'Arduino', value: 'arduino' },42 { label: 'ASCII Art', value: 'ascii' },43 { label: 'Assembly', value: 'x86asm' },44 { label: 'Bash', value: 'bash' },45 { label: 'BASIC', value: 'basic' },46 { label: 'BNF', value: 'bnf' },47 { label: 'C', value: 'c' },48 { label: 'C#', value: 'csharp' },49 { label: 'C++', value: 'cpp' },50 { label: 'Clojure', value: 'clojure' },51 { label: 'CoffeeScript', value: 'coffeescript' },52 { label: 'Coq', value: 'coq' },53 { label: 'CSS', value: 'css' },54 { label: 'Dart', value: 'dart' },55 { label: 'Dhall', value: 'dhall' },56 { label: 'Diff', value: 'diff' },57 { label: 'Docker', value: 'dockerfile' },58 { label: 'EBNF', value: 'ebnf' },59 { label: 'Elixir', value: 'elixir' },60 { label: 'Elm', value: 'elm' },61 { label: 'Erlang', value: 'erlang' },62 { label: 'F#', value: 'fsharp' },63 { label: 'Flow', value: 'flow' },64 { label: 'Fortran', value: 'fortran' },65 { label: 'Gherkin', value: 'gherkin' },66 { label: 'GLSL', value: 'glsl' },67 { label: 'Go', value: 'go' },68 { label: 'GraphQL', value: 'graphql' },69 { label: 'Groovy', value: 'groovy' },70 { label: 'Haskell', value: 'haskell' },71 { label: 'HCL', value: 'hcl' },72 { label: 'HTML', value: 'html' },73 { label: 'Idris', value: 'idris' },74 { label: 'Java', value: 'java' },75 { label: 'JavaScript', value: 'javascript' },76 { label: 'JSON', value: 'json' },77 { label: 'Julia', value: 'julia' },78// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from plate
All 324 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| ai-kitai-kit | plate | Components | Free | 1 dep | |
| AI Menuai-menu | plate | Components | Free | 5 deps · 2 files | |
| AI Leafai-node | plate | Components | Free | no deps | |
| AI Toolbar Buttonai-toolbar-button | plate | Components | Free | 1 dep | |
| align-base-kitalign-base-kit | plate | Components | Free | 1 dep | |
| align-kitalign-kit | plate | Components | Free | 1 dep | |
| Align Toolbar Buttonalign-toolbar-button | plate | Components | Free | 1 dep | |
| autoformat-classic-kitautoformat-classic-kit | plate | Components | Free | 2 deps |
