Dialog
Dialog
Component demo
Interactive example
<ic-buttononclick="showDialog()">Launch dialog</ic-button><ic-dialogid="default-dialog"heading="Are you sure?"label="Coffee order"><ic-typography> You are about to add 'Americano' to your basket. Are you sure you want to continue?</ic-typography></ic-dialog>
<IcButtononClick={handleDialogOpen}>Launch dialog</IcButton><IcDialogheading="Are you sure?"label="Coffee order"open={openDialog}// Set state to false if dismiss button is clickedonIcDialogClosed={openDialog && handleDialogClose}onIcDialogConfirmed={handleDialogClose}onIcDialogCancelled={handleDialogClose}><IcTypography> You are about to add 'Americano' to your basket. Are you sure you want to continue?</IcTypography></IcDialog>
Dialog details
Props
All components also accept native properties supported by the DOM, such asclassName
and
style
.
|
|
|
---|---|---|
|
If set to |
|
|
If set to |
|
|
If default buttons are displayed, sets the 'primary' or rightmost button to the destructive variant. Stops initial focus being set on the 'primary' or rightmost default or slotted button. |
|
|
If set to |
|
|
If set to |
|
|
Sets the dismiss label tooltip and aria label. |
|
|
Sets the heading for the dialog. |
|
|
If |
|
|
Sets the optional label for the dialog which appears above the heading. |
|
|
If |
|
|
Sets the maximum and minimum height and width for the dialog. |
|
|
Sets the theme color to the dark or light theme color. "inherit" will set the color based on the system settings or ic-theme component. |
|
If set to |
If set to |
If default buttons are displayed, sets the 'primary' or rightmost button to the destructive variant. Stops initial focus being set on the 'primary' or rightmost default or slotted button. |
If set to |
If set to |
Sets the dismiss label tooltip and aria label. |
Sets the heading for the dialog. |
If |
Sets the optional label for the dialog which appears above the heading. |
If |
Sets the maximum and minimum height and width for the dialog. |
Sets the theme color to the dark or light theme color. "inherit" will set the color based on the system settings or ic-theme component. |
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.
|
|
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
CSS Custom Properties
|
|
---|---|
|
|
|
Events
All components also accept native events supported by the DOM, such as
onClick
and
onKeyDown
.
|
|
|
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Methods
|
|
|
---|---|---|
|
|
|
|
|
|
|
|
Variants
Sizes
Interactive example
<ic-buttononclick="showDialog()">Launch dialog</ic-button><ic-dialogid="size-dialog"heading="Are you sure?"label="Coffee order"><ic-typography> You are about to add 'Americano' to your basket. Are you sure you want to continue?</ic-typography></ic-dialog>
<IcButtononClick={handleDialogOpen}>Launch sizes dialog</IcButton><IcDialogsize="large"// "small" | "medium" | "large"open={openDialog}label="Coffee order"heading="Are you sure?"onIcDialogClosed={openDialog && handleDialogClose}onIcDialogConfirmed={handleDialogClose}onIcDialogCancelled={handleDialogClose}><IcTypography> You are about to add 'Americano' to your basket. Are you sure you want to continue?</IcTypography></IcDialog>
With status alerts
Interactive example
<ic-buttononclick="showDialog('#status-dialog')">Launch status dialog</ic-button><ic-dialogid="status-dialog"heading="Are you sure?"label="Coffee order"size="medium"><ic-alertslot="alert"heading="They're both good"message="Some say tea is just as good as coffee."variant="neutral"title-above="true"></ic-alert><ic-typography> You are about to add 'Americano' to your basket. Are you sure you want to continue?</ic-typography></ic-dialog>
<IcButtonvariant="primary"onClick={handleDialogOpen}> Launch status dialog</IcButton><IcDialogopen={openDialog}heading="Are you sure?"label="Coffee order"onIcDialogClosed={openDialog && handleDialogClose}onIcDialogConfirmed={handleDialogClose}onIcDialogCancelled={handleDialogClose}size="medium"><IcAlertslot="alert"heading="They're both good"message="Some say tea is just as good as coffee."variant="neutral"// "neutral" | "info" | "warn" | "error" | "success" titleAbove/><IcTypography> You are about to add 'Americano' to your basket. Are you sure you want to continue?</IcTypography></IcDialog>
Slotted buttons
Interactive example
<ic-buttononclick="showDialog()">Launch dialog</ic-button><ic-dialogid="slotted-dialog"heading="Are you sure?"label="Coffee order"><ic-typography> You are about to add 'Americano' to your basket. Are you sure you want to continue?</ic-typography><ic-buttonslot="dialog-controls"variant="secondary"onclick="hideDialog()"> Go back</ic-button><ic-buttonslot="dialog-controls"onclick="addToBasket()"> Add to basket</ic-button></ic-dialog>
<IcButtononClick={handleDialogOpen}>Launch slotted buttons dialog</IcButton><IcDialogheading="Are you sure?"label="Coffee order"open={openDialog}onIcDialogClosed={openDialog && handleDialogClose}><IcTypography> You are about to add 'Americano' to your basket. Are you sure you want to continue?</IcTypography><IcButtonslot="dialog-controls"variant="secondary"onClick={handleDialogClose}> Go back</IcButton><IcButtonslot="dialog-controls"onClick={handleAddToBasket}> Add to basket</IcButton></IcDialog>
Interactive content
Interactive example
<ic-buttononclick="showDialog()">Launch dialog</ic-button><ic-dialogid="interactive-content-dialog"label="Coffee order"heading="Please agree to our terms and conditions"><ic-typography> Before continuing, please agree to our terms and conditions.</ic-typography><ic-checkbox-groupname="terms"label="terms and conditions"hide-label="true"><ic-checkboxlabel="I agree to the terms and conditions."value="agree"></ic-checkbox></ic-checkbox-group></ic-dialog>
<IcButtononClick={handleDialogOpen}>Launch dialog</IcButton><IcDialogopen={openDialog}label="Coffee order"heading="Please agree to our terms and conditions"onIcDialogClosed={openDialog && handleDialogClose}onIcDialogConfirmed={termsDialogConfirmed}onIcDialogCancelled={handleDialogClose}><IcTypography> Before continuing, please agree to our terms and conditions.</IcTypography><IcCheckboxGroupname="terms"label="terms and conditions"hideLabelonIcChange={toggleTermsAgreed}className={classes.checkboxGroup}><IcCheckboxlabel="I agree to the terms and conditions."value="agree"/></IcCheckboxGroup></IcDialog>
Background close prevented
Interactive example
<ic-buttononclick="showDialog()">Launch dialog</ic-button><ic-dialogid="no-close-dialog"close-on-backdrop-click="false"label="Background close prevented"heading="This dialog can't be closed by clicking the background"><ic-typography> You are about to add 'Americano' to your basket. Are you sure you want to continue?</ic-typography></ic-dialog>
<IcButtononClick={handleDialogOpen}>Launch dialog</IcButton><IcDialogopen={openDialog}closeOnBackdropClick={false}label="Background close prevented"heading="This dialog can't be closed by clicking the background"onIcDialogClosed={openDialog && handleDialogClose}onIcDialogConfirmed={handleConfirmDialog}onIcDialogCancelled={handleDialogClose}><IcTypography> You are about to add 'Americano' to your basket. Are you sure you want to continue?</IcTypography></IcDialog>
Events
Interactive example
<ic-buttononclick="showDialog()">Launch dialog</ic-button><ic-dialogid="ev-dialog"heading="Are you sure?"label="Coffee order"><ic-typography> You are about to add 'Americano' to your basket. Are you sure you want to continue?</ic-typography><ic-buttonvariant="tertiary"onclick="cancelDialog()"slot="dialog-controls"> Cancel</ic-button><ic-buttononclick="confirmDialog()"slot="dialog-controls"> Confirm</ic-button></ic-dialog>
<IcButtononClick={handleDialogOpen}>Launch dialog</IcButton><IcDialogopen={openDialog}heading="This dialog utilises events"label="Events"onIcDialogOpened={handleDialogOpened}onIcDialogConfirmed={handleDialogConfirmed}onIcDialogCancelled={handleDialogCancelled}onIcDialogClosed={handleDialogClosed}><IcTypography> You are about to add 'Americano' to your basket. Are you sure you want to continue?</IcTypography><IcButtonvariant="tertiary"onClick={handleSlottedCancel}slot="dialog-controls"> Cancel</IcButton><IcButtononClick={handleSlottedConfirm}slot="dialog-controls"> Confirm</IcButton></IcDialog>
Disabled height constraint
Interactive example
<ic-buttononclick='showDialog()'>Launch disabled height constraint dialog</ic-button><ic-dialoglabel='Coffee order'heading='Please add your milk?'disable-height-constraint='true'><ic-typography>Sure, let's dive into the delightful world of milk, where dairy dreams and coffee collide in the harmonious dance of a flat white. Picture this: you stroll into your favorite coffee haunt, the aroma of freshly ground beans tickling your senses. You approach the counter, ready to make a crucial decision – what kind of milk will accompany your flat white?</ic-typography><br/><ic-typography>In the end, whether you go for the classic, embrace the trendy, or opt for the exotic, the flat white remains a canvas waiting to be painted with your milk of choice. So, next time you're at the coffee counter, let your taste buds embark on a journey – a journey where milk and coffee meet, and every sip tells a story, sprinkled with a dash of humor and a whole lot of flavor. Cheers to the caffeinated adventure!</ic-typography><br/><ic-selectlabel='Please select a type of milk'></ic-select></ic-dialog>
<IcButtononClick={handleDialogOpen}>Launch disabled height constraint dialog</IcButton><IcDialoglabel='Coffee order'heading="Please add your milk"disableHeightConstraintopen={openDialog}onIcDialogConfirmed={openDialog && handleDialogClose}onIcDialogCancelled={handleDialogClose}><IcTypography> Sure, let's dive into the delightful world of milk, where dairy dreams and coffee collide in the harmonious dance of a flat white. Picture this: you stroll into your favorite coffee haunt, the aroma of freshly ground beans tickling your senses. You approach the counter, ready to make a crucial decision – what kind of milk will accompany your flat white?</IcTypography><br/><IcTypography> In the end, whether you go for the classic, embrace the trendy, or opt for the exotic, the flat white remains a canvas waiting to be painted with your milk of choice. So, next time you're at the coffee counter, let your taste buds embark on a journey – a journey where milk and coffee meet, and every sip tells a story, sprinkled with a dash of humor and a whole lot of flavor. Cheers to the caffeinated adventure!</IcTypography><br/><IcSelectlabel='Select a type of milk'options={[{ value:'whole', label:'Whole'},{ value:'semiskinned', label:'Semi Skinned'},{ value:'oat', label:'Oat'},{ value:'almond', label:'Almond'}]}/></IcDialog>
Theme
Interactive example
<ic-buttononclick="showDialog()">Launch dialog</ic-button><ic-dialogid="default-dialog"heading="Are you sure?"label="Coffee order"theme="dark"><ic-typography> You are about to add 'Americano' to your basket. Are you sure you want to continue?</ic-typography></ic-dialog>
<IcButtononClick={handleDialogOpen}>Launch dialog</IcButton><IcDialogheading="Are you sure?"label="Coffee order"theme="dark"open={openDialog}// Set state to false if dismiss button is clickedonIcDialogClosed={openDialog && handleDialogClose}onIcDialogConfirmed={handleDialogClose}onIcDialogCancelled={handleDialogClose}><IcTypography> You are about to add 'Americano' to your basket. Are you sure you want to continue?</IcTypography></IcDialog>