React Alert Component Styling
Alert Styling
New Year sale. Skyrocket your business in 2025!
Extra 25% off for all sale items + Free CoreUI Icons PRO with every order!
Limited-time offer for the first 100 customers in 2025. Use code 2025SKY25 at checkout.
Limited-time offer for the first 100 customers in 2025. Use code 2025SKY25 at checkout.
Learn how to customize the React Alert component with CSS classes, variables, and SASS for flexible styling and seamless integration into your design.
On this page
CSS variables#
React Alert supports CSS variables for easy customization. These variables are set via SASS but allow direct overrides in your stylesheets or inline styles.
--cui-alert-bg: transparent;--cui-alert-padding-x: #{$alert-padding-x};--cui-alert-padding-y: #{$alert-padding-y};--cui-alert-margin-bottom: #{$alert-margin-bottom};--cui-alert-color: inherit;--cui-alert-border-color: transparent;--cui-alert-border: #{$alert-border-width} solid var(--cui-alert-border-color);--cui-alert-border-radius: #{$alert-border-radius};--cui-alert-link-color: inherit;
How to use CSS variables#
const customVars = { '--cui-alert-color': '#333', '--cui-alert-bg': '#f8f9fa',}
return <CAlert style={customVars}>{/* Alert content */}</CAlert>
SASS variables#
$alert-padding-y: $spacer !default;$alert-padding-x: $spacer !default;$alert-margin-bottom: 1rem !default;$alert-border-radius: var(--cui-border-radius) !default;$alert-link-font-weight: $font-weight-bold !default;$alert-border-width: var(--cui-border-width) !default;$alert-dismissible-padding-r: $alert-padding-x * 3 !default; // 3x covers width of x plus default padding on either side