|
| 1 | +--- |
| 2 | +title: Appearance |
| 3 | +page_title: ComboBox Appearance |
| 4 | +description: Appearance settings of the ComboBox for Blazor. |
| 5 | +slug: combobox-appearance |
| 6 | +tags: telerik,blazor,combobox,appearance |
| 7 | +published: True |
| 8 | +position: 65 |
| 9 | +--- |
| 10 | + |
| 11 | +# Appearance Settings |
| 12 | + |
| 13 | +You can control the appearance of the ComboBox by setting the following attribute: |
| 14 | + |
| 15 | +* [Size](#size) |
| 16 | +* [Rounded](#rounded) |
| 17 | +* [FillMode](#fillmode) |
| 18 | + |
| 19 | + |
| 20 | +## Size |
| 21 | + |
| 22 | +You can increase or decrease the size of the ComboBox by setting the `Size` attribute to a member of the `Telerik.Blazor.ThemeConstants.ComboBox.Size` class: |
| 23 | + |
| 24 | +| Class members | Manual declarations | |
| 25 | +|------------|--------| |
| 26 | +|`Small` |`sm`| |
| 27 | +|`Medium`|`md`| |
| 28 | +|`Large`|`lg`| |
| 29 | + |
| 30 | +>caption The built-in sizes |
| 31 | +
|
| 32 | +````CSHTML |
| 33 | +@{ |
| 34 | + var fields = typeof(Telerik.Blazor.ThemeConstants.ComboBox.Size) |
| 35 | + .GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static |
| 36 | + | System.Reflection.BindingFlags.FlattenHierarchy) |
| 37 | + .Where(field => field.IsLiteral && !field.IsInitOnly).ToList(); |
| 38 | +
|
| 39 | + foreach (var field in fields) |
| 40 | + { |
| 41 | + string size = field.GetValue(null).ToString(); |
| 42 | +
|
| 43 | + <div style="float:left; margin: 20px;"> |
| 44 | + <TelerikComboBox Data="@myComboData" |
| 45 | + Size="@size" |
| 46 | + TextField="MyTextField" |
| 47 | + ValueField="MyValueField" |
| 48 | + @bind-Value="selectedValue" |
| 49 | + Placeholder="Select an item..." |
| 50 | + ClearButton="true" |
| 51 | + Filterable="true"> |
| 52 | + </TelerikComboBox> |
| 53 | + </div> |
| 54 | + } |
| 55 | +} |
| 56 | +
|
| 57 | +@code { |
| 58 | + IEnumerable<MyDdlModel> myComboData = Enumerable.Range(1, 20).Select(x => new MyDdlModel { MyTextField = "item " + x, MyValueField = x }); |
| 59 | +
|
| 60 | + int selectedValue { get; set; } |
| 61 | +
|
| 62 | + protected override void OnInitialized() |
| 63 | + { |
| 64 | + selectedValue = 3; |
| 65 | + } |
| 66 | +
|
| 67 | + public class MyDdlModel |
| 68 | + { |
| 69 | + public int MyValueField { get; set; } |
| 70 | + public string MyTextField { get; set; } |
| 71 | + } |
| 72 | +} |
| 73 | +```` |
| 74 | + |
| 75 | +## Rounded |
| 76 | + |
| 77 | +The `Rounded` attribute applies the `border-radius` CSS rule to the ComboBox to achieve curving of the edges. You can set it to a member of the `Telerik.Blazor.ThemeConstants.ComboBox.Rounded` class: |
| 78 | + |
| 79 | +| Class members | Manual declarations | |
| 80 | +|------------|--------| |
| 81 | +|`Small` |`sm`| |
| 82 | +|`Medium`|`md`| |
| 83 | +|`Large`|`lg`| |
| 84 | +|`Full`|`full`| |
| 85 | + |
| 86 | +>caption The built-in values of the Rounded attribute |
| 87 | +
|
| 88 | +````CSHTML |
| 89 | +@* The built-in values of the Rounded attribute. *@ |
| 90 | +
|
| 91 | +@{ |
| 92 | + var fields = typeof(Telerik.Blazor.ThemeConstants.ComboBox.Rounded) |
| 93 | + .GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static |
| 94 | + | System.Reflection.BindingFlags.FlattenHierarchy) |
| 95 | + .Where(field => field.IsLiteral && !field.IsInitOnly).ToList(); |
| 96 | +
|
| 97 | + foreach (var field in fields) |
| 98 | + { |
| 99 | + string rounded = field.GetValue(null).ToString(); |
| 100 | +
|
| 101 | + <div style="float:left; margin: 20px;"> |
| 102 | + <TelerikComboBox Data="@myComboData" |
| 103 | + Rounded="@rounded" |
| 104 | + TextField="MyTextField" |
| 105 | + ValueField="MyValueField" |
| 106 | + @bind-Value="selectedValue" |
| 107 | + Placeholder="Select an item..." |
| 108 | + ClearButton="true" |
| 109 | + Filterable="true"> |
| 110 | + </TelerikComboBox> |
| 111 | + </div> |
| 112 | + } |
| 113 | +} |
| 114 | +
|
| 115 | +@code { |
| 116 | + IEnumerable<MyDdlModel> myComboData = Enumerable.Range(1, 20).Select(x => new MyDdlModel { MyTextField = "item " + x, MyValueField = x }); |
| 117 | +
|
| 118 | + int selectedValue { get; set; } |
| 119 | +
|
| 120 | + protected override void OnInitialized() |
| 121 | + { |
| 122 | + selectedValue = 3; |
| 123 | + } |
| 124 | +
|
| 125 | + public class MyDdlModel |
| 126 | + { |
| 127 | + public int MyValueField { get; set; } |
| 128 | + public string MyTextField { get; set; } |
| 129 | + } |
| 130 | +} |
| 131 | +```` |
| 132 | + |
| 133 | +## FillMode |
| 134 | + |
| 135 | +The `FillMode` controls how the TelerikComboBox is filled. You can set it to a member of the `Telerik.Blazor.ThemeConstants.ComboBox.FillMode` class: |
| 136 | + |
| 137 | +| Class members | Result | |
| 138 | +|------------|--------| |
| 139 | +|`Solid` <br /> default value|`solid`| |
| 140 | +|`Flat`|`flat`| |
| 141 | +|`Outline`|`outline`| |
| 142 | + |
| 143 | +>caption The built-in Fill modes |
| 144 | +
|
| 145 | +````CSHTML |
| 146 | +@* These are all built-in fill modes *@ |
| 147 | +
|
| 148 | +@{ |
| 149 | + var fields = typeof(Telerik.Blazor.ThemeConstants.ComboBox.FillMode) |
| 150 | + .GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static |
| 151 | + | System.Reflection.BindingFlags.FlattenHierarchy) |
| 152 | + .Where(field => field.IsLiteral && !field.IsInitOnly).ToList(); |
| 153 | +
|
| 154 | + foreach (var field in fields) |
| 155 | + { |
| 156 | + string fillMode = field.GetValue(null).ToString(); |
| 157 | +
|
| 158 | + <div style="float:left; margin: 20px;"> |
| 159 | + <TelerikComboBox Data="@myComboData" |
| 160 | + FillMode="@fillMode" |
| 161 | + TextField="MyTextField" |
| 162 | + ValueField="MyValueField" |
| 163 | + @bind-Value="selectedValue" |
| 164 | + Placeholder="Select an item..." |
| 165 | + ClearButton="true" |
| 166 | + Filterable="true"> |
| 167 | + </TelerikComboBox> |
| 168 | + </div> |
| 169 | + } |
| 170 | +} |
| 171 | +
|
| 172 | +@code { |
| 173 | + IEnumerable<MyDdlModel> myComboData = Enumerable.Range(1, 20).Select(x => new MyDdlModel { MyTextField = "item " + x, MyValueField = x }); |
| 174 | +
|
| 175 | + int selectedValue { get; set; } |
| 176 | +
|
| 177 | + protected override void OnInitialized() |
| 178 | + { |
| 179 | + selectedValue = 3; |
| 180 | + } |
| 181 | +
|
| 182 | + public class MyDdlModel |
| 183 | + { |
| 184 | + public int MyValueField { get; set; } |
| 185 | + public string MyTextField { get; set; } |
| 186 | + } |
| 187 | +} |
| 188 | +```` |
| 189 | + |
0 commit comments