Skip to content

Styling ​

The library contains only critical styles to layout the notifications container and notification itself. It can be easily customized using custom css. You will probably only need to style .o-notification element.

Elements contains several variables to easily style them, without changing style properties.

HTML tree ​

html
<div class="o-notifications-container">
  <div class="o-notification type--info">
    <div class="o-notification-body">
      <div class="o-notification-icon">...</div>

      <div class="o-notification-content">...</div>

      <button class="o-notification-close">...</button>
    </div>
  </div>

  <div class="o-notification type--default">
    <div class="o-notification-body">
      <div class="o-notification-icon">...</div>
      
      <div class="o-notification-content">...</div>
    </div>
  </div>
</div>

.o-notifications-container ​

Variables ​

VariableTypeDefaultDescription
--o-spacinglength0.5remSpacing between notifications
--o-offsetlength1remOffset from edge of window
--o-max-widthlength26.25remMax width

.o-notification ​

Notification is a man element of your notifications.

Variables ​

VariableTypeDefaultDescription
--o-paddinglength0.75remPadding
--o-gaplength0.75remSpacing between content
--o-sizelength1.5remSize of icon and close button
--o-colorcolorinitialBackground color
--o-border-widthlength1pxBorder width
--o-border-colorcolorinitialBorder color
--o-text-colorcolorcurrentColorText color
--o-icon-sizelength1.5remIcon size
--o-icon-colorcolorcurrentColorIcon color
scss
// You can define colors for each notification type (default, info, success, warning, error).
$types: (
  'default' : (
    'color' : '#F6F5FF',
    'border-color': '#CBCAFC',
    'icon-color': '#564AF7',
  ),
  'error' : (
    'color' : '#FFF0F0',
    'border-color': '#FFC2C2',
    'icon-color': '#FF0000',
  ),
);

.o-notification {
  border-radius: 10px;

  // and loop over types to set colors based on a class
  @each $type, $values in $types {
    &.type--#{$type} {
      @each $name, $value in $values {
        --o-#{$name}: #{$value};
      }
    }
  }

  .o-notification-title {
    font-size: 16px;
    font-weight: 600;
    color: #121827;
  }

  .o-notification-text {
    font-size: 14px;
    font-weight: 400;
    color: #384050;
  }

  .o-notification-close {
    background: none;
    opacity: 0.5;
    transition: opacity .3s;

    &:hover {
      opacity: 1;
    }
  }
}