Alert
This page is currently under construction
Lism UI (@lism-css/ui) is still in preparation.
Use this component to emphasize short messages.
Overview
↓
Preview
Lorem ipsum dolor sit amet. Consectetur adipiscing elit, sed do eiusmod tempor Incididunt ut.
Resize
<Alert> <p>Lorem ipsum dolor sit amet. Consectetur adipiscing elit, sed do eiusmod tempor Incididunt ut.</p></Alert><div class="b--alert l--flex u--cbox" style="--keycolor:var(--red)"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" width="1em" height="1em" fill="currentColor" focusable="false" class="a--icon" aria-hidden="true"><path d="M120,136V80a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0ZM232,91.55v72.9a15.86,15.86,0,0,1-4.69,11.31l-51.55,51.55A15.86,15.86,0,0,1,164.45,232H91.55a15.86,15.86,0,0,1-11.31-4.69L28.69,175.76A15.86,15.86,0,0,1,24,164.45V91.55a15.86,15.86,0,0,1,4.69-11.31L80.24,28.69A15.86,15.86,0,0,1,91.55,24h72.9a15.86,15.86,0,0,1,11.31,4.69l51.55,51.55A15.86,15.86,0,0,1,232,91.55Zm-16,0L164.45,40H91.55L40,91.55v72.9L91.55,216h72.9L216,164.45ZM128,160a12,12,0,1,0,12,12A12,12,0,0,0,128,160Z"></path></svg> <div class="l--flow -flow:s"> <p>Lorem ipsum dolor sit amet. Consectetur adipiscing elit, sed do eiusmod tempor Incididunt ut.</p> </div></div>Styles
The base styles for Alert are defined in the following CSS.
_style.css
@layer lism-block {
/* Note: u--cbox との併用を前提としています。layout="withSide" 指定時は l--withSide がレイアウトを上書きします. */
.b--alert {
--bds: solid;
--bdw: 1px;
--bdc: var(--divider); /* u--cbox 併用時は u--cbox 側の --bdc が優先される */
align-items: center;
gap: var(--s15);
padding: var(--s15);
border: var(--bdw) var(--bds) var(--bdc);
border-radius: var(--bdrs--10);
}
.b--alert > .a--icon {
color: var(--keycolor);
font-size: var(--fz--xl);
}
/* memo: layout="withSide" を考慮し、flex: 1 ではなく width: 100% で本文幅を確保している */
.b--alert > .l--flow {
width: 100%;
}
} The full source code is available on GitHub.
Usage
Provided as Alert from the @lism-css/ui package.
Import
import { Alert } from '@lism-css/ui/react'; import { Alert } from '@lism-css/ui/astro'; <link href="https://cdn.jsdelivr.net/npm/@lism-css/ui@0.28.0/dist/style.css" rel="stylesheet" /> Props
| Prop | Description |
|---|---|
type | Specifies a preset value combining keycolor and icon. Default: "alert" |
icon | Specifies the icon to pass to the Icon component. Preset icons can be specified with just a string. |
keycolor | Specifies the key color. |
flow | Passed to the flow prop of the Flow element that wraps the content. Default: "s" |
layout | Switches the layout primitive. Default: "flex" |
Examples
Custom Color and Icon
↓
Example
icon=“good” keycolor=“green”
<Alert icon="good" keycolor="green"> <p>icon="good" keycolor="green"</p></Alert><div class="b--alert l--flex u--cbox" style="--keycolor:var(--green)"> <svg class="a--icon"...>...</svg> <div class="l--flow -flow:s"> <p>icon="good" keycolor="green"</p> </div></div>Responsive Layout with l--withSide
↓
Preview
On narrow screens, the icon and text stack vertically.
Resize
<Alert type="check" layout="withSide"> <p>On narrow screens, the icon and text stack vertically.</p></Alert><div class="b--alert l--withSide u--cbox" style="--keycolor:var(--green)"> <svg class="a--icon is--side"...>...</svg> <div class="l--flow -flow:s"> <p>On narrow screens, the icon and text stack vertically.</p> </div></div>Alert with a Button and Breakpoint-Responsive Layout
↓
Preview
On narrow screens, the icon, text, and button stack vertically.
Button Resize
<Alert type="info" fxd={["column","row"]}> <Flex ai="center" jc="between" fxd={["column","row"]} g="15"> <p>On narrow screens, the icon, text, and button stack vertically.</p> <Button href="#" bdrs="10" fxsh="0" fz="s" bgc="link">Button</Button> </Flex></Alert><div class="b--alert l--flex u--cbox -fxd:column -fxd_sm" style="--keycolor:var(--blue);--fxd_sm:row"> <svg class="a--icon"...>...</svg> <div class="l--flow -flow:s"> <div class="l--flex -ai:center -jc:between -fxd:column -fxd_sm -g:15" style="--fxd_sm:row"> <p>On narrow screens, the icon, text, and button stack vertically.</p> <a class="b--button -hov:-o -bdrs:10 -fxsh:0 -fz:s -bgc" style="--bgc:var(--link)" href="#">Button</a> </div> </div></div>Available Types
↓
Specifying type
type=“alert”: Example text.
type=“point”: Example text.
type=“warning”: Example text.
type=“check”: Example text.
type=“info”: Example text.
type=“help”: Example text.
type=“note”: Example text.
Resize
<Alert type="alert">...</Alert><Alert type="point">...</Alert><Alert type="warning">...</Alert><Alert type="check">...</Alert><Alert type="info">...</Alert><Alert type="help">...</Alert><Alert type="note">...</Alert><div class="b--alert l--flex u--cbox" style="--keycolor:var(--red)"> <svg class="a--icon"...>...</svg> <div class="l--flow -flow:s">type="alert": Example text.</div></div><!-- type="point" → --keycolor:var(--orange) --><!-- type="warning" → --keycolor:var(--yellow) --><!-- type="check" → --keycolor:var(--green) --><!-- type="info" → --keycolor:var(--blue) --><!-- type="help" → --keycolor:var(--purple) --><!-- type="note" → --keycolor:var(--gray) -->Without @lism-css/ui
This example builds the Alert with lism-css primitives only, without @lism-css/ui.
↓
Preview
Lorem ipsum dolor sit amet. Consectetur adipiscing elit, sed do eiusmod tempor Incididunt ut.
Resize
<WithSide util="cbox" keycolor="red" ai="center" p="15" g="15" bd bdrs="10"> <Center isSide c="keycolor" fz="xl"> <Icon icon="alert" /> </Center> <Flow flow="s"> <p>Lorem ipsum dolor sit amet. Consectetur adipiscing elit, sed do eiusmod tempor Incididunt ut.</p> </Flow></WithSide><div class="l--withSide u--cbox -ai:center -p:15 -g:15 -bd -bdrs:10" style="--keycolor: var(--red)"> <div class="l--center is--side -c:keycolor -fz:xl"> <svg xmlns="http://www.w3.org/2000/svg" class="a--icon" viewBox="0 0 256 256" width="1em" height="1em" fill="currentColor" focusable="false" aria-hidden="true" > <path d="M120,136V80a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0ZM232,91.55v72.9a15.86,15.86,0,0,1-4.69,11.31l-51.55,51.55A15.86,15.86,0,0,1,164.45,232H91.55a15.86,15.86,0,0,1-11.31-4.69L28.69,175.76A15.86,15.86,0,0,1,24,164.45V91.55a15.86,15.86,0,0,1,4.69-11.31L80.24,28.69A15.86,15.86,0,0,1,91.55,24h72.9a15.86,15.86,0,0,1,11.31,4.69l51.55,51.55A15.86,15.86,0,0,1,232,91.55Zm-16,0L164.45,40H91.55L40,91.55v72.9L91.55,216h72.9L216,164.45ZM128,160a12,12,0,1,0,12,12A12,12,0,0,0,128,160Z" ></path> </svg> </div> <div class="l--flow -flow:s"> <p>Lorem ipsum dolor sit amet. Consectetur adipiscing elit, sed do eiusmod tempor Incididunt ut.</p> </div></div>