|
1 | | - |
2 | | -<!--- |
3 | | -
|
4 | | -This README is automatically generated from the comments in these files: |
5 | | -paper-dropdown-menu-light.html paper-dropdown-menu.html |
6 | | -
|
7 | | -Edit those files, and our readme bot will duplicate them over here! |
8 | | -Edit this file, and the bot will squash your changes :) |
9 | | -
|
10 | | -The bot does some handling of markdown. Please file a bug if it does the wrong |
11 | | -thing! https://github.com/PolymerLabs/tedium/issues |
12 | | -
|
13 | | ---> |
14 | | - |
| 1 | +[](https://beta.webcomponents.org/element/PolymerElements/paper-dropdown-menu) |
15 | 2 | [](https://travis-ci.org/PolymerElements/paper-dropdown-menu) |
16 | 3 |
|
17 | | -_[Demo and API docs](https://elements.polymer-project.org/elements/paper-dropdown-menu)_ |
18 | | - |
19 | | - |
20 | 4 | ##<paper-dropdown-menu> |
21 | 5 |
|
22 | 6 | Material design: [Dropdown menus](https://www.google.com/design/spec/components/buttons.html#buttons-dropdown-buttons) |
23 | 7 |
|
24 | 8 | `paper-dropdown-menu` is similar to a native browser select element. |
25 | | -`paper-dropdown-menu` works with selectable content. The currently selected |
26 | | -item is displayed in the control. If no item is selected, the `label` is |
27 | | -displayed instead. |
28 | | - |
29 | | -Example: |
| 9 | +`paper-dropdown-menu` works with selectable content. |
30 | 10 |
|
31 | | -```html |
32 | | -<paper-dropdown-menu label="Your favourite pastry"> |
33 | | - <paper-listbox class="dropdown-content"> |
34 | | - <paper-item>Croissant</paper-item> |
35 | | - <paper-item>Donut</paper-item> |
36 | | - <paper-item>Financier</paper-item> |
37 | | - <paper-item>Madeleine</paper-item> |
38 | | - </paper-listbox> |
39 | | -</paper-dropdown-menu> |
| 11 | +<!--- |
40 | 12 | ``` |
41 | | - |
42 | | -This example renders a dropdown menu with 4 options. |
43 | | - |
44 | | -The child element with the class `dropdown-content` is used as the dropdown |
45 | | -menu. This can be a [`paper-listbox`](paper-listbox), or any other or |
46 | | -element that acts like an [`iron-selector`](iron-selector). |
47 | | - |
48 | | -Specifically, the menu child must fire an |
49 | | -[`iron-select`](iron-selector#event-iron-select) event when one of its |
50 | | -children is selected, and an [`iron-deselect`](iron-selector#event-iron-deselect) |
51 | | -event when a child is deselected. The selected or deselected item must |
52 | | -be passed as the event's `detail.item` property. |
53 | | - |
54 | | -Applications can listen for the `iron-select` and `iron-deselect` events |
55 | | -to react when options are selected and deselected. |
56 | | - |
57 | | -### Styling |
58 | | - |
59 | | -The following custom properties and mixins are also available for styling: |
60 | | - |
61 | | -| Custom property | Description | Default | |
62 | | -| --- | --- | --- | |
63 | | -| `--paper-dropdown-menu` | A mixin that is applied to the element host | `{}` | |
64 | | -| `--paper-dropdown-menu-disabled` | A mixin that is applied to the element host when disabled | `{}` | |
65 | | -| `--paper-dropdown-menu-ripple` | A mixin that is applied to the internal ripple | `{}` | |
66 | | -| `--paper-dropdown-menu-button` | A mixin that is applied to the internal menu button | `{}` | |
67 | | -| `--paper-dropdown-menu-input` | A mixin that is applied to the internal paper input | `{}` | |
68 | | -| `--paper-dropdown-menu-icon` | A mixin that is applied to the internal icon | `{}` | |
69 | | - |
70 | | -You can also use any of the `paper-input-container` and `paper-menu-button` |
71 | | -style mixins and custom properties to style the internal input and menu button |
72 | | -respectively. |
73 | | - |
74 | | - |
75 | | - |
76 | | -##<paper-dropdown-menu-light> |
77 | | - |
78 | | -Material design: [Dropdown menus](https://www.google.com/design/spec/components/buttons.html#buttons-dropdown-buttons) |
79 | | - |
80 | | -This is a faster, lighter version of `paper-dropdown-menu`, that does not |
81 | | -use a `<paper-input>` internally. Use this element if you're concerned about |
82 | | -the performance of this element, i.e., if you plan on using many dropdowns on |
83 | | -the same page. Note that this element has a slightly different styling API |
84 | | -than `paper-dropdown-menu`. |
85 | | - |
86 | | -`paper-dropdown-menu-light` is similar to a native browser select element. |
87 | | -`paper-dropdown-menu-light` works with selectable content. The currently selected |
88 | | -item is displayed in the control. If no item is selected, the `label` is |
89 | | -displayed instead. |
90 | | - |
91 | | -Example: |
92 | | - |
93 | | -```html |
94 | | -<paper-dropdown-menu-light label="Your favourite pastry"> |
95 | | - <paper-listbox class="dropdown-content"> |
96 | | - <paper-item>Croissant</paper-item> |
97 | | - <paper-item>Donut</paper-item> |
98 | | - <paper-item>Financier</paper-item> |
99 | | - <paper-item>Madeleine</paper-item> |
100 | | - </paper-listbox> |
101 | | -</paper-dropdown-menu-light> |
| 13 | +<custom-element-demo> |
| 14 | + <template> |
| 15 | + <script src="../webcomponentsjs/webcomponents-lite.js"></script> |
| 16 | + <link rel="import" href="paper-dropdown-menu.html"> |
| 17 | + <link rel="import" href="../paper-item/paper-item.html"> |
| 18 | + <link rel="import" href="../paper-listbox/paper-listbox.html"> |
| 19 | + <link rel="import" href="../iron-demo-helpers/demo-pages-shared-styles.html"> |
| 20 | + <style is="custom-style" include="demo-pages-shared-styles"> |
| 21 | + paper-dropdown-menu, paper-listbox { |
| 22 | + width: 250px; |
| 23 | + } |
| 24 | + paper-dropdown-menu { |
| 25 | + height: 200px; |
| 26 | + margin: auto; |
| 27 | + display: block; |
| 28 | + } |
| 29 | + </style> |
| 30 | + <next-code-block></next-code-block> |
| 31 | + </template> |
| 32 | +</custom-element-demo> |
102 | 33 | ``` |
103 | | - |
104 | | -This example renders a dropdown menu with 4 options. |
105 | | - |
106 | | -The child element with the class `dropdown-content` is used as the dropdown |
107 | | -menu. This can be a [`paper-listbox`](paper-listbox), or any other or |
108 | | -element that acts like an [`iron-selector`](iron-selector). |
109 | | - |
110 | | -Specifically, the menu child must fire an |
111 | | -[`iron-select`](iron-selector#event-iron-select) event when one of its |
112 | | -children is selected, and an [`iron-deselect`](iron-selector#event-iron-deselect) |
113 | | -event when a child is deselected. The selected or deselected item must |
114 | | -be passed as the event's `detail.item` property. |
115 | | - |
116 | | -Applications can listen for the `iron-select` and `iron-deselect` events |
117 | | -to react when options are selected and deselected. |
118 | | - |
119 | | -### Styling |
120 | | - |
121 | | -The following custom properties and mixins are also available for styling: |
122 | | - |
123 | | -| Custom property | Description | Default | |
124 | | -| --- | --- | --- | |
125 | | -| `--paper-dropdown-menu` | A mixin that is applied to the element host | `{}` | |
126 | | -| `--paper-dropdown-menu-disabled` | A mixin that is applied to the element host when disabled | `{}` | |
127 | | -| `--paper-dropdown-menu-ripple` | A mixin that is applied to the internal ripple | `{}` | |
128 | | -| `--paper-dropdown-menu-button` | A mixin that is applied to the internal menu button | `{}` | |
129 | | -| `--paper-dropdown-menu-icon` | A mixin that is applied to the internal icon | `{}` | |
130 | | -| `--paper-dropdown-menu-disabled-opacity` | The opacity of the dropdown when disabled | `0.33` | |
131 | | -| `--paper-dropdown-menu-color` | The color of the input/label/underline when the dropdown is unfocused | `--primary-text-color` | |
132 | | -| `--paper-dropdown-menu-focus-color` | The color of the label/underline when the dropdown is focused | `--primary-color` | |
133 | | -| `--paper-dropdown-error-color` | The color of the label/underline when the dropdown is invalid | `--error-color` | |
134 | | -| `--paper-dropdown-menu-label` | Mixin applied to the label | `{}` | |
135 | | -| `--paper-dropdown-menu-input` | Mixin appled to the input | `{}` | |
136 | | - |
137 | | -Note that in this element, the underline is just the bottom border of the "input". |
138 | | -To style it: |
139 | | - |
| 34 | +--> |
140 | 35 | ```html |
141 | | -<style is=custom-style> |
142 | | - paper-dropdown-menu-light.custom { |
143 | | - --paper-dropdown-menu-input: { |
144 | | - border-bottom: 2px dashed lavender; |
145 | | - }; |
146 | | -</style> |
| 36 | +<paper-dropdown-menu label="Dinosaurs"> |
| 37 | + <paper-listbox class="dropdown-content" selected="1"> |
| 38 | + <paper-item>allosaurus</paper-item> |
| 39 | + <paper-item>brontosaurus</paper-item> |
| 40 | + <paper-item>carcharodontosaurus</paper-item> |
| 41 | + <paper-item>diplodocus</paper-item> |
| 42 | + </paper-listbox> |
| 43 | +</paper-dropdown-menu> |
147 | 44 | ``` |
148 | | - |
149 | | - |
0 commit comments