Suggestions
Show quick prompt chips and write the selected suggestion into InputBar for fast message drafting. Use disabled to pause interaction and item.className for per-chip styling.
Getting Started
$pnpm add @sinups/ai-kit @mantine/core @mantine/hooks @tabler/icons-reactExamples
Icons + text
Fill InputBar
Source
The component source as it ships in the package. Useful as a reference, or as a starting point if you want to fork a piece.
input/Suggestions.tsx
import React from 'react';
import { Box, UnstyledButton } from '@mantine/core';
import { cx } from '../utils/cx';
import classes from './Suggestions.module.css';
export type SuggestionItem = {
id: string;
label: string;
/** Text inserted into the composer, `label` is used when omitted */
value?: string;
icon?: React.ReactNode;
className?: string;
};
export interface SuggestionsProps {
items: SuggestionItem[];
onSelect: (item: SuggestionItem) => void;
disabled?: boolean;
className?: string;
/** Class name applied to every suggestion chip */
itemClassName?: string;
style?: React.CSSProperties;
}
/** Row of clickable suggestion chips shown under the composer or in the empty state */
export function Suggestions({
items,
onSelect,
disabled,
className,
itemClassName,
style,
}: SuggestionsProps) {
if (items.length === 0) {
return null;
}
return (
<Box className={cx(classes.root, className)} style={style}>
{items.map((item) => (
<UnstyledButton
key={item.id}
disabled={disabled}
onClick={() => onSelect(item)}
className={cx(classes.item, itemClassName, item.className)}
>
{item.icon && <span className={classes.icon}>{item.icon}</span>}
{item.label}
</UnstyledButton>
))}
</Box>
);
}
Suggestions.displayName = 'Suggestions';
API reference
Prop
Type
Required
items
SuggestionItem[]
Yes
onSelect
(item: SuggestionItem) => void
Yes
disabled
boolean
No
className
string
No
itemClassName
string
No
Class name applied to every suggestion chip
style
React.CSSProperties
No