Style PresetsPRO
A row of style cards; picking one cross-fades the look onto a large preview.
Code
1 file · 209 lines of TypeScriptPRO
Style Presets is part of Pro
Get its source, the one-paste agent prompt and all 113 components, for a one-time $99.
Motion notes
- The new look settles in on top from a slight zoom and blur while the old one holds still underneath, so the preview never dips through a half-transparent frame.
- One selection ring slides between cards on a layout spring (shared layoutId), so the eye follows the choice instead of seeing two rings blink.
- The row scrolls itself to center the selected card, and its edges fade only where more cards are hidden behind them.
- A radio group: arrow keys, Home and End move the choice. With reduced motion the ring jumps and the preview does a short plain cross-fade.
Usage
Example
const [style, setStyle] = useState("original");
<StylePresets
src={image.url}
alt={prompt}
value={style}
onValueChange={setStyle}
/>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| src | string | — | The image to restyle. |
| alt | string | — | Describes the image; the active style is appended for screen readers. |
| presets | StylePreset[] | defaultStylePresets | { id, label, filter } where filter is any CSS filter. |
| value | string | — | Controlled selected preset id. |
| defaultValue | string | — | Starting preset when uncontrolled. Defaults to the first. |
| onValueChange | (id: string) => void | — | Called when a card is picked. |
| focus | string | "50% 50%" | CSS object-position for the preview and thumbnails. |
| className | string | — | Classes for the wrapper; the default is max-w-sm. |
| previewClassName | string | — | Classes for the preview, e.g. a different aspect ratio than 16:10. |
