blob: f2a8c05c06695e13f1b8daa1c4e797d31dccae59 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
<header><h1>popover</h1></header><div class="section-content">
<p>The <code>popover</code> <a href="../global_attributes">global attribute</a> is used to designate an element as a popover element.</p> <p>Popover elements are hidden via <code>display: none</code> until opened via an invoking/control element (i.e. a <code><button></code> or <code><input type="button"></code> with a <a href="../element/button#popovertarget"><code>popovertarget</code></a> attribute) or a <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/showPopover"><code>HTMLElement.showPopover()</code></a> call.</p> <p>When open, popover elements will appear above all other elements in the <a href="https://developer.mozilla.org/en-US/docs/Glossary/Top_layer">top layer</a>, and won't be influenced by parent elements' <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/position"><code>position</code></a> or <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/overflow"><code>overflow</code></a> styling.</p> <p> A popover attribute can have values <a href="https://developer.mozilla.org/en-US/docs/Web/API/Popover_API/Using#auto_state_and_light_dismiss"><code>"auto"</code></a> (default) or <a href="https://developer.mozilla.org/en-US/docs/Web/API/Popover_API/Using#using_manual_popover_state"><code>"manual"</code></a>. Popovers that have the <code>auto</code> state can be "light dismissed" by selecting outside the popover area, and generally only allow one popover to be displayed on-screen at a time. By contrast, <code>manual</code> popovers must always be explicitly hidden, but allow for use cases such as nested popovers in menus. </p> <p>For detailed information on usage, see the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Popover_API">Popover API</a> landing page.</p>
</div>
<h2 id="examples">Examples</h2>
<div class="section-content">
<p>The following will render a button which will open a popover element.</p> <div class="code-example">
<p class="example-header"><span class="language-name">html</span></p>
<pre data-signature="7v3uh3jeL5lI4RisD3HJLrDXuIM+pPMWtwYF7G3ml10=" data-language="html"><span class="token tag"><span class="token tag"><span class="token punctuation"><</span>button</span> <span class="token attr-name">popovertarget</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>my-popover<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>Open Popover<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>button</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation"><</span>div</span> <span class="token attr-name">popover</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>my-popover<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>Greetings, one and all!<span class="token tag"><span class="token tag"><span class="token punctuation"></</span>div</span><span class="token punctuation">></span></span>
</pre>
</div> <div class="notecard note" id="sect1"> <p><strong>Note:</strong> See our <a href="https://mdn.github.io/dom-examples/popover-api/" target="_blank">Popover API examples landing page</a> to access the full collection of MDN popover examples.</p> </div>
</div>
<h2 id="specifications">Specifications</h2>
<div class="_table"><table class="standard-table">
<thead><tr><th scope="col">Specification</th></tr></thead>
<tbody><tr><td><a href="https://html.spec.whatwg.org/multipage/popover.html#the-popover-attribute">HTML Standard <br><small># the-popover-attribute</small></a></td></tr></tbody>
</table></div>
<h2 id="browser_compatibility">Browser compatibility</h2>
<div class="_table"><table>
<thead>
<tr id="bct-browser-type">
<th></th>
<th colspan="6">Desktop</th>
<th colspan="6">Mobile</th>
</tr>
<tr id="bct-browsers">
<th></th>
<th>Chrome</th>
<th>Edge</th>
<th>Firefox</th>
<th>Internet Explorer</th>
<th>Opera</th>
<th>Safari</th>
<th>WebView Android</th>
<th>Chrome Android</th>
<th>Firefox for Android</th>
<th>Opera Android</th>
<th>Safari on IOS</th>
<th>Samsung Internet</th>
</tr>
</thead>
<tbody><tr>
<th><code>popover</code></th>
<td class="bc-supports-yes">114</td>
<td class="bc-supports-yes">114</td>
<td class="bc-supports-yes">114</td>
<td class="bc-supports-no">No</td>
<td class="bc-supports-yes">100</td>
<td class="bc-supports-yes">17</td>
<td class="bc-supports-yes">114</td>
<td class="bc-supports-yes">114</td>
<td class="bc-supports-no">No</td>
<td class="bc-supports-no">No</td>
<td class="bc-supports-yes">17</td>
<td class="bc-supports-no">No</td>
</tr></tbody>
</table></div>
<h2 id="see_also">See also</h2>
<div class="section-content"><ul> <li><a href="https://developer.mozilla.org/en-US/docs/Web/API/Popover_API">Popover API</a></li> </ul></div><div class="_attribution">
<p class="_attribution-p">
© 2005–2023 MDN contributors.<br>Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.<br>
<a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/popover" class="_attribution-link">https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/popover</a>
</p>
</div>
|