logo polydile dile-components

dile-info-box

Web Component to create a customized information box.

Installation

npm i @dile/dile-info-box

Usage

Import the component.

  import '@dile/dile-info-box/dile-info-box.js';

Use the component.

<dile-info-box showCloseButton>Information message...</dile-info-box>

Properties

CSS Custom Properties

You can customize it using CSS Custom Properties.

Custom propertyDescriptionDefault
--dile-info-box-background-colorBackground color#ddd
--dile-info-box-border-radiusBox border radius0.8rem
--dile-info-box-paddingBox padding1rem
--dile-info-box-text-colorText color#303030
--dile-icon-colorInfo icon color#888
--dile-info-box-close-icon-colorClose icon color#f33
--dile-info-box-title-margin-bottomTitle margin bottom0.5rem
--dile-info-box-title-font-sizeTitle font size1.3rem
--dile-info-box-title-font-weightTitle font weightbold
--dile-info-box-title-text-colorTitle text colorinherit

dile-info-box demos

Default box

<dile-info-box>
  Info message
</dile-info-box>

Default box with title

<dile-info-box class="with-title" title="Hi from dile-components">
  Lorem ipsum, dolor sit amet consectetur adipisicing elit. Ea et aspernatur aliquam est deserunt illum explicabo quis id aut nulla.
</dile-info-box>

With close icon

<dile-info-box showCloseButton>
  This box has a close icon. Please, click at the icon and the box will dissapear with a smooth animation.
</dile-info-box>

Styled box

<style>
.styled {
  font-size: 1rem;
  --dile-icon-color: #bbdefb;
  --dile-info-box-background-color: #303030;
  --dile-info-box-text-color: white;
  --dile-info-box-border-radius: 2rem;
  --dile-info-box-title-text-color: #ffa;
}
</style>
<dile-info-box showCloseButton class="styled" title="I am the title!">
  Lorem ipsum dolor sit amet consectetur, adipisicing elit. Officiis quae at sequi! Earum tenetur dolorum, eaque deserunt nam cumque aut repellendus aliquid dolorem, numquam quo impedit praesentium explicabo quis. Sequi?
</dile-info-box>

Styled box warning

<style>
.stylederror {
  font-size: 1rem;
  --dile-icon-color: #f6f04a;
  --dile-info-box-background-color: #9c1111;
  --dile-info-box-text-color: white;
  --dile-info-box-border-radius: 0.2rem;
  --dile-info-box-title-text-color: #ffa;
  --dile-info-box-close-icon-color: #fff;
}
</style>
<dile-info-box isError showCloseButton class="stylederror" title="Error found!">
  Lorem ipsum dolor sit amet consectetur, adipisicing elit. Officiis quae at sequi! Earum tenetur dolorum, eaque deserunt nam cumque aut repellendus aliquid dolorem, numquam quo impedit praesentium explicabo quis. Sequi?
</dile-info-box>