Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <canvas id="canvas" width="500" height="500"></canvas>

<script id="vertexShader" type="x-shader/x-vertex">
  #version 300 es

  in vec4 vertexPosition;

  void main() {
    gl_Position = vertexPosition;

<script id="fragmentShader" type="x-shader/x-fragment">
  #version 300 es
  precision highp float;

  out vec4 fragColor;

  void main() {
    fragColor = vec4(1, 0, 0, 1);


                body {
  text-align: center;
canvas {
  max-width: 100vw; 
  max-height: 100vh;


                // Requires a WebGL2-compatible browser:
// Confirm your compatibility:
// Older versions of Safari (iOS/MacOS) may need to enable WebGL2 under "Experimental Features"

// More WebGL2 demos:

const gl = canvas.getContext("webgl2");
if (!gl) throw "WebGL2 not supported";

// Creating the two shaders is repetitive and will be refactored 
// into a createShader() function in the next demo:
const vs = gl.createShader(gl.VERTEX_SHADER);
gl.shaderSource(vs, vertexShader.textContent.trim());
if (!gl.getShaderParameter(vs, gl.COMPILE_STATUS)) {
  throw gl.getShaderInfoLog(vs);

const fs = gl.createShader(gl.FRAGMENT_SHADER);
gl.shaderSource(fs, fragmentShader.textContent.trim());
if (!gl.getShaderParameter(fs, gl.COMPILE_STATUS)) {
  throw gl.getShaderInfoLog(fs);

const program = gl.createProgram();
gl.attachShader(program, vs);
gl.attachShader(program, fs);
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
  throw gl.getProgramInfoLog(program);

const vertices = [
  [-1, -1, 0],
  [1, -1, 0],
  [1, 1, 0],
gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer());
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices.flat()), gl.STATIC_DRAW);

const vertexPosition = gl.getAttribLocation(program, "vertexPosition");
gl.vertexAttribPointer(vertexPosition, 3, gl.FLOAT, false, 0, 0);

gl.drawArrays(gl.TRIANGLES, 0, vertices.length);