JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Monaco Editor with TypeScript Definitions</title>
<style>
html, body {
height: 100%;
margin: 0;
display: flex;
justify-content: center;
align-items: center;
background: #f0f0f0; /* Light gray background */
}
#editor {
width: 600px;
height: 300px;
border-radius: 10px; /* Rounded corners */
box-shadow: 0 4px 6px rgba(0,0,0,0.1); /* Drop shadow */
overflow: hidden; /* Ensures the corners remain rounded */
}
</style>
</head>
<body>
<div id="editor"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.30.1/min/vs/loader.js"></script>
<script>
require.config({ paths: { vs: 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.30.1/min/vs' }});
require(['vs/editor/editor.main'], function () {
monaco.editor.defineTheme('darkBlueTheme', {
base: 'vs-dark', // can also be vs (light) or hc-black (high contrast)
inherit: true, // can inherit defaults from the base theme
rules: [
{ token: 'comment', foreground: '6A9955' },
{ token: 'keyword', foreground: '569CD6' },
{ token: 'identifier', foreground: '9CDCFE' },
],
colors: {
'editor.background': '#1E1E1E',
'editor.foreground': '#D4D4D4',
'editor.lineHighlightBackground': '#073642',
'editorLineNumber.foreground': '#0088CC',
'editor.selectionBackground': '#264F78',
'editor.inactiveSelectionBackground': '#3A3D41'
}
});
// Create the Monaco editor
const editor = monaco.editor.create(document.getElementById('editor'), {
value: '// Try typing something from the Flotiq API...\nimport {FlotiqApi} from \'@flotiq/api\'\nconst api = new FlotiqApi(\'YOUR_API_KEY\');\n',
...