suggestion

PreviousNext
Docs
takiui

Preview

Loading preview…
registry/new-york/ai-elements/suggestion.tsx
"use client"

import type { ComponentProps } from "react"

import { cn } from "@/lib/utils"
import { Button } from "@/registry/new-york/ui/button"

export type SuggestionsProps = ComponentProps<"div">

export const Suggestions = ({
  className,
  children,
  ...props
}: SuggestionsProps) => (
  <div className="w-full overflow-x-auto whitespace-nowrap" {...props}>
    <div className={cn("flex w-max flex-nowrap items-center gap-2", className)}>
      {children}
    </div>
  </div>
)

export type SuggestionProps = Omit<ComponentProps<typeof Button>, "onClick"> & {
  suggestion: string
  onClick?: (suggestion: string) => void
}

export const Suggestion = ({
  suggestion,
  onClick,
  className,
  variant = "outline",
  size = "sm",
  children,
  ...props
}: SuggestionProps) => {
  const handleClick = () => {
    onClick?.(suggestion)
  }

  return (
    <Button
      className={cn("rounded-full px-4", className)}
      onPress={handleClick}
      size={size}
      type="button"
      variant={variant}
      {...props}
    >
      {children || suggestion}
    </Button>
  )
}

Installation

npx shadcn@latest add @taki/suggestion

Usage

import { Suggestion } from "@/components/ui/suggestion"
<Suggestion />