An actionbar that can contain arbitrary items. An item can either be added to the left or the right side of the actionbar. All items that do not fit into the bar (due to space problems or configuration) are hidden in popovers and 'more' buttons are shown in the actionbar.

Markup Examples

|

ActionBar with prefilled buttons on left and right side

Show Markup
<coral-actionbar>
  <coral-actionbar-container>
    <coral-actionbar-item>
      <button is="coral-button">Left 1</button>
    </coral-actionbar-item>
    <coral-actionbar-item>
      <button is="coral-button">Left 2</button>
    </coral-actionbar-item>
    <coral-actionbar-item>
      <button is="coral-button">Left 3</button>
    </coral-actionbar-item>
  </coral-actionbar-container>
  <coral-actionbar-container>
    <coral-actionbar-item>
      <button is="coral-button">Right 1</button>
    </coral-actionbar-item>
    <coral-actionbar-item>
      <button is="coral-button">Right 2</button>
    </coral-actionbar-item>
    <coral-actionbar-item>
      <button is="coral-button">Right 3</button>
    </coral-actionbar-item>
  </coral-actionbar-container>
</coral-actionbar>

Left/Right wrappers can also be configured using attributes

Show Markup
<coral-actionbar>
  <coral-actionbar-container threshold="-1" morebuttontext="Left More">
    <coral-actionbar-item>
      <button is="coral-button" variant="quiet">Left 1</button>
    </coral-actionbar-item>
    <coral-actionbar-item>
      <button is="coral-button" variant="quiet">Left 2</button>
    </coral-actionbar-item>
    <coral-actionbar-item>
      <button is="coral-button" variant="quiet">Left 3</button>
    </coral-actionbar-item>
  </coral-actionbar-container>
  <coral-actionbar-container threshold="2" morebuttontext="Right More">
    <coral-actionbar-item>
      <button is="coral-button" variant="quiet">Right 1</button>
    </coral-actionbar-item>
    <coral-actionbar-item>
      <button is="coral-button" variant="quiet">Right 2</button>
    </coral-actionbar-item>
    <coral-actionbar-item>
      <button is="coral-button" variant="quiet">Right 3</button>
    </coral-actionbar-item>
  </coral-actionbar-container>
</coral-actionbar>

Generate ActionBar with prefilled items on left side only (wrappers are automatically generated)

Show Markup
<coral-actionbar>
  <coral-actionbar-item>
    <button is="coral-button" variant="quiet">Left 1</button>
  </coral-actionbar-item>
  <coral-actionbar-item>
    <button is="coral-button" variant="quiet">Left 2</button>
  </coral-actionbar-item>
  <coral-actionbar-item>
    <button is="coral-button" variant="quiet">Left 3</button>
  </coral-actionbar-item>
</coral-actionbar>

Fill ActionBar via Javascript

The following example is filled and configured via javascript
Show Markup
<coral-actionbar id="jsbar"></coral-actionbar>

The following Javascript manually adds content to the ActionBar component on page initialization and configures the containers

<script>
  $(document).ready(function() {
  var actionBar = document.getElementById('jsbar');
  //wait till the actionbar is ready
  Coral.commons.ready(actionBar, function() {
    // configure the primary/secondary containers
    actionBar.primary.moreButtonText = actionBar.secondary.moreButtonText = 'More JS';
    actionBar.primary.threshold = actionBar.secondary.threshold = 3;
  
    // e.g.: create like actionbar items like this
    var leftItems = actionBar.primary.items;
    var rightItems = actionBar.secondary.items;
    for (var i = 0; i < 5; i++) {
  
    leftItems.add({}).appendChild(new Coral.Button()).set({label: {innerHTML: 'Left' + i}});
    rightItems.add({}).appendChild(new Coral.Button()).set({label: {innerHTML: 'Right' + i}});
  }
});
});
</script>

Coral.ActionBar API

Constructor

JavaScript:

new Coral.ActionBar() or document.createElement('coral-actionbar')

HTML Tag:

<coral-actionbar>

Extends

Sub-components

Instance Properties

instance.hidden {Boolean}

Reflected
Whether this component is hidden or not.
Inherited From:
Default Value:
  • false
HTML Attribute:
  • hidden

instance.primary {HTMLElement}

The primary (left) container of the ActionBar.

instance.secondary {HTMLElement}

The secondary (right) container of the ActionBar.

Methods

instance.get

Get the value of a property.
Parameters:
Name Type Description
property String The name of the property to fetch the value of.
Returns:
Property value. {*}
Inherited From:

instance.hide

Hide this component.
Returns:
this, chainable {Coral.Component}
Inherited From:

instance.off

