Close Button
A generic close button for dismissing content like modals and alerts.
#
ExampleProvide an option to dismiss or close a component with .btn-close. Default styling is limited, but highly customizable. Modify the Sass variables to replace the default background-image. Be sure to include text for screen readers, as we’ve done with aria-label.
- Web Component
- React
- Angular
<uxf-close-button></uxf-close-button>
<UxfCloseButton></UxfCloseButton>
<uxf-close-button></uxf-close-button>
#
Disabled stateDisabled close buttons change their opacity. We’ve also applied pointer-events: none and user-select: none to preventing hover and active states from triggering.
- Web Component
- React
- Angular
<uxf-close-button disabled></uxf-close-button>
<UxfCloseButton disabled></UxfCloseButton>
<uxf-close-button disabled></uxf-close-button>
White variant
Change the default .btn-close to be white with the .btn-close-white class. This class uses the filter property to invert the background-image.
- Web Component
- React
- Angular
<uxf-close-button white></uxf-close-button><uxf-close-button white disabled></uxf-close-button>
<UxfCloseButton white></UxfCloseButton><UxfCloseButton white disabled></UxfCloseButton>
<uxf-close-button white></uxf-close-button><uxf-close-button white disabled></uxf-close-button>
Events
#
close- Web Component
- React
- Angular
<uxf-close-button id="close-button"></uxf-close-button>
<script> document.querySelector("#close-button").addEventListener("triggerClose", ()=>{ alert("trigger close event triggered") })</script>
<UxfCloseButton onTriggerClose={()=>alert("trigger close event triggered")}></UxfCloseButton>
<uxf-close-button id="close-button"></uxf-close-button>