Parallelogram

평행사변형

A parallelogram with adjustable width, height, and top-edge skew.

Also known as: ParallelogramSlanted rectangle

Moves in browsers that support WebGPU

This device could not render the demo — showing a still

React
// Renders only in browsers with WebGPU.
import { Shader, Parallelogram } from 'shaders/react'

export default function ShaderEffect() {
  return (
    <Shader style={{ width: '100%', height: 320 }} disableTelemetry>
      <Parallelogram />
    </Shader>
  )
}
Vue
<!-- Renders only in browsers with WebGPU. -->
<script setup lang="ts">
import { Shader, Parallelogram } from 'shaders/vue'
</script>

<template>
  <Shader style="width: 100%; height: 320px" :disable-telemetry="true">
    <Parallelogram/>
  </Shader>
</template>
Svelte
<!-- Renders only in browsers with WebGPU. -->
<script>
  import { Shader, Parallelogram } from 'shaders/svelte'
</script>

<Shader style="width: 100%; height: 320px" disableTelemetry>
  <Parallelogram />
</Shader>
Solid
// Renders only in browsers with WebGPU.
import { Shader, Parallelogram } from 'shaders/solid'

export default function ShaderEffect() {
  return (
    <Shader style={{ width: '100%', height: '320px' }} disableTelemetry>
      <Parallelogram />
    </Shader>
  )
}
JavaScript
// Renders only in browsers with WebGPU.
// expects <canvas id="canvas" style="width:100%;height:320px"></canvas> on the page
import { createShader } from 'shaders/js'

const shader = await createShader(document.getElementById("canvas"), {
  components: [
    {
      type: 'Parallelogram',
    }
  ]
}, { disableTelemetry: true })

Props · Parallelogram

Changes apply to the demo above and to the code tabs. Descriptions come from the library registry (MIT).

NameValueDefaultRange / optionsDescription
originOriginSet in codecenter—Reference edge the center position is measured from (center default). Lets you pin the shape relative to a corner or the canvas centre.
colorColor#ffffff—Fill color of the parallelogram
centerCenter
x0.5y0.5
{"x":0.5,"y":0.5}x, y: 0 – 1Center position of the parallelogram
widthWidth0.320.02 – 1 (step 0.01)Half-width of the parallelogram
heightHeight0.220.02 – 1 (step 0.01)Half-height of the parallelogram
skewSkew0.15-0.4 – 0.4 (step 0.01)Horizontal skew of the top edge
rotationRotation00 – 360 (step 1)Rotation in degrees
softnessSoftness00 – 0.1 (step 0.001)Edge softness for antialiasing
strokeThicknessStroke Thickness00 – 0.2 (step 0.005)Stroke thickness. Zero means no stroke.
strokeColorStroke Color#000000—Color of the stroke outline
strokePositionStroke Positioncenteroutside · center · insidePosition of the stroke relative to the shape edge
colorSpaceColor Blendinglinearlinear · oklch · oklab · hsl · hsv · lchColor space for blending fill and stroke colors

Every component also takes blendMode · opacity · visible · maskSource/maskType · boundingBox · id

A parallelogram is a shifted rectangle whose opposite sides stay parallel. It adds direction to a slanted label or a speed-inspired background panel.

`width` and `height` are half-sizes, each from 0.02 to 1. `skew` tilts the top edge horizontally from -0.4 to 0.4, while `rotation` turns the whole shape from 0 to 360 degrees.

`skew` changes one edge's slant, while `rotation` turns the entire shape. Place it beside `Trapezoid` to compare slant with changing edge widths, and check the slanted edge and text spacing when using it behind a label.

When to use

Use it for slanted labels, banners, or speed-inspired panels. It creates a directional surface compared with a rectangle. Avoid it when the top and bottom widths must differ or when a card needs vertical alignment.

Open as page ↗