@@ -21,6 +21,10 @@ interface CodeSnippetProps {
2121 icon ?: ReactNode ;
2222 /** Function to format the displayed text (value is still copied as-is) */
2323 formatter ?: ( value : string ) => string ;
24+ /** Enable multiline display (disables truncation, enables word wrap) */
25+ multiline ?: boolean ;
26+ /** Custom aria-label for the copy button */
27+ ariaLabel ?: string ;
2428}
2529
2630export const CodeSnippet = ( {
@@ -30,6 +34,8 @@ export const CodeSnippet = ({
3034 hideCopyButton = false ,
3135 icon,
3236 formatter,
37+ multiline = false ,
38+ ariaLabel = "Copy to clipboard" ,
3339} : CodeSnippetProps ) => {
3440 const [ copied , setCopied ] = useState ( false ) ;
3541
@@ -46,7 +52,7 @@ export const CodeSnippet = ({
4652 type = "button"
4753 onClick = { handleCopy }
4854 className = "text-text-neutral-secondary hover:text-text-neutral-primary shrink-0 cursor-pointer transition-colors"
49- aria-label = "Copy to clipboard"
55+ aria-label = { ariaLabel }
5056 >
5157 { copied ? (
5258 < Check className = "h-3.5 w-3.5" />
@@ -66,7 +72,7 @@ export const CodeSnippet = ({
6672 "hover:bg-bg-neutral-tertiary text-text-neutral-secondary hover:text-text-neutral-primary shrink-0 cursor-pointer rounded-md p-1 transition-colors" ,
6773 className ,
6874 ) }
69- aria-label = "Copy to clipboard"
75+ aria-label = { ariaLabel }
7076 >
7177 { copied ? (
7278 < Check className = "h-3.5 w-3.5" />
@@ -80,19 +86,26 @@ export const CodeSnippet = ({
8086 return (
8187 < div
8288 className = { cn (
83- "bg-bg-neutral-tertiary text-text-neutral-primary border-border-neutral-tertiary flex h-6 w-fit min-w-0 items-center gap-1.5 rounded-full border-2 px-2 py-0.5 text-xs" ,
89+ "bg-bg-neutral-tertiary text-text-neutral-primary border-border-neutral-tertiary flex w-fit min-w-0 items-center gap-1.5 border-2 px-2 py-0.5 text-xs" ,
90+ multiline ? "h-auto rounded-lg" : "h-6 rounded-full" ,
8491 className ,
8592 ) }
8693 >
8794 { icon && (
8895 < span className = "text-text-neutral-secondary shrink-0" > { icon } </ span >
8996 ) }
90- < Tooltip >
91- < TooltipTrigger asChild >
92- < code className = "min-w-0 flex-1 truncate" > { displayValue } </ code >
93- </ TooltipTrigger >
94- < TooltipContent side = "top" > { value } </ TooltipContent >
95- </ Tooltip >
97+ { multiline ? (
98+ < span className = "min-w-0 flex-1 break-all whitespace-pre-wrap" >
99+ { displayValue }
100+ </ span >
101+ ) : (
102+ < Tooltip >
103+ < TooltipTrigger asChild >
104+ < span className = "min-w-0 flex-1 truncate" > { displayValue } </ span >
105+ </ TooltipTrigger >
106+ < TooltipContent side = "top" > { value } </ TooltipContent >
107+ </ Tooltip >
108+ ) }
96109 { ! hideCopyButton && < CopyButton /> }
97110 </ div >
98111 ) ;
0 commit comments