Newer Version Available
ui:outputURL
Displays a link to a URL as specified by the value attribute, rendered on a given text (label attribute) and image, if any.
A ui:outputURL component represents a URL that is wrapped in an HTML a tag. We recommend using lightning:formattedUrl instead of ui:outputURL.
ui:outputURL can be used with ui:inputURL, which takes in a URL input. To apply Lightning Design System styling, we recommend that you use lightning:input with type="url" instead of ui:inputURL.
To display a URL, you can use an attribute value and bind it to the ui:outputURL component.
1<aura:attribute name="myURL" type="String" default="http://www.google.com"/>
2<ui:outputURL value="{!v.myURL}" label="Search"/>The previous example renders the following HTML.
1<a href="http://www.google.com" class="uiOutputURL">Search</a>This example shows how you can bind data from a ui:inputURL component.
1<aura:component>
2 <ui:inputURL aura:id="url" label="Venue URL" class="field" value="http://www.myURL.com"/>
3 <ui:button class="btn" label="Submit" press="{!c.setOutput}"/>
4 <div aura:id="msg" class="hide">
5 You entered: <ui:outputURL aura:id="oURL" value=""/>
6 </div>
7</aura:component>1({
2 setOutput : function(component, event, helper) {
3 var cmpMsg = component.find("msg");
4 $A.util.removeClass(cmpMsg, 'hide');
5
6 var url = component.find("url").get("v.value");
7 var oURL = component.find("oURL");
8 oURL.set("v.value", url);
9 oURL.set("v.label", url);
10 }
11})Attributes
| Attribute Name | Attribute Type | Description | Required? |
|---|---|---|---|
| alt | String | The alternate text description for image (used when there is no label) | |
| body | Component[] | The body of the component. In markup, this is everything in the body of the tag. | |
| class | String | A CSS style to be attached to the component. This style is added in addition to base styles output by the component. | |
| disabled | Boolean | Specifies whether the component should be displayed in a disabled state. Default value is "false". | |
| iconClass | String | The CSS style used to display the icon or image. | |
| label | String | The text displayed on the component. | |
| target | String | The target destination where this rendered component is displayed. Possible values: _blank, _parent, _self, _top | |
| title | String | The text to display as a tooltip when the mouse pointer hovers over this component. | |
| value | String | The URL of the page that the link goes to. | Yes |
Events
| Event Name | Event Type | Description |
|---|---|---|
| dblclick | COMPONENT | The event fired when the user double-clicks the component. |
| mouseover | COMPONENT | The event fired when the user moves the mouse pointer over the component. |
| mouseout | COMPONENT | The event fired when the user moves the mouse pointer away from the component. |
| mouseup | COMPONENT | The event fired when the user releases the mouse button over the component. |
| mousemove | COMPONENT | The event fired when the user moves the mouse pointer over the component. |
| click | COMPONENT | The event fired when the user clicks on the component. |
| mousedown | COMPONENT | The event fired when the user clicks a mouse button over the component. |