We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Change individual chip color

Is it possible to set some property (ex. background) for individual chips? I need to have different chips colors inside one group.

1 Reply

HM Hemalatha Marikumar Syncfusion Team November 26, 2019 07:04 AM UTC

Hi Artur, 
  
Greeting from Syncfusion. 
  
You can achieve your requirement by using the ItemTemplate support for SfChipGroup and BackgroundColor property of SfChip. Please refer the below code. 
  
Code Snippet [XAML]: 
<syncfusion:SfChipGroup.ItemTemplate> 
    <DataTemplate> 
        <StackLayout> 
            <syncfusion:SfChip Text="{Binding Name}" BackgroundColor="{Binding ChipColor}"/> 
        </StackLayout> 
    </DataTemplate> 
</syncfusion:SfChipGroup.ItemTemplate> 
  
Code Snippet [C#]: Model class 
public class Model 
{ 
    public string Name { getset; } 
  
    public Color ChipColor { getset; } 
} 
  
Code Snippet [C#]: Viewmodel 
public class ViewModel : INotifyPropertyChanged 
{ 
    public ObservableCollection<Model> Employees 
    { 
        . . . 
    } 
    
    public ViewModel() 
    { 
        employees = new ObservableCollection<Model>(); 
        employees.Add(new Model() { Name = "John", ChipColor = Color.Red }); 
        employees.Add(new Model() { Name = "Stephen", ChipColor = Color.Yellow }); 
        employees.Add(new Model() { Name = "Michael", ChipColor = Color.Pink }); 
        employees.Add(new Model() { Name = "Joel", ChipColor = Color.Gray }); 
    } 
} 
  
  
Please download the prepared sample from below link   
  
   
Screenshot:  
 
  
Please let us know if you need any further assistance on this.  
  
Regards, 
Hemalatha M. 


Loader.
Live Chat Icon For mobile
Up arrow icon