File tree 4 files changed +69
-0
lines changed
libs/react-client/src/types
4 files changed +69
-0
lines changed Original file line number Diff line number Diff line change 143
143
# Be careful: If this is a relative path, it should not start with a slash.
144
144
# custom_build = "./public/build"
145
145
146
+ # Specify optional one or more custom links in the header.
147
+ # [[UI.header_links]]
148
+ # name = "Issues"
149
+ # icon_url = "https://avatars.githubusercontent.com/u/128686189?s=200&v=4"
150
+ # url = "https://github.com/Chainlit/chainlit/issues"
151
+
146
152
[meta]
147
153
generated_by = "{ __version__ } "
148
154
"""
@@ -214,6 +220,13 @@ class FeaturesSettings(DataClassJsonMixin):
214
220
edit_message : bool = True
215
221
216
222
223
+ @dataclass
224
+ class HeaderLink (DataClassJsonMixin ):
225
+ name : str
226
+ icon_url : str
227
+ url : str
228
+
229
+
217
230
@dataclass ()
218
231
class UISettings (DataClassJsonMixin ):
219
232
name : str
@@ -230,6 +243,8 @@ class UISettings(DataClassJsonMixin):
230
243
custom_meta_image_url : Optional [str ] = None
231
244
# Optional custom build directory for the frontend
232
245
custom_build : Optional [str ] = None
246
+ # Optional header links
247
+ header_links : Optional [List [HeaderLink ]] = None
233
248
234
249
235
250
@dataclass ()
Original file line number Diff line number Diff line change
1
+ import { useContext } from 'react' ;
2
+
3
+ import { ChainlitContext } from '@chainlit/react-client' ;
4
+
5
+ import { Button } from '@/components/ui/button' ;
6
+ import {
7
+ Tooltip ,
8
+ TooltipContent ,
9
+ TooltipProvider ,
10
+ TooltipTrigger
11
+ } from '@/components/ui/tooltip' ;
12
+
13
+ export interface ButtonLinkProps {
14
+ name ?: string ;
15
+ iconUrl ?: string ;
16
+ url : string ;
17
+ }
18
+
19
+ export default function ButtonLink ( { name, iconUrl, url } : ButtonLinkProps ) {
20
+ const apiClient = useContext ( ChainlitContext ) ;
21
+ return (
22
+ < TooltipProvider >
23
+ < Tooltip >
24
+ < TooltipTrigger asChild >
25
+ < Button
26
+ variant = "ghost"
27
+ size = "icon"
28
+ className = "text-muted-foreground hover:text-muted-foreground"
29
+ >
30
+ < a href = { url } target = "_blank" >
31
+ < img
32
+ src = {
33
+ iconUrl ?. startsWith ( '/public' )
34
+ ? apiClient . buildEndpoint ( iconUrl )
35
+ : iconUrl
36
+ }
37
+ className = { 'h-6 w-6' }
38
+ alt = { name }
39
+ />
40
+ </ a >
41
+ </ Button >
42
+ </ TooltipTrigger >
43
+ < TooltipContent > { name } </ TooltipContent >
44
+ </ Tooltip >
45
+ </ TooltipProvider >
46
+ ) ;
47
+ }
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import { useNavigate } from 'react-router-dom';
4
4
import { useAudio , useAuth , useConfig } from '@chainlit/react-client' ;
5
5
6
6
import AudioPresence from '@/components/AudioPresence' ;
7
+ import ButtonLink from '@/components/ButtonLink' ;
7
8
import { useSidebar } from '@/components/ui/sidebar' ;
8
9
9
10
import ApiKeys from './ApiKeys' ;
@@ -25,6 +26,8 @@ const Header = memo(() => {
25
26
26
27
const historyEnabled = data ?. requireLogin && config ?. dataPersistence ;
27
28
29
+ const links = config ?. ui ?. header_links || [ ] ;
30
+
28
31
return (
29
32
< div
30
33
className = "p-3 flex h-[60px] items-center justify-between gap-2 relative"
@@ -59,6 +62,9 @@ const Header = memo(() => {
59
62
< div className = "flex items-center gap-1" >
60
63
< ReadmeButton />
61
64
< ApiKeys />
65
+ { links && (
66
+ links . map ( link => < ButtonLink name = { link . name } iconUrl = { link . icon_url } url = { link . url } /> )
67
+ ) }
62
68
< ThemeToggle />
63
69
< UserNav />
64
70
</ div >
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ export interface IChainlitConfig {
39
39
custom_js ?: string ;
40
40
custom_font ?: string ;
41
41
custom_meta_image_url ?: string ;
42
+ header_links ?: { name : string ; icon_url : string , url : string } [ ] ;
42
43
} ;
43
44
features : {
44
45
spontaneous_file_upload ?: {
You can’t perform that action at this time.
0 commit comments