Skip to documentation content

Silk

Slow folds of satin with a soft sheen, in one or two colors.

silk-demo

Overview

Silk draws a sheet of satin that folds and gathers slowly. Long folds run across the surface on angle, a soft sheen catches their crests, and the hollows fall into shade. With secondaryColor, the cloth shifts from one color to the other across the folds.

The shading stays low in contrast, so a heading or a short line of copy reads well on top. Use it as the background of a hero, a pricing card, or a sign-in panel. Unlike the line and dot backgrounds, Silk paints the whole surface.

Installation

npm install honestui

Usage

import { Silk } from "honestui/shaders"

<Silk className="h-96" color="#2b3350" secondaryColor="#3b2f4d">
  <div className="grid size-full place-items-center">
    <h2 className="text-3xl font-medium text-white">Made to be touched.</h2>
  </div>
</Silk>

Children render above the cloth. Deep colors with a white sheen give the classic satin look; for a light page, use pale colors and a lower sheen so the highlight does not wash out.

Accessibility

Silk is decorative and its canvas is hidden from assistive technology. Put text and actions in normal HTML, and check text contrast against both the shaded folds and the brightest sheen.

The effect pauses while it is offscreen or the tab is hidden, and shows a still frame when the user prefers reduced motion. Without WebGL the container shows only its own background, so give it a CSS background color close to color.

API Reference

PropTypeDefaultDescription
colorstring"#2b3350"Main color of the cloth. Any CSS color.
secondaryColorstring–Second color blended across the cloth on the fold angle. Defaults to color.
sheenColorstring"#ffffff"Color of the sheen along the fold crests.
sheennumber0.45Strength of the sheen, from 0 (matte) to 1 (glossy).
scalenumber1Size of the folds. Larger values draw more, smaller folds.
depthnumber0.5How deep the folds look, from 0 (flat) to 1 (deep).
softnessnumber0.6How soft the sheen is, from 0 (tight highlight) to 1 (broad glow).
anglenumber-18Direction the folds run, in degrees.
speednumber1Animation speed. 0 holds the cloth still.
pausedbooleanfalseRenders a still frame instead of animating.
classNamestring–Class for sizing and positioning the container.
childrenReactNode–Content rendered above the cloth.