Customize the close button as texts or other symbols.
Alert allows you to configure if it's closable. The close button text and closing callbacks are also customizable. closable attribute decides if the component can be closed or not. It accepts boolean, and the default is true. You can set close-text attribute to replace the default cross symbol as the close button. Be careful that close-text must be a string. close event fires when the component is closed.
export function AlertCenter() { return ( <div style={box}> <ElAlert title="Primary alert" type="primary" center showIcon /> <ElAlert title="Success alert" type="success" center showIcon style={gap} /> <ElAlert title="Info alert" type="info" center showIcon style={gap} /> <ElAlert title="Warning alert" type="warning" center showIcon style={gap} /> <ElAlert title="Error alert" type="error" center showIcon style={gap} /> </div> );}
With Description
Description includes a message with more detailed information.
Besides the required title attribute, you can add a description attribute to help you describe the alert with more details. Description can only store text string, and it will word wrap automatically.
With description
This is a description.
export function AlertDescription() { return ( <div style={box}> <ElAlert title="With description" type="success" description="This is a description." /> </div> );}
With Icon and Description
At last, this is an example with both icon and description.
Primary alert
More text description
Success alert
More text description
Info alert
More text description
Warning alert
More text description
Error alert
More text description
export function AlertIconDescription() { return ( <div style={box}> <ElAlert title="Primary alert" type="primary" description="More text description" showIcon /> <ElAlert title="Success alert" type="success" description="More text description" showIcon style={gap} /> <ElAlert title="Info alert" type="info" description="More text description" showIcon style={gap} /> <ElAlert title="Warning alert" type="warning" description="More text description" showIcon style={gap} /> <ElAlert title="Error alert" type="error" description="More text description" showIcon style={gap} /> </div> );}