obap-badge

June 12, 2020 ยท View on GitHub

<obap-badge> is a circular text badge that is displayed on the top right corner (default) of an element, representing a status or a notification. It will anchor to the element specified in the for attribute, or, if that doesn't exist the immediate previous sibling, failing that, the parent node containing it. It inherits all the obap-attached-element positioning propeties (anchor, inset, shift, offsetX and offsetY).

Usage

import '@obap/obap-elements/obap-badge/obap-badge.js';

<!-- Anchors based on id -->
<div>
    <div id="ib_1"></div>
    <obap-badge label="3" for="ib_1"></obap-badge>
</div>

<!-- Anchors to previous sibling (div) -->
<div>
    <div class="sibling"></div>
    <obap-badge label="3"></obap-badge>
</div>

<!-- Anchors to the parent -->
<div class="parent">
    <obap-badge label="3"></obap-badge>
</div>

Mixins: ObapAttachedElementController

Properties

PropertyAttributeModifiersTypeDefaultDescription
anchoranchorstring"top-right"
disableddisabledBoolean"false"If true, the button will be disabled.
forforstring""
iconiconstring""
insetinsetstring"none"
labellabelstring""
offsetXoffset-xnumber0
offsetYoffset-ynumber0
roleroleString"null"The ARIA role of the element.
shiftshiftstring"none"
targetElementreadonly

Methods

MethodType
updatePosition(): void