Content
Use the slot property to inject content into a Modal without detaching. Simply turn the card content into a local component and swap it out with the slot.
Modals are overlay components used for tasks or decisions that require user focus and confirmation. They block access to the main interface and should be used only for critical actions or information that cannot appear inline. When a modal appears, a background overlay using black at 25% opacity (RGBA 0,0,0,0.25) is applied.
For more information on ModelValues please have a look to the Vue's Data Binding section.
const modelValue = defineModel<boolean>('modelValue', {
required: true,
default: false,
});export interface ModalProps {
title?: string;
closeOnClick?: boolean;
size?: 'narrow' | 'wide';
closeButton?: boolean;
headingIcon?: IconName;
headerSize?: 'default' | 'tiny';
content?: any;
infoText?: string;
actions?: (AppButtonProps & {
component?: 'AppButton',
text: string;
onClick: () => void;
} | Omit<LinkProps, 'to'> & {
component: 'Link',
to?: string;
text: string;
onClick: () => void;
})[];
}NOTE
Submit Event (@submit): Triggered when user clicks the default submit button or any other button who's onClick function calls the submit component method.
If you want to use the built-in code control, it is strongly recommended that you define your actions to include one of the exposed util functions cancel or submit via the component ref.
<script lang="ts" setup>
const pg = reactive({
modelValue: false,
title: 'Dialog Window',
closeOnClick: true,
size: 'wide' as NonNullable<ModalProps['size']>,
closeButton: true,
actions: [
{
text: 'Link',
component: 'Link' as const,
type: 'primary' as NonNullable<LinkProps['type']>,
onClick: () => {
console.log('Cancel');
modalRef.value?.cancel();
},
},
{
text: 'Secondary',
secondary: true,
icon: 'close' as IconName,
onClick: () => {
console.log('Close');
modalRef.value?.cancel();
},
},
{
text: 'Primary',
icon: 'send' as IconName,
trailingIcon: true,
onClick: () => {
console.log('Send');
modalRef.value?.submit();
},
},
],
});
const modalRef = useTemplateRef<InstanceType<typeof Modal>>('modal');
const showModal = () => {
modalRef.value?.showModal({
title: 'Opened via code',
size: pg.size,
closeButton: pg.closeButton,
headingIcon: 'ai' as IconName,
});
};
</script>
<template>
<Modal ref="modal" v-bind="pg" v-model="pg.modelValue" :headingIcon="icon">
Here is your modal content definition
<Logo :brand="'PohlCon'" />
</Modal>
</template>--bds-brand-primary-color--color-grey-90--color-grey-25--color-grey-70Use the slot property to inject content into a Modal without detaching. Simply turn the card content into a local component and swap it out with the slot.
Show or hide a heading Icon
Show or hide a close button