@@ -25,11 +25,19 @@ interface SidebarItemProps {
2525 onDoubleClick ?: ( ) => void ;
2626 onContextMenu ?: ( e : React . MouseEvent ) => void ;
2727 action ?: SidebarItemAction ;
28+ /** Hugs the label but never truncates with it; pushes endContent right. */
29+ badge ?: React . ReactNode ;
2830 endContent ?: React . ReactNode ;
2931 disabled ?: boolean ;
3032}
3133
32- function SidebarItemLabel ( { label } : { label : React . ReactNode } ) {
34+ function SidebarItemLabel ( {
35+ label,
36+ grow,
37+ } : {
38+ label : React . ReactNode ;
39+ grow : boolean ;
40+ } ) {
3341 const canTooltip = typeof label === "string" || typeof label === "number" ;
3442
3543 const measureRef = useCallback ( ( el : HTMLSpanElement | null ) => {
@@ -44,7 +52,7 @@ function SidebarItemLabel({ label }: { label: React.ReactNode }) {
4452 } , [ ] ) ;
4553
4654 const span = (
47- < span ref = { measureRef } className = "min-w-0 flex-1 truncate" >
55+ < span ref = { measureRef } className = { cn ( "min-w-0 truncate" , grow && " flex-1" ) } >
4856 { label }
4957 </ span >
5058 ) ;
@@ -76,6 +84,7 @@ export function SidebarItem({
7684 onClick,
7785 onDoubleClick,
7886 onContextMenu,
87+ badge,
7988 endContent,
8089 disabled,
8190} : SidebarItemProps ) {
@@ -108,7 +117,12 @@ export function SidebarItem({
108117 ) : null }
109118 < span className = "flex min-w-0 flex-1 flex-col" >
110119 < span className = "flex min-h-[18px] items-center gap-1" >
111- < SidebarItemLabel label = { label } />
120+ < SidebarItemLabel label = { label } grow = { ! badge } />
121+ { badge ? (
122+ < span className = "mr-auto ml-1 flex shrink-0 items-center" >
123+ { badge }
124+ </ span >
125+ ) : null }
112126 { endContent }
113127 </ span >
114128 { subtitle ? (
0 commit comments