Iron Filings
Web (React)
A field of fine ink filings that turn to face the pointer, like iron around a lodestone.
A field of fine filings in alternating ink and accent. It renders a CSS grid of simple <span> elements and uses a single window event listener to calculate the geometric angle (using Math.acos()) from each line to your mouse, applying the rotation via CSS custom properties.
Installation
CLI
npx @modus-ui/cli add iron-filingsManual
- Copy the code from the component tab.
- Create a file at
components/ui/iron-filings.tsx. - Paste the code.
Usage
tsx
Props
| Prop | Type | Default | Description |
|---|---|---|---|
rows | number | 13 | Number of rows of lines. |
columns | number | 13 | Number of columns of lines. |
containerSize | string | "70vmin" | CSS size of the square container. |
lineColor | string | "hsl(var(--foreground))" | Colour of the lines. |
lineWidth | string | "0.4vmin" | CSS width of each line. |
lineHeight | string | "3.6vmin" | CSS length of each line. |
baseAngle | number | 45 | Resting rotation of the lines in degrees. |
Comments