Suggestions
nexus-ui/suggestionsFreeComponent
Prompt suggestion chips for guiding user input
Live preview
live · rendered by the registry
Rendered by nexus-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://nexus-ui.dev/r/suggestions.jsonSource
1"use client";23import * as React from "react";4import { Presence } from "@radix-ui/react-presence";5import { Slot } from "@radix-ui/react-slot";67import { cva, type VariantProps } from "class-variance-authority";89import { cn } from "@/lib/utils";10import { Button } from "@/components/ui/button";1112const suggestionVariants = cva(13 "h-8 gap-1.5 rounded-full px-4 text-sm font-normal shadow-none outline-0 transition-all duration-150 focus-visible:ring-2 focus-visible:ring-ring active:scale-[0.99]",14 {15 variants: {16 variant: {17 filled:18 "border-none bg-muted text-primary hover:bg-border",19 outline:20 "border border-input bg-transparent text-primary hover:bg-muted",21 ghost:22 "border-none bg-transparent text-muted-foreground hover:bg-muted hover:text-primary",23 },24 },25 defaultVariants: {26 variant: "filled",27 },28 },29);3031type SuggestionsContextValue = {32 onSelect?: (value: string) => void;33};3435const SuggestionsContext = React.createContext<SuggestionsContextValue>({});3637type SuggestionsProps = Omit<38 React.HTMLAttributes<HTMLDivElement>,39 "onSelect"40> & {41 onSelect?: (value: string) => void;42};4344function Suggestions({ className, onSelect, ...props }: SuggestionsProps) {45 return (46 <SuggestionsContext.Provider value={{ onSelect }}>47 <div48 data-slot="suggestions"49 role="group"50 aria-label="Suggestions"51 className={cn("flex flex-col gap-2", className)}52 {...props}53 />54 </SuggestionsContext.Provider>55 );56}5758type SuggestionListProps = React.HTMLAttributes<HTMLDivElement> & {59 orientation?: "horizontal" | "vertical";60};6162function SuggestionList({63 className,64 orientation = "horizontal",65 ...props66}: SuggestionListProps) {67 return (68 <div69 data-slot="suggestion-list"70 role="group"71 aria-label="Suggestions"72 className={cn(73 "flex gap-2 duration-150",74 orientation === "horizontal"75 ? "flex-row flex-wrap items-center justify-center"76 : "flex-col items-start",77 className,78 )}79 {...props}80 />81 );82}8384type SuggestionProps = Omit<React.ComponentProps<typeof Button>, "variant"> &85 VariantProps<typeof suggestionVariants> & {86 value?: string;87 highlight?: string | string[];88 };8990function highlightText(91 text: string,92 terms: string | string[],93): React.ReactNode {94 const termList = Array.isArray(terms) ? terms : [terms];95// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from nexus-ui
All 15 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Attachmentsattachments | nexus-ui | Components | Free | 4 deps · 2 files | |
| Chain of Thoughtchain-of-thought | nexus-ui | Components | Free | 2 deps · 2 files | |
| Citationcitation | nexus-ui | Components | Free | 4 deps | |
| Feedback Barfeedback-bar | nexus-ui | Components | Free | 1 dep | |
| Imageimage | nexus-ui | Components | Free | 2 deps | |
| Messagemessage | nexus-ui | Components | Free | 9 deps · 2 files | |
| Model Selectormodel-selector | nexus-ui | Components | Free | 3 deps | |
| Prompt Inputprompt-input | nexus-ui | Components | Free | 1 dep |