Remove an event listener.
Parameters:
Name Type Optional Description
eventName String No
The event name to stop listening for.
selector String Yes
The selector that was used for event delegation.
func function No
The function that was passed to on().
useCapture Boolean Yes
Only remove listeners with useCapture set to the value passed in.
Returns:
this, chainable. {Coral.Component}
Inherited From:

instance.on

Add an event listener.
Parameters:
Name Type Optional Default Description
eventName String No
The event name to listen for.
selector String Yes
The selector to use for event delegation.
func function No
The function that will be called when the event is triggered.
useCapture Boolean Yes
Whether or not to listen during the capturing or bubbling phase.
Returns:
this, chainable. {Coral.Component}
Inherited From:

instance.remove

Non-destructively remove this element. It can be re-added by simply appending it to the document again. It will be garbage collected if there are no more references to it.
Inherited From:

instance.set

Set a single property.
Parameters:
Name Type Description
property String The name of the property to set.
value * The value to set the property to.
silent Boolean If true, events should not be triggered as a result of this set.
Returns:
this, chainable. {Coral.Component}
Inherited From:

instance.show

Show this component.
Returns:
this, chainable {Coral.Component}
Inherited From:

instance.trigger

Trigger an event.
Parameters:
Name Type Optional Default Description
eventName String No
The event name to trigger.
props Object Yes
Additional properties to make available to handlers as event.detail.
bubbles Boolean Yes
Set to false to prevent the event from bubbling.
cancelable Boolean Yes
Set to false to prevent the event from being cancelable.
Returns:
CustomEvent object {CustomEvent}
Inherited From:

Events

coral-component:attached

