Star

별

A pointed star with adjustable point count and inner depth.

Also known as: StarStar polygon

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, Star } from 'shaders/react'

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

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

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

export default function ShaderEffect() {
  return (
    <Shader style={{ width: '100%', height: '320px' }} disableTelemetry>
      <Star />
    </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: 'Star',
    }
  ]
}, { disableTelemetry: true })

Props · Star

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 star
centerCenter
x0.5y0.5
{"x":0.5,"y":0.5}x, y: 0 – 1Center position of the star
radiusRadius0.40 – 1 (step 0.01)Outer tip radius — distance from center to the pointed tips
sidesPoints53 – 12 (step 1)Number of points on the star
innerRatioInner Ratio0.40.1 – 0.9 (step 0.01)Inner vertex radius as a ratio of outer radius (0.382 = golden-ratio 5-star)
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 star alternates between outer tips and inner vertices. It is a familiar silhouette for anything from rating marks to sparkle badges, making an emphasis easy to recognize.

`sides` sets the number of star points from 3 to 12. `radius` measures the distance to the outer tips from 0 to 1, while `innerRatio` sets the inner-vertex radius as a proportion from 0.1 to 0.9. `rotation` changes the orientation from 0 to 360 degrees.

A lower `innerRatio` makes deeper notches; a higher value makes the star fuller. The points can look crowded in a tiny badge, so give the shape enough size and contrast, and compare its silhouette alongside `Polygon`.

When to use

Use it for visible accents such as favorites, ratings, and promotion badges. It also works for star-shaped decoration or repeating patterns. Avoid it in UI where the points will not read at a very small size.

Open as page ↗