Add Responsive-Friendly Enhancements to <​details> with <​details-utils>

Zach created a very handy Web Component that augments and wraps around a <details> element. He’s named it <details-utils>. This web component adds five new responsive-friendly enhancements to one or more <details> elements nestled inside: Force open/closed Click outside to close Close on esc Animate open/closed Toggle root element class Using attributes you can control …


This content originally appeared on Bram.us and was authored by Bramus!

Zach created a very handy Web Component that augments and wraps around a <details> element. He’s named it <details-utils>.

This web component adds five new responsive-friendly enhancements to one or more <details> elements nestled inside:

  • Force open/closed
  • Click outside to close
  • Close on esc
  • Animate open/closed
  • Toggle root element class

Using attributes you can control the behavior. Additionally, you can pass in media queries into (most of) the attribute values to make them respond to viewport sizes. For example, to have a <details> be automatically opened below a certain viewport size, you can use this:

<details-utils force-open="(max-width: 767px)">
	<details>
		<summary>Force open at small viewport</summary>
		<div class="demo-content">
			<p>This is the content.</p>
		</div>
	</details>
</details-utils>

Handy!

Introductory Blogpost →
Demo →
Source (GitHub) →


This content originally appeared on Bram.us and was authored by Bramus!


Print Share Comment Cite Upload Translate Updates
APA

Bramus! | Sciencx (2022-02-10T21:33:12+00:00) Add Responsive-Friendly Enhancements to <​details> with <​details-utils>. Retrieved from https://www.scien.cx/2022/02/10/add-responsive-friendly-enhancements-to-details-with-details-utils-2/

MLA
" » Add Responsive-Friendly Enhancements to <​details> with <​details-utils>." Bramus! | Sciencx - Thursday February 10, 2022, https://www.scien.cx/2022/02/10/add-responsive-friendly-enhancements-to-details-with-details-utils-2/
HARVARD
Bramus! | Sciencx Thursday February 10, 2022 » Add Responsive-Friendly Enhancements to <​details> with <​details-utils>., viewed ,<https://www.scien.cx/2022/02/10/add-responsive-friendly-enhancements-to-details-with-details-utils-2/>
VANCOUVER
Bramus! | Sciencx - » Add Responsive-Friendly Enhancements to <​details> with <​details-utils>. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/02/10/add-responsive-friendly-enhancements-to-details-with-details-utils-2/
CHICAGO
" » Add Responsive-Friendly Enhancements to <​details> with <​details-utils>." Bramus! | Sciencx - Accessed . https://www.scien.cx/2022/02/10/add-responsive-friendly-enhancements-to-details-with-details-utils-2/
IEEE
" » Add Responsive-Friendly Enhancements to <​details> with <​details-utils>." Bramus! | Sciencx [Online]. Available: https://www.scien.cx/2022/02/10/add-responsive-friendly-enhancements-to-details-with-details-utils-2/. [Accessed: ]
rf:citation
» Add Responsive-Friendly Enhancements to <​details> with <​details-utils> | Bramus! | Sciencx | https://www.scien.cx/2022/02/10/add-responsive-friendly-enhancements-to-details-with-details-utils-2/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.