As a plugin developer, it's important to make sure the Dashboard has the same look-and-feel as the rest of the native components of WordPress to provide a better User Experience.
For my plugin, I want to implement an accordion in my settings page. From reading this article and using wp_enqueue_script()
function, it looks like this is possible by doing the following:
<?php
wp_enqueue_script( 'jquery-ui-accordion' );
?>
<script type="text/javascript">
jQuery(function($){
$(".accordion").accordion({ header: "h3" });
$(".accordion").last().accordion("option", "icons", false);
});
</script>
<div class="accordion">
<div>
<h3><a href="#">First</a></h3>
<div>Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet.</div>
</div>
<div>
<h3><a href="#">Second</a></h3>
<div>Phasellus mattis tincidunt nibh.</div>
</div>
<div>
<h3><a href="#">Third</a></h3>
<div>Nam dui erat, auctor a, dignissim quis.</div>
</div>
</div>
<?php
Result
This was taken from the WordPress Admin Pattern Library plugin that I found on GitHub. Yet, in their demo, the accordion example looks like the following:
The repo looks like it hasn't been maintained and it seems that this is a styling issue. Is there another function that I need to run such as wp_enqueue_style()
that is natively built in in order to get the proper styling for the accordion?