Triggered when the component is attached to the DOM.
Callback Parameters:
Name Type Description
event Object Event object.
Inherited From:
Deprecated:
  • since 1.14.0, use MutationObserver instead.

    coral-component:detached

    Triggered when the component is detached to the DOM.
    Callback Parameters:
    Name Type Description
    event Object Event object.
    Inherited From:
    Deprecated:
    • since 1.14.0, use MutationObserver instead.

      coral-component:ready

      Triggerred when the component has been upgraded and is ready for use.
      Callback Parameters:
      Name Type Description
      event Object Event object.
      Inherited From:
      Deprecated:
      • since 1.9.0, use Coral.commons.ready() instead.

        Coral.ActionBar.Container API

        Constructor

        JavaScript:

        new Coral.ActionBar.Container() or document.createElement('coral-actionbar-container')

        HTML Tag:

        <coral-actionbar-container>

        Extends

        Instance Properties

        instance.hidden {Boolean}

        Reflected
        Whether this component is hidden or not.
        Inherited From:
        Default Value:
        • false
        HTML Attribute:
        • hidden

        instance.items {Coral.Collection}

        Readonly
        The Collection Interface that allows interacting with the items that the component contains. See Coral.Collection for more details.

        instance.moreButtonText {String}

        If there are more ActionBarItems inside the ActionBar than currently can be shown, then a "more" Button with the following text will be rendered (and some ActionBarItems will be hidden inside of a Popover).
        Default Value:
        • ""
        HTML Attribute:
        • morebuttontext

        instance.threshold {Number}

        Reflected
        The amount of items that are maximally visible inside the container. Using a value <= 0 will disable this feature and show as many items as possible.
        Default Value:
        • -1
        HTML Attribute:
        • threshold

        Methods

        instance.get

        Get the value of a property.
        Parameters:
        Name Type Description
        property String The name of the property to fetch the value of.
        Returns:
        Property value. {*}
        Inherited From:

        instance.hide

        Hide this component.
        Returns:
        this, chainable {Coral.Component}
        Inherited From:

        instance.off

        Remove an event listener.
        Parameters:
        Name Type Optional Description
        eventName String No
        The event name to stop listening for.
        selector String Yes
        The selector that was used for event delegation.
        func function No
        The function that was passed to on().
        useCapture Boolean Yes
        Only remove listeners with useCapture set to the value passed in.
        Returns:
        this, chainable. {Coral.Component}
        Inherited From:

        instance.on

        Add an event listener.
        Parameters:
        Name Type Optional Default Description
        eventName String No
        The event name to listen for.
        selector String Yes
        The selector to use for event delegation.
        func function No
        The function that will be called when the event is triggered.
        useCapture Boolean Yes
        Whether or not to listen during the capturing or bubbling phase.
        Returns:
        this, chainable. {Coral.Component}
        Inherited From:

        instance.remove

        Non-destructively remove this element. It can be re-added by simply appending it to the document again. It will be garbage collected if there are no more references to it.
        Inherited From:

        instance.set

        Set a single property.
        Parameters:
        Name Type Description
        property String The name of the property to set.
        value * The value to set the property to.
        silent Boolean If true, events should not be triggered as a result of this set.
        Returns:
        this, chainable. {Coral.Component}
        Inherited From:

        instance.show

        Show this component.
        Returns:
        this, chainable {Coral.Component}
        Inherited From:

        instance.trigger

        Trigger an event.
        Parameters:
        Name Type Optional Default Description
        eventName String No
        The event name to trigger.
        props Object Yes
        Additional properties to make available to handlers as event.detail.
        bubbles Boolean Yes
        Set to false to prevent the event from bubbling.
        cancelable Boolean Yes
        Set to false to prevent the event from being cancelable.
        Returns:
        CustomEvent object {CustomEvent}
        Inherited From:

        Events

        coral-component:attached

        Triggered when the component is attached to the DOM.
        Callback Parameters:
        Name Type Description
        event Object Event object.
        Inherited From:
        Deprecated:
        • since 1.14.0, use MutationObserver instead.

          coral-component:detached

          Triggered when the component is detached to the DOM.
          Callback Parameters:
          Name Type Description
          event Object Event object.
          Inherited From:
          Deprecated:
          • since 1.14.0, use MutationObserver instead.

            coral-component:ready

            Triggerred when the component has been upgraded and is ready for use.
            Callback Parameters:
            Name Type Description
            event Object Event object.
            Inherited From:
            Deprecated:
            • since 1.9.0, use Coral.commons.ready() instead.

              Coral.ActionBar.Item API

              Constructor

              An ActionBar Item should simply wrap arbitrary other items

              JavaScript:

              new Coral.ActionBar.Item() or document.createElement('coral-actionbar-item')

              HTML Tag:

              <coral-actionbar-item>

              Extends

              Instance Properties

              instance.content {HTMLElement}

              Item content element.

              instance.hidden {Boolean}

              Reflected
              Whether this component is hidden or not.
              Inherited From:
              Default Value:
              • false
              HTML Attribute:
              • hidden

              Methods

              instance.get

              Get the value of a property.
              Parameters:
              Name Type Description
              property String The name of the property to fetch the value of.
              Returns:
              Property value. {*}
              Inherited From:

              instance.hide

              Hide this component.
              Returns:
              this, chainable {Coral.Component}
              Inherited From:

              instance.off

              Remove an event listener.
              Parameters:
              Name Type Optional Description
              eventName String No
              The event name to stop listening for.
              selector String Yes
              The selector that was used for event delegation.
              func function No
              The function that was passed to on().
              useCapture Boolean Yes
              Only remove listeners with useCapture set to the value passed in.
              Returns:
              this, chainable. {Coral.Component}
              Inherited From:

              instance.on

              Add an event listener.
              Parameters:
              Name Type Optional Default Description
              eventName String No
              The event name to listen for.
              selector String Yes
              The selector to use for event delegation.
              func function No
              The function that will be called when the event is triggered.
              useCapture Boolean Yes
              Whether or not to listen during the capturing or bubbling phase.
              Returns:
              this, chainable. {Coral.Component}
              Inherited From:

              instance.remove

              Non-destructively remove this element. It can be re-added by simply appending it to the document again. It will be garbage collected if there are no more references to it.
              Inherited From:

              instance.set

              Set a single property.
              Parameters:
              Name Type Description
              property String The name of the property to set.
              value * The value to set the property to.
              silent Boolean If true, events should not be triggered as a result of this set.
              Returns:
              this, chainable. {Coral.Component}
              Inherited From:

              instance.show

              Show this component.
              Returns:
              this, chainable {Coral.Component}
              Inherited From:

              instance.trigger

              Trigger an event.
              Parameters:
              Name Type Optional Default Description
              eventName String No
              The event name to trigger.
              props Object Yes
              Additional properties to make available to handlers as event.detail.
              bubbles Boolean Yes
              Set to false to prevent the event from bubbling.
              cancelable Boolean Yes
              Set to false to prevent the event from being cancelable.
              Returns:
              CustomEvent object {CustomEvent}
              Inherited From:

              Events

              coral-component:attached

              Triggered when the component is attached to the DOM.
              Callback Parameters:
              Name Type Description
              event Object Event object.
              Inherited From:
              Deprecated:
              • since 1.14.0, use MutationObserver instead.

                coral-component:detached

                Triggered when the component is detached to the DOM.
                Callback Parameters:
                Name Type Description
                event Object Event object.
                Inherited From:
                Deprecated:
                • since 1.14.0, use MutationObserver instead.

                  coral-component:ready

                  Triggerred when the component has been upgraded and is ready for use.
                  Callback Parameters:
                  Name Type Description
                  event Object Event object.
                  Inherited From:
                  Deprecated:
                  • since 1.9.0, use Coral.commons.ready() instead.