| Name | Type | Description | Default |
|---|---|---|---|
| disabled | boolean | If true, the component will be disabled. When mode is "dismissible", the chip cannot be disabled. | false |
| label | string | Text to be placed on the chip. When using an avatar as prefix or when mode is "dismissible", the label is required to ensure proper accessibility. | - |
New mode | "selectable" | "dismissible" | Determines the visual style and functionality of the chip. Available modes are:
| "selectable" |
New onClick | () => void | Function to be called when the chip is clicked or the dismiss action is triggered. | - |
New prefix | | string
| SVG
| AvatarPropsbeing {
color: 'primary' | 'secondary' | 'tertiary'
| 'success' | 'info' | 'neutral' | 'warning'
| 'error';
icon?: string | SVG;
imgSrc?: string;
profileName?: string;
}; | Material Symbol name or SVG element used as the icon. When using Material Symbols, replace spaces with underscores. By default, symbols are outlined; to use the filled version, prefix the symbol name with "filled_". If a string or SVG is provided, it will be rendered as an icon placed before the chip label. If an avatar props object is provided, a DxcAvatar will be displayed to the left of the label. | - |
New selected | boolean | If true, the component will be selected. If undefined, the component manages its own internal state (uncontrolled mode). This property is only applicable when the mode is "selectable". | - |
| tabIndex | number | Value of the tabindex attribute applied to the component when mode is "selectable" and clear icon when mode is "dismissible". | 0 |
() => { const [selectedFilters, setSelectedFilters] = useState({ sports: true, art: false, music: false, reading: false, }); const filters = [ { key: "sports", label: "Sports", icon: "fitness_center" }, { key: "art", label: "Art", icon: "palette" }, { key: "music", label: "Music", icon: "music_note" }, { key: "reading", label: "Reading", icon: "menu_book" }, ]; const handleToggle = (key) => { setSelectedFilters((prev) => ({ ...prev, [key]: !prev[key] })); }; return ( <DxcInset space="var(--spacing-padding-xl)"> <DxcFlex direction="column" gap="var(--spacing-gap-l)"> <DxcFlex gap="var(--spacing-gap-m)" wrap="wrap"> {filters.map((filter) => ( <DxcChip key={filter.key} prefix={filter.icon} label={filter.label} selected={selectedFilters[filter.key]} onClick={() => handleToggle(filter.key)} /> ))} </DxcFlex> <ActivitiesTable selectedFilters={selectedFilters} /> </DxcFlex> </DxcInset> ); }
() => { const [selectedOptions, setSelectedOptions] = useState([options[0], options[2]]); const handleDismiss = (valueToRemove) => { setSelectedOptions(selectedOptions.filter(opt => opt.value !== valueToRemove)); }; return ( <DxcInset space="var(--spacing-padding-xl)"> <DxcFlex direction="column" gap="var(--spacing-gap-m)"> <TransportSelect selectedOptions={selectedOptions} onChange={setSelectedOptions} /> {selectedOptions.length > 0 && ( <DxcFlex gap="var(--spacing-gap-s)" wrap="wrap"> {selectedOptions.map((option) => ( <DxcChip key={option.value} mode="dismissible" label={option.label} prefix={option.icon} onClick={() => handleDismiss(option.value)} /> ))} </DxcFlex> )} </DxcFlex> </DxcInset> ); }