Open In Chat
8starlabs-ui/open-in-chatFreeComponent
A component that opens an LLM chat with a pre-filled prompt.
Install it
npx shadcn@latest add https://ui.8starlabs.com/r/open-in-chat.jsonSource
1"use client";23import * as React from "react";4import { ChevronDown, ExternalLink } from "lucide-react";56import {7 ClaudeIcon,8 GrokIcon,9 OpenAIIcon,10 PerplexityIcon,11 V0Icon12} from "@/registry/8starlabs-ui/ui/ai-icons";13import { cn } from "@/lib/utils";14import { Button } from "@/registry/8starlabs-ui/blocks/button";15import {16 DropdownMenu,17 DropdownMenuContent,18 DropdownMenuItem,19 DropdownMenuTrigger20} from "@/registry/8starlabs-ui/ui/dropdown-menu";21import {22 Tooltip,23 TooltipContent,24 TooltipProvider,25 TooltipTrigger26} from "@/registry/8starlabs-ui/ui/tooltip";2728export type AiLinkName = "ChatGPT" | "Claude" | "Perplexity" | "Grok" | "v0";29export type OpenInChatLayout = "dropdown" | "horizontal";3031export type OpenInChatIcon = React.ElementType<React.ComponentProps<"svg">>;3233export type AiLinkData = {34 baseUrl: string;35 paramName?: string;36 icon: OpenInChatIcon;37};3839export type OpenInChatContextValue = {40 prompt: string;41 layout: OpenInChatLayout;42};4344export type OpenInChatBaseProps = Omit<45 React.ComponentPropsWithoutRef<"div">,46 "align"47> & {48 prompt: string;49 triggerLabel?: React.ReactNode;50 triggerClassName?: string;51 contentClassName?: string;52 align?: React.ComponentProps<typeof DropdownMenuContent>["align"];53 side?: React.ComponentProps<typeof DropdownMenuContent>["side"];54};5556export type OpenInChatDropdownProps = OpenInChatBaseProps & {57 layout?: "dropdown";58 trigger?: React.ReactElement | null;59};6061export type OpenInChatHorizontalProps = OpenInChatBaseProps & {62 layout: "horizontal";63 trigger?: never;64};6566export type OpenInChatProps =67 | OpenInChatDropdownProps68 | OpenInChatHorizontalProps;6970export type OpenInChatLinkProps = {71 baseUrl: string;72 paramName?: string;73 icon: OpenInChatIcon;74 label: string;75 prompt?: string;76 className?: string;77};7879const OpenInChatContext = React.createContext<OpenInChatContextValue | null>(80 null81);8283export const aiLinksDataMap: Record<AiLinkName, AiLinkData> = {84 ChatGPT: {85 baseUrl: "https://chatgpt.com/",86 icon: OpenAIIcon87 },88 Claude: {89 baseUrl: "https://claude.ai/new",90 icon: ClaudeIcon91 },92 Perplexity: {93 baseUrl: "https://www.perplexity.ai/search/new",94 icon: PerplexityIcon95 },96 Grok: {97 baseUrl: "https://grok.com/",98 icon: GrokIcon99 },100 v0: {101 baseUrl: "https://v0.app/chat",102 icon: V0Icon103 }104};105106export function getPromptUrl(107 baseUrl: string,108 prompt: string,109 paramName: string = "q"110) {111 const url = new URL(baseUrl);112// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from 8starlabs-ui
All 74 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Buttonbutton | 8starlabs-ui | Components | Free | 2 deps | |
| Collapsiblecollapsible | 8starlabs-ui | Components | Free | 1 dep | |
| Dropdown Menudropdown-menu | 8starlabs-ui | Components | Free | 2 deps | |
| Flip clockflip-clock | 8starlabs-ui | Components | Free | no deps | |
| Heatmapheatmap | 8starlabs-ui | Components | Free | no deps | |
| Inputinput | 8starlabs-ui | Components | Free | no deps | |
| JSON Viewerjson-viewer | 8starlabs-ui | Components | Free | 1 dep · 3 files | |
| Labellabel | 8starlabs-ui | Components | Free | no deps |
