Search is a touch-friendly input control.

Labelling the component

For improved accessibility the component should always be labelled. This can be achieved by using the labelledby attribute.
Show Markup
<form class="coral-Form coral-Form--vertical">
  <section class="coral-Form-fieldset">
    <label class="coral-Form-fieldlabel" id="labelExample">Select the image width</label>
    <coral-search value="480" name="ally" labelledby="labelExample"></coral-search>
  </section>
</form>

Vertical Layout

Show Markup
<form class="coral-Form coral-Form--vertical">
  <section class="coral-Form-fieldset">
  <div class="coral-Form-fieldwrapper">
    <label class="coral-Form-fieldlabel" id="label-vertical-search-0">Label</label>
    <coral-search class="coral-Form-field" placeholder="Enter your text" name="name" value="" labelledby="label-vertical-search-0"></coral-search>
  </div>
  <div class="coral-Form-fieldwrapper">
    <label class="coral-Form-fieldlabel" id="label-vertical-search-1">Required</label>
    <coral-search  class="coral-Form-field" placeholder="Enter your text" name="name" value="" labelledby="label-vertical-search-1"></coral-search>
    <coral-icon class="coral-Form-fieldinfo" icon="infoCircle" size="S" id="coral-form-vertical-search-fieldinfo"></coral-icon>
    <coral-tooltip variant="info" placement="right" target="#coral-form-vertical-search-fieldinfo">Required Information</coral-tooltip>
  </div>
  <div class="coral-Form-fieldwrapper">
    <label class="coral-Form-fieldlabel" id="label-vertical-search-2">Invalid</label>
    <coral-search class="coral-Form-field" placeholder="Enter your text" name="name" value="" labelledby="label-vertical-search-2"></coral-search>
    <coral-icon class="coral-Form-fielderror" icon="infoCircle" size="S" id="coral-form-vertical-search-fielderror"></coral-icon>
    <coral-tooltip variant="error" placement="right" target="#coral-form-vertical-search-fielderror">Error Message</coral-tooltip>
  </div>
  </section>
</form>

Aligned Layout

Show Markup
<form class="coral-Form coral-Form--aligned u-columnLarge">
  <section class="coral-Form-fieldset">
  <div class="coral-Form-fieldwrapper">
    <label class="coral-Form-fieldlabel" id="label-aligned-search-0">Label</label>
    <coral-search class="coral-Form-field" placeholder="Enter your text" name="name" value="" labelledby="label-aligned-search-0"></coral-search>
  </div>
  <div class="coral-Form-fieldwrapper">
    <label class="coral-Form-fieldlabel" id="label-aligned-search-1">Required</label>
    <coral-search class="coral-Form-field" placeholder="Enter your text" name="name" value="" labelledby="label-aligned-search-1"></coral-search>
    <coral-icon class="coral-Form-fieldinfo" icon="infoCircle" size="S" id="coral-form-aligned-search-fieldinfo"></coral-icon>
    <coral-tooltip variant="info" placement="right" target="#coral-form-aligned-search-fieldinfo">Required Information</coral-tooltip>
  </div>
  <div class="coral-Form-fieldwrapper">
    <label class="coral-Form-fieldlabel" id="label-aligned-search-2">Invalid</label>
    <coral-search class="coral-Form-field" placeholder="Enter your text" name="name" value="" labelledby="label-aligned-search-2"></coral-search>
    <coral-icon class="coral-Form-fielderror" icon="infoCircle" size="S" id="coral-form-aligned-search-fielderror"></coral-icon>
    <coral-tooltip variant="error" placement="right" target="#coral-form-aligned-search-fielderror">Error Message</coral-tooltip>
  </div>
  </section>
</form>

Coral.Search API

Constructor

JavaScript:

new Coral.Search() or document.createElement('coral-search')

HTML Tag:

<coral-search>

Extends

Static Properties

Coral.Search.variant {String}

Enum for search variant values.

Properties:

Name Type Value Description
DEFAULT String default A default, gray search input
QUIET String quiet A search with no border, no background, no glow

Instance Properties

instance.disabled {Boolean}

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

instance.hidden {Boolean}

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

instance.icon {String}

Reflected
This sets the left icon on the search component.
Default Value:
  • "search"
HTML Attribute:
  • icon

instance.invalid {Boolean}

Reflected
Whether the current value of this field is invalid or not.
Inherited From:
Default Value:
  • false
HTML Attribute:
  • invalid

instance.labelledBy {String}

Reference to a space delimited set of ids for the HTML elements that provide a label for the formField. Implementers should override this method to ensure that the appropriate descendant elements are labelled using the aria-labelledby attribute. This will ensure that the component is properly identified for accessibility purposes. It reflects the aria-labelledby attribute to the DOM.
Inherited From:
Default Value:
  • null
HTML Attribute:
  • labelledby

instance.maxLength {Long}

Reflected
Max length for the Input field.
HTML Attribute:
  • maxlength

instance.name {String}

Reflected
Name used to submit the data in a form.
Inherited From:
Default Value:
  • ""
HTML Attribute:
  • name

instance.placeholder {String}

Reflected
Short hint that describes the expected value of the Search. It is displayed when the Search is empty.
Default Value:
  • ""
HTML Attribute:
  • placeholder

instance.readOnly {Boolean}

Reflected
Whether this field is readOnly or not. Indicating that the user cannot modify the value of the control. This is ignored for checkbox, radio or fileupload.
Inherited From:
Default Value:
  • false
HTML Attribute:
  • readonly

instance.required {Boolean}

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

instance.value {String}

This field's current value.
Inherited From:
Default Value:
  • ""
HTML Attribute:
  • value

instance.variant {Coral.Search.variant}

The search's variant.
Default Value:
  • Coral.Search.variant.DEFAULT
HTML Attribute:
  • variant

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

change

Triggered when the value has changed. This event is only triggered by user interaction.
Callback Parameters:
Name Type Description
event Object Event object.
Inherited From:

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-search:clear

        Triggerred when the search is cleared.
        Callback Parameters:
        Name Type Description
        event Object Event object.

        coral-search:input

        Triggerred when input is given.
        Callback Parameters:
        Name Type Description
        event Object Event object.

        coral-search:submit

        Triggerred when the user presses enter.
        Callback Parameters:
        Name Type Description
        event Object Event object.