|
| 1 | +--- |
| 2 | +title: AppBar |
| 3 | +page_title: Configuration, methods and events of Kendo UI AppBar |
| 4 | +description: 'Configuration steps for the AppBar widget.' |
| 5 | +res_type: api |
| 6 | +--- |
| 7 | + |
| 8 | +# kendo.ui.AppBar |
| 9 | + |
| 10 | +Represents the Kendo UI AppBar widget. Inherits from [Widget](/api/javascript/ui/widget). |
| 11 | + |
| 12 | +## Configuration |
| 13 | + |
| 14 | +### themeColor `String` *(default: 'light')* |
| 15 | + |
| 16 | +Specifies the color of the component. Valid options are |
| 17 | + |
| 18 | +* `inherit`: no coloring will be applied to the appbar. Useful when the appbar needs to blend-in with the surrounding elements. |
| 19 | +* `dark`: applies coloring based on **dark** theme color. |
| 20 | +* `light`: applies coloring based on **light** theme color. |
| 21 | + |
| 22 | +#### Example - set color |
| 23 | + <div id="appbar"></div> |
| 24 | + <script> |
| 25 | + $("#appbar").kendoAppBar({ |
| 26 | + items: [ |
| 27 | + { |
| 28 | + template: "<span><input /><span>" |
| 29 | + } |
| 30 | + ], |
| 31 | + themeColor: "dark" |
| 32 | + }); |
| 33 | + </script> |
| 34 | + |
| 35 | +### items `Array` |
| 36 | + |
| 37 | +An array with objects representing the appbar items. |
| 38 | + |
| 39 | +#### Example - set the widths of the columns |
| 40 | + <div id="appbar"></div> |
| 41 | + <script> |
| 42 | + $("#appbar").kendoAppBar({ |
| 43 | + items: [ |
| 44 | + { |
| 45 | + type: "contentItem", |
| 46 | + template: "<span><input /><span>" |
| 47 | + }, |
| 48 | + { |
| 49 | + type: "spacer" |
| 50 | + }, |
| 51 | + { |
| 52 | + type: "contentItem", |
| 53 | + template: "<h1>This is just a text</h1>" |
| 54 | + }, |
| 55 | + ] |
| 56 | + }); |
| 57 | + </script> |
| 58 | + |
| 59 | +### items.className `String` |
| 60 | + |
| 61 | +Defines a set CSS classes for the item. |
| 62 | + |
| 63 | +#### Example - set the type for an item |
| 64 | + <div id="appbar"></div> |
| 65 | + <script> |
| 66 | + $("#appbar").kendoAppBar({ |
| 67 | + items: [ |
| 68 | + { |
| 69 | + type: "contentItem", |
| 70 | + className: "k-first k-one" |
| 71 | + template: "<span><input /><span>" |
| 72 | + }, |
| 73 | + { |
| 74 | + type: "spacer" |
| 75 | + }, |
| 76 | + { |
| 77 | + type: "contentItem", |
| 78 | + template: "<h1>This is just a text</h1>" |
| 79 | + }, |
| 80 | + ] |
| 81 | + }); |
| 82 | + </script> |
| 83 | + |
| 84 | +### items.template `String|Function` |
| 85 | + |
| 86 | +The [template](/api/javascript/kendo/methods/template) which renders as content for the appbar item. Valid only for the **contentItem** type |
| 87 | + |
| 88 | +#### Example - set the template using function |
| 89 | + <script id="first" type="text/x-kendo-template"> |
| 90 | + <input /> |
| 91 | + </script> |
| 92 | + <script id="second" type="text/x-kendo-template"> |
| 93 | + <h3>B</h3> |
| 94 | + </script> |
| 95 | + <div id="appbar"></div> |
| 96 | + <script> |
| 97 | + $("#appbar").kendoAppBar({ |
| 98 | + items: [ |
| 99 | + { |
| 100 | + type: "contentItem", |
| 101 | + template: kendo.template($("#first").html()) |
| 102 | + }, |
| 103 | + { |
| 104 | + type: "spacer" |
| 105 | + }, |
| 106 | + { |
| 107 | + type: "contentItem", |
| 108 | + template: kendo.template($("#second").html()) |
| 109 | + }, |
| 110 | + ] |
| 111 | + }); |
| 112 | + </script> |
| 113 | + |
| 114 | +#### Example - set the template using string |
| 115 | + <div id="appbar"></div> |
| 116 | + <script> |
| 117 | + $("#appbar").kendoAppBar({ |
| 118 | + items: [ |
| 119 | + { |
| 120 | + type: "contentItem", |
| 121 | + template: "<span><input /><span>" |
| 122 | + }, |
| 123 | + { |
| 124 | + type: "spacer" |
| 125 | + }, |
| 126 | + { |
| 127 | + type: "contentItem", |
| 128 | + template: "<h1>This is just a text</h1>" |
| 129 | + }, |
| 130 | + ] |
| 131 | + }); |
| 132 | + </script> |
| 133 | + |
| 134 | +### items.type `String` |
| 135 | + |
| 136 | +A value determining the type of the item. Valid options are |
| 137 | + |
| 138 | +* `spacer`: creates a **span** which to add space between the items. |
| 139 | +* `contentItem`: creates an item using a specific template provided for it. |
| 140 | + |
| 141 | +#### Example - set the type for an item |
| 142 | + <div id="appbar"></div> |
| 143 | + <script> |
| 144 | + $("#appbar").kendoAppBar({ |
| 145 | + items: [ |
| 146 | + { |
| 147 | + type: "contentItem", |
| 148 | + template: "<span><input /><span>" |
| 149 | + }, |
| 150 | + { |
| 151 | + type: "spacer" |
| 152 | + }, |
| 153 | + { |
| 154 | + type: "contentItem", |
| 155 | + template: "<h1>This is just a text</h1>" |
| 156 | + }, |
| 157 | + ] |
| 158 | + }); |
| 159 | + </script> |
| 160 | + |
| 161 | +### items.width `String|Number` |
| 162 | + |
| 163 | +Determines the width of the item. Valid only for the spacer items. Numeric values are treated as pixels. |
| 164 | + |
| 165 | +#### Example - set the width for an item |
| 166 | + <div id="appbar"></div> |
| 167 | + <script> |
| 168 | + $("#appbar").kendoAppBar({ |
| 169 | + items: [ |
| 170 | + { |
| 171 | + type: "contentItem", |
| 172 | + template: "<span><input /><span>" |
| 173 | + }, |
| 174 | + { |
| 175 | + type: "spacer", |
| 176 | + width: 60 |
| 177 | + }, |
| 178 | + { |
| 179 | + type: "contentItem", |
| 180 | + template: "<h1>This is just a text</h1>" |
| 181 | + }, |
| 182 | + ] |
| 183 | + }); |
| 184 | + </script> |
| 185 | + |
| 186 | +### position `String` *(default: 'none')* |
| 187 | + |
| 188 | +Defines where in the page the AppBar will be positioned. Valid options are |
| 189 | + |
| 190 | +* `none`: does not add specific positioning syles |
| 191 | +* `top`: adds the AppBar at the top of the page |
| 192 | +* `bottom`: adds the AppBar at the bottom of the page. |
| 193 | + |
| 194 | +#### Example - set the position |
| 195 | + <div id="appbar"></div> |
| 196 | + <script> |
| 197 | + $("#appbar").kendoAppBar({ |
| 198 | + position: "bottom", |
| 199 | + items: [ |
| 200 | + { |
| 201 | + type: "contentItem", |
| 202 | + template: "<span><input /><span>" |
| 203 | + }, |
| 204 | + { |
| 205 | + type: "spacer" |
| 206 | + }, |
| 207 | + { |
| 208 | + type: "contentItem", |
| 209 | + template: "<h1>This is just a text</h1>" |
| 210 | + }, |
| 211 | + ] |
| 212 | + }); |
| 213 | + </script> |
| 214 | + |
| 215 | +### positionMode `String` *(default: 'static')* |
| 216 | + |
| 217 | +Defines the type of positioning. Valid options are |
| 218 | + |
| 219 | +* `static`: positions the AppBar according to the normal flow of the page. |
| 220 | +* `sticky`: sticks the AppBar to a given position(top or bottom). |
| 221 | +* `fixed`: positions the AppBar relative to the viewport. |
| 222 | + |
| 223 | +#### Example - set the positionMode |
| 224 | + <div id="appbar"></div> |
| 225 | + <script> |
| 226 | + $("#appbar").kendoAppBar({ |
| 227 | + positionMode: "sticky", |
| 228 | + items: [ |
| 229 | + { |
| 230 | + type: "contentItem", |
| 231 | + template: "<span><input /><span>" |
| 232 | + }, |
| 233 | + { |
| 234 | + type: "spacer" |
| 235 | + }, |
| 236 | + { |
| 237 | + type: "contentItem", |
| 238 | + template: "<h1>This is just a text</h1>" |
| 239 | + }, |
| 240 | + ] |
| 241 | + }); |
| 242 | + </script> |
| 243 | + |
| 244 | +## Events |
| 245 | + |
| 246 | +### resize |
| 247 | + |
| 248 | +Fired when the window is resized. |
| 249 | + |
| 250 | +#### Event Data |
| 251 | + |
| 252 | +##### e.sender `kendo.ui.AppBar` |
| 253 | + |
| 254 | +The widget instance. |
| 255 | + |
| 256 | +#### Example - subscribe to resize event |
| 257 | + <div id="appbar"></div> |
| 258 | + <script> |
| 259 | + $("#appbar").kendoAppBar({ |
| 260 | + positionMode: "sticky", |
| 261 | + resize: function () { |
| 262 | + console.log("Resize fired!"); |
| 263 | + }, |
| 264 | + items: [ |
| 265 | + { |
| 266 | + type: "contentItem", |
| 267 | + template: "<span><input /><span>" |
| 268 | + }, |
| 269 | + { |
| 270 | + type: "spacer" |
| 271 | + }, |
| 272 | + { |
| 273 | + type: "contentItem", |
| 274 | + template: "<h1>This is just a text</h1>" |
| 275 | + }, |
| 276 | + ] |
| 277 | + }); |
| 278 | + </script> |
0 commit comments