11import { Tab } from "@material-ui/core" ;
22import { makeStyles } from "@saleor/macaw-ui" ;
33import clsx from "clsx" ;
4+ import { type ReactNode } from "react" ;
45
56const useStyles = makeStyles (
67 theme => ( {
@@ -44,6 +45,18 @@ const useStyles = makeStyles(
4445 marginLeft : theme . spacing ( 0.5 ) ,
4546 flexShrink : 0 ,
4647 } ,
48+ // Slot for a small marker icon (e.g. a pin glyph for pinned tabs). Rendered
49+ // before the label, slightly raised relative to the baseline-aligned label
50+ // so it visually centers with the cap height of the text.
51+ tabLeadingIcon : {
52+ alignSelf : "center" ,
53+ display : "inline-flex" ,
54+ flexShrink : 0 ,
55+ // Inherit the tab's current text color (active vs inactive) but always
56+ // dim the marker so it reads as metadata, not as a primary glyph.
57+ color : theme . palette . text . disabled ,
58+ marginRight : theme . spacing ( 0.75 ) ,
59+ } ,
4760 tabRoot : {
4861 minWidth : "80px" ,
4962 opacity : 1 ,
@@ -62,24 +75,30 @@ interface FilterTabProps {
6275 * Always rendered in a muted color so the label remains the dominant element.
6376 */
6477 count ?: number ;
78+ /**
79+ * Optional small marker rendered before the label. Useful for surfacing
80+ * subtle metadata on a tab (e.g. a pin glyph for pinned tabs, à la Chrome).
81+ * Keep it tiny (≤ 12px) and let the component dim it via `text.disabled`.
82+ */
83+ leadingIcon ?: ReactNode ;
6584 selected ?: boolean ;
6685 value ?: number ;
6786}
6887
6988export const FilterTab = ( props : FilterTabProps ) => {
70- const { onClick, label, count, selected, value } = props ;
89+ const { onClick, label, count, leadingIcon , selected, value } = props ;
7190 const classes = useStyles ( props ) ;
72- const tabContent =
73- count === undefined ? (
74- < span className = { classes . tabContent } title = { label } >
75- < span className = { classes . tabLabelText } > { label } </ span >
76- </ span >
77- ) : (
78- < span className = { classes . tabContent } title = { label } >
79- < span className = { classes . tabLabelText } > { label } </ span >
80- < span className = { classes . tabCount } > ({ count } )</ span >
81- </ span >
82- ) ;
91+ const tabContent = (
92+ < span className = { classes . tabContent } title = { label } >
93+ { leadingIcon && (
94+ < span className = { classes . tabLeadingIcon } aria-hidden = "true" >
95+ { leadingIcon }
96+ </ span >
97+ ) }
98+ < span className = { classes . tabLabelText } > { label } </ span >
99+ { count !== undefined && < span className = { classes . tabCount } > ({ count } )</ span > }
100+ </ span >
101+ ) ;
83102
84103 return (
85104 < Tab
0 commit comments