AI Prompt Suggestion Chips
Categorized quick-prompt suggestion chips with spring physics bounce and one-tap populating.
Preview and code
/*
* MIT License
*
* Copyright (c) 2026 Syed Subhan Uddin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
// AI Prompt Suggestion Chips from amicro by Syed Subhan Uddin
// https://github.com/Subhan-code/Amicro--Micro-transitions-/blob/main/src/components/ai/AiPromptChips.tsx
// MIT License, Copyright (c) 2026 Syed Subhan Uddin. Full licence: https://github.com/Subhan-code/Amicro--Micro-transitions-/blob/main/LICENSE
// Styled with Tailwind CSS. Needs: motion, lucide-react
import React from 'react';
import { motion } from 'motion/react';
import { Sparkles } from 'lucide-react';
import { useWebHaptics } from './use-web-haptics';
export interface AiPromptChipsProps {
theme?: 'dark' | 'light';
onSelectPrompt: (prompt: string) => void;
chips?: Array<{ id: string; label: string; prompt: string; icon?: string }>;
}
const DEFAULT_CHIPS = [
{ id: '1', label: 'Spring Tilt Card', prompt: 'Create an interactive 3D card spread with spring tilt physics on cursor move', icon: '✨' },
{ id: '2', label: 'Particle Burst Button', prompt: 'Add dynamic multi-color particle burst micro-interaction on CTA button click', icon: '💥' },
{ id: '3', label: 'Reasoning Accordion', prompt: 'Build a collapsible AI reasoning trace block with live elapsed timer and status nodes', icon: '🧠' },
{ id: '4', label: 'Magnetic Pill Dock', prompt: 'Design a macOS inspired floating island dock with spring magnetic pull effect', icon: '🧲' },
];
export function AiPromptChips({
theme = 'dark',
onSelectPrompt,
chips = DEFAULT_CHIPS,
}: AiPromptChipsProps) {
const { trigger: triggerHaptic } = useWebHaptics();
const isDark = theme === 'dark';
return (
<div className="w-full flex items-center justify-center select-none py-1">
<div className="flex flex-wrap items-center justify-center gap-2 max-w-[800px]">
{chips.map((chip, index) => (
<motion.button
key={chip.id}
type="button"
initial={{ opacity: 0, y: 8 }}
animate={{ opacity: 1, y: 0 }}
transition={{ delay: index * 0.05, duration: 0.25 }}
whileHover={{ y: -2, scale: 1.03 }}
whileTap={{ scale: 0.96 }}
onClick={() => {
triggerHaptic('light');
onSelectPrompt(chip.prompt);
}}
className={`group inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full text-xs font-medium cursor-pointer border transition-all duration-200 ${
isDark
? 'bg-white/[0.04] border-white/[0.08] hover:border-white/20 hover:bg-white/[0.08] text-neutral-300 hover:text-white'
: 'bg-white border-neutral-200 hover:border-neutral-300 hover:bg-neutral-50 text-neutral-700 hover:text-black shadow-xs'
}`}
>
<span>{chip.icon || '✨'}</span>
<span>{chip.label}</span>
</motion.button>
))}
</div>
</div>
);
}
/*
* MIT License
*
* Copyright (c) 2026 Syed Subhan Uddin
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
import { useCallback, useState, useEffect } from 'react';
export type HapticsType = 'light' | 'medium' | 'heavy' | 'success' | 'warning' | 'error';
let globalAudioCtx: AudioContext | null = null;
let soundEnabled = true;
if (typeof window !== 'undefined') {
try {
const saved = localStorage.getItem('amicro_sound_enabled');
soundEnabled = saved !== null ? saved === 'true' : true;
} catch {
soundEnabled = true;
}
}
function getAudioContext(): AudioContext | null {
if (typeof window === 'undefined') return null;
try {
if (!globalAudioCtx) {
const AudioCtx = window.AudioContext || (window as unknown as { webkitAudioContext: typeof AudioContext }).webkitAudioContext;
if (AudioCtx) {
globalAudioCtx = new AudioCtx();
}
}
if (globalAudioCtx && globalAudioCtx.state === 'suspended') {
globalAudioCtx.resume();
}
return globalAudioCtx;
} catch {
return null;
}
}
function playSynthesizedHaptic(type: HapticsType) {
if (!soundEnabled) return;
const ctx = getAudioContext();
if (!ctx) return;
try {
const now = ctx.currentTime;
const osc = ctx.createOscillator();
const gain = ctx.createGain();
osc.connect(gain);
gain.connect(ctx.destination);
if (type === 'success') {
// Pleasant subtle two-tone chime for copy actions
osc.type = 'sine';
osc.frequency.setValueAtTime(820, now);
osc.frequency.exponentialRampToValueAtTime(1240, now + 0.06);
gain.gain.setValueAtTime(0.035, now);
gain.gain.exponentialRampToValueAtTime(0.0001, now + 0.14);
osc.start(now);
osc.stop(now + 0.14);
} else if (type === 'error') {
osc.type = 'sawtooth';
osc.frequency.setValueAtTime(220, now);
gain.gain.setValueAtTime(0.04, now);
gain.gain.exponentialRampToValueAtTime(0.0001, now + 0.08);
osc.start(now);
osc.stop(now + 0.08);
} else {
// Soft mechanical tactile click
osc.type = 'triangle';
const freq = type === 'medium' ? 1400 : type === 'heavy' ? 1100 : 1750;
osc.frequency.setValueAtTime(freq, now);
osc.frequency.exponentialRampToValueAtTime(freq * 0.5, now + 0.02);
gain.gain.setValueAtTime(0.025, now);
gain.gain.exponentialRampToValueAtTime(0.0001, now + 0.025);
osc.start(now);
osc.stop(now + 0.025);
}
} catch {
// Non-blocking fallback
}
}
export function useWebHaptics() {
const [isSoundOn, setIsSoundOn] = useState(soundEnabled);
useEffect(() => {
setIsSoundOn(soundEnabled);
}, []);
const toggleSound = useCallback(() => {
soundEnabled = !soundEnabled;
setIsSoundOn(soundEnabled);
try {
localStorage.setItem('amicro_sound_enabled', String(soundEnabled));
} catch {}
if (soundEnabled) {
playSynthesizedHaptic('light');
}
}, []);
const trigger = useCallback((type: HapticsType = 'light') => {
// 1. Play synthesized tactile audio
playSynthesizedHaptic(type);
// 2. Trigger hardware vibration on mobile if supported
if (typeof window !== 'undefined' && window.navigator && window.navigator.vibrate) {
try {
switch (type) {
case 'light':
return window.navigator.vibrate(10);
case 'medium':
return window.navigator.vibrate(25);
case 'heavy':
return window.navigator.vibrate(50);
case 'success':
return window.navigator.vibrate([15, 60, 15]);
case 'warning':
return window.navigator.vibrate([30, 60, 30]);
case 'error':
return window.navigator.vibrate([60, 60, 60, 60, 60]);
default:
return window.navigator.vibrate(10);
}
} catch {
return false;
}
}
return true;
}, []);
return { trigger, isSoundOn, toggleSound };
}
Needs: motion
lucide-react
react tailwindcss
Install
npx shadcn@latest add https://ownlyplans.com/r/bhaskar/ai-prompt-chips.json
Adds the React files to components/ownlyplans/ in a project set up with shadcn and Tailwind CSS. Or copy them from the Code tab.
About
Categorized quick-prompt suggestion chips with spring physics bounce and one-tap populating.
A React AI interface piece built with Motion and Tailwind CSS. Open the Preview tab to try it, then copy the code from the Code tab or install it with the shadcn command. Hand this page’s link to Claude or any AI tool and it can read the code straight from the page.
Credit: from the amicro library by Syed Subhan Uddin (https://github.com/Subhan-code/Amicro–Micro-transitions-), shared here under the MIT licence.
MIT License
Copyright (c) 2026 Syed Subhan Uddin
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.