message
elevenlabs/messageFreeComponent
shadcn/ui publishes no description for this item.
Install it
npx shadcn@latest add https://raw.githubusercontent.com/elevenlabs/ui/main/apps/www/public/r/message.jsonSource
1import type { ComponentProps, HTMLAttributes } from "react"2import { cva, type VariantProps } from "class-variance-authority"34import { cn } from "@/lib/utils"5import {6 Avatar,7 AvatarFallback,8 AvatarImage,9} from "@/components/ui/avatar"1011export type MessageProps = HTMLAttributes<HTMLDivElement> & {12 from: "user" | "assistant"13}1415export const Message = ({ className, from, ...props }: MessageProps) => (16 <div17 className={cn(18 "group flex w-full items-end justify-end gap-2 py-4",19 from === "user" ? "is-user" : "is-assistant flex-row-reverse justify-end",20 className21 )}22 {...props}23 />24)2526const messageContentVariants = cva(27 "is-user:dark flex flex-col gap-2 overflow-hidden rounded-lg text-sm",28 {29 variants: {30 variant: {31 contained: [32 "max-w-[80%] px-4 py-3",33 "group-[.is-user]:bg-primary group-[.is-user]:text-primary-foreground",34 "group-[.is-assistant]:bg-secondary group-[.is-assistant]:text-foreground",35 ],36 flat: [37 "group-[.is-user]:max-w-[80%] group-[.is-user]:bg-secondary group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground",38 "group-[.is-assistant]:text-foreground",39 ],40 },41 },42 defaultVariants: {43 variant: "contained",44 },45 }46)4748export type MessageContentProps = HTMLAttributes<HTMLDivElement> &49 VariantProps<typeof messageContentVariants>5051export const MessageContent = ({52 children,53 className,54 variant,55 ...props56}: MessageContentProps) => (57 <div58 className={cn(messageContentVariants({ variant, className }))}59 {...props}60 >61 {children}62 </div>63)6465export type MessageAvatarProps = ComponentProps<typeof Avatar> & {66 src: string67 name?: string68}6970export const MessageAvatar = ({71 src,72 name,73 className,74 ...props75}: MessageAvatarProps) => (76 <Avatar className={cn("ring-border size-8 ring-1", className)} {...props}>77 <AvatarImage alt="" className="mt-0 mb-0" src={src} />78 <AvatarFallback>{name?.slice(0, 2) || "ME"}</AvatarFallback>79 </Avatar>80)
What it pulls in
npm packages
Other registry items
Files it writes
More from shadcn/ui
All 50 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| audio-playeraudio-player | shadcn/ui | Components | Free | 2 deps | |
| bar-visualizerbar-visualizer | shadcn/ui | Components | Free | no deps | |
| conversationconversation | shadcn/ui | Components | Free | 1 dep | |
| conversation-barconversation-bar | shadcn/ui | Components | Free | 1 dep | |
| live-waveformlive-waveform | shadcn/ui | Components | Free | no deps | |
| matrixmatrix | shadcn/ui | Components | Free | no deps | |
| mic-selectormic-selector | shadcn/ui | Components | Free | no deps | |
| orborb | shadcn/ui | Components | Free | 4 deps |
