Alert
Alert
Component demo
Interactive example
<ic-alertheading="Americano order"message="Preparation status is unavailable."></ic-alert><ic-alertvariant="info"heading="Did you know?"message="Coffee is a brewed drink prepared from roasted coffee beans."></ic-alert><ic-alertvariant="error"heading="Americano order error"message="Americano couldn't be made, we ran out of beans."></ic-alert><ic-alertvariant="warning"heading="Hot drink"message="Please be careful the drink is hot."></ic-alert><ic-alertvariant="success"heading="Americano order complete"message="Success, your coffee is good to go."></ic-alert>
<IcAlertheading="Americano order"message="Preparation status is unavailable."/><IcAlertvariant="info"heading="Did you know?"message="Coffee is a brewed drink prepared from roasted coffee beans."/><IcAlertvariant="error"heading="Americano order error"message="Americano couldn't be made, we ran out of beans."/><IcAlertvariant="warning"heading="Hot drink"message="Please be careful the drink is hot."/><IcAlertvariant="success"heading="Americano order complete"message="Success, your coffee is good to go."/>
Alert details
Props
All components also accept native properties supported by the DOM, such asclassName
and
style
.
|
|
|
---|---|---|
|
If |
|
|
If |
|
|
The optional title to display at the start of the alert. |
|
|
The main body message of the alert. |
|
|
If |
|
|
If |
|
|
The variant of the alert which will be rendered. |
|
If |
If |
The optional title to display at the start of the alert. |
The main body message of the alert. |
If |
If |
The variant of the alert which will be rendered. |
Slots
A slot allows for any type of element or markup to be passed into and rendered within a web component. This creates more flexibility than using a prop which must take a specific type of data.
Content can be slotted into a component by adding it as a top-level child of the component.
Slots can have a name to identify them. These specify which slot the content will be inserted into, and therefore where it will be rendered and how it will be used within the component. The name of the slot to be used can be specified by passing it via a
slot
attribute on the slotted content.
|
|
---|---|
|
|
|
|
|
|
|
|
|
Events
All components also accept native events supported by the DOM, such as
onClick
and
onKeyDown
.
|
|
|
---|---|---|
|
|
|
|
|
|
|
|
Variants
Dismissible
Interactive example
<ic-alertheading="Americano order nearly ready"message="Your coffee is nearly ready. We'll send you another alert once it is complete."dismissible="true"></ic-alert>
<IcAlertheading="Americano order nearly ready"message="Your coffee is nearly ready. We'll send you another alert once it is complete."dismissible/>
With action
Interactive example
<ic-alertvariant="info"heading="Did you know?"message="There is a new range of coffees to try."><ic-buttonslot="action"variant="secondary"appearance="dark">View Drinks</ic-button></ic-alert>
<IcAlertvariant="info"heading="Did you know?"message="There is a new range of coffees to try."><IcButtonslot="action"variant="secondary"appearance="dark"onClick={(ev)=>console.log(ev)}> View Drinks</IcButton></IcAlert>
Title above
Interactive example
<ic-alertheading="What is Coffee?"message="Coffee is a brewed drink prepared from roasted coffee beans, the seeds of berries from certain flowering plants in the Coffea genus."title-above="true"variant="info"></ic-alert>
<IcAlertheading="What is Coffee?"message="Coffee is a brewed drink prepared from roasted coffee beans, the seeds of berries from certain flowering plants in the Coffea genus."titleAbovevariant="info"/>
Responsive title
Interactive example
<ic-alertheading="Here you can find out lots more information about the world's favourite hot drink."message="Coffee is a brewed drink prepared from roasted coffee beans, the seeds of berries from certain flowering plants in the Coffea genus. From the coffee fruit, the seeds are separated to produce a stable, raw product: unroasted green coffee."variant="info"></ic-alert>
<IcAlertheading="Here you can find out lots more information about the world's favourite hot drink."message="Coffee is a brewed drink prepared from roasted coffee beans, the seeds of berries from certain flowering plants in the Coffea genus. From the coffee fruit, the seeds are separated to produce a stable, raw product: unroasted green coffee."variant="info"/>
Custom message
Interactive example
<ic-alertvariant="info"heading="Want to know more about our coffee?"><spanslot="message"> Go to our <ic-linkhref="/">coffee page</ic-link> to learn more.</span></ic-alert>
<IcAlertvariant="info"heading="Want to know more about our coffee?"><spanslot="message"> Go to our <IcLinkhref="/">coffee page</IcLink> to learn more.</span></IcAlert>
With custom icon
Interactive example
<ic-alertvariant="neutral"heading="Increased wait times"message="Due to unprecedented coffee demand, wait times may be longer than usual."><svgslot="neutral-icon"xmlns="http://www.w3.org/2000/svg"height="24"viewBox="0 0 24 24"width="24"fill="#000000"><pathd="M12,20A8,8 0 0,0 20,12A8,8 0 0,0 12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22C6.47,22 2,17.5 2,12A10,10 0 0,1 12,2M12.5,7V12.25L17,14.92L16.25,16.15L11,13V7H12.5Z"/></svg></ic-alert>
<IcAlertvariant="neutral"heading="Increased wait times"message="Due to unprecedented coffee demand, wait times may be longer than usual."><SlottedSVGslot="neutral-icon"xmlns="http://www.w3.org/2000/svg"height="24"viewBox="0 0 24 24"width="24"fill="#000000"><pathd="M12,20A8,8 0 0,0 20,12A8,8 0 0,0 12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22C6.47,22 2,17.5 2,12A10,10 0 0,1 12,2M12.5,7V12.25L17,14.92L16.25,16.15L11,13V7H12.5Z"/></SlottedSVG></IcAlert>
With no icon
Interactive example
<ic-alertheading="Order queued"show-default-icon="false"message="Your coffee order is in the queue. We'll notify you when it's ready to be picked up."></ic-alert>
<IcAlertheading="Order queued"showDefaultIcon="false"message="Your coffee order is in the queue. We'll notify you when it's ready to be picked up."></IcAlert>