Control panels · component · 17K

Pattern editor

The desktop-pattern editor from a General Controls panel: an 8×8 fat-bits grid you click or drag to paint, a live preview tile, ◂ ▸ to step through the theme's patterns and "Set Desktop", which hands you { bits, css }: eight rows of "#"/"." and a ready 8×8 SVG data-URI tile.

The grid is one Tab stop (role="grid") of toggle buttons named by row and column: arrow keys move the cursor, Home/End jump to the ends of a row, Space or Enter flips a dot. A drag paints with the colour of the first dot pressed; a click is its single-pointer equivalent. Apply the result with style={{ "--s7-desktop-pattern": pattern.css }} on <Desktop>. patternToCss(bits, color?) and cssToBits(css) convert both ways (cssToBits reads its own tiles and the theme's <rect> tiles); PATTERN_PRESETS holds the bits of the theme's --s7-pattern-* tiles. Cells grow to 16px with comfortable density and 24px on coarse pointers.

Install

pnpm dlx shadcn@latest add @s7ui/pattern-editor

Example

This example also uses @s7ui/desktop @s7ui/window.

Weave, 12 of 64 dots

Arrow keys move, Space turns a dot on or off.

###.#...
....#...
....#...
........
#...###.
#.......
#.......
........

Info

Files:
components/retro/pattern-editor.tsx
Uses:
@s7ui/theme, @s7ui/bitmap, @s7ui/button
Packages:
—