@shoelace-style/shoelace

sl-alert

Alerts are used to display important messages inline or as toast notifications.

Properties
nametypedefaultdescriptionattributereflectsstatic
dependencies
{ "text": "object" }
{ 'sl-icon-button': SlIconButton } - - - true
base
{ "text": "HTMLElement" }
- - - - -
open
{ "text": "boolean" }
falseIndicates whether or not the alert is open. You can toggle this attribute to show and hide the alert, or you can use the `show()` and `hide()` methods and this attribute will reflect the alert's open state.opentrue -
closable
{ "text": "boolean" }
falseEnables a close button that allows the user to dismiss the alert.closabletrue -
variant
{ "text": "'primary' | 'success' | 'neutral' | 'warning' | 'danger'" }
'primary'The alert's theme variant.varianttrue -
duration - InfinityThe length of time, in milliseconds, the alert will show before closing itself. If the user interacts with the alert before it closes (e.g. moves the mouse over it), the timer will restart. Defaults to `Infinity`, meaning the alert will not close on its own.duration - -
Attributes
namedefaultdescriptionfieldNametyperesolveInitializer
openfalseIndicates whether or not the alert is open. You can toggle this attribute to show and hide the alert, or you can use the `show()` and `hide()` methods and this attribute will reflect the alert's open state.open
{ "text": "boolean" }
-
closablefalseEnables a close button that allows the user to dismiss the alert.closable
{ "text": "boolean" }
-
variant'primary'The alert's theme variant.variant
{ "text": "'primary' | 'success' | 'neutral' | 'warning' | 'danger'" }
-
durationInfinityThe length of time, in milliseconds, the alert will show before closing itself. If the user interacts with the alert before it closes (e.g. moves the mouse over it), the timer will restart. Defaults to `Infinity`, meaning the alert will not close on its own.duration -
{ "module": "src/components/alert/alert.component.ts" }
CSS Parts
namedescription
baseThe component's base wrapper.
iconThe container that wraps the optional icon.
messageThe container that wraps the alert's main content.
close-buttonThe close button, an `<sl-icon-button>`.
close-button__baseThe close button's exported `base` part.
Slots
namedescription
The alert's main content.
iconAn icon to show in the alert. Works best with `<sl-icon>`.
Events
namedescriptionreactNameeventName
sl-showEmitted when the alert opens.onSlShowSlShowEvent
sl-after-showEmitted after the alert opens and all animations are complete.onSlAfterShowSlAfterShowEvent
sl-hideEmitted when the alert closes.onSlHideSlHideEvent
sl-after-hideEmitted after the alert closes and all animations are complete.onSlAfterHideSlAfterHideEvent
Methods
namedescription
handleOpenChange -
handleDurationChange -
showShows the alert.
hideHides the alert
toastDisplays the alert as a toast notification. This will move the alert out of its position in the DOM and, when dismissed, it will be removed from the DOM completely. By storing a reference to the alert, you can reuse it by calling this method again. The returned promise will resolve after the alert is hidden.

sl-avatar

Avatars are used to represent a person or object.

Properties
nametypedefaultdescriptionattributestaticreflects
dependencies
{ "text": "object" }
{ 'sl-icon': SlIcon } - - true -
image
{ "text": "string" }
''The image source to use for the avatar.image - -
label
{ "text": "string" }
''A label to use to describe the avatar to assistive devices.label - -
initials
{ "text": "string" }
''Initials to use as a fallback when no image is available (1-2 characters max recommended).initials - -
loading
{ "text": "'eager' | 'lazy'" }
'eager'Indicates how the browser should load the image.loading - -
shape
{ "text": "'circle' | 'square' | 'rounded'" }
'circle'The shape of the avatar.shape - true
Attributes
nametypedefaultdescriptionfieldName
image
{ "text": "string" }
''The image source to use for the avatar.image
label
{ "text": "string" }
''A label to use to describe the avatar to assistive devices.label
initials
{ "text": "string" }
''Initials to use as a fallback when no image is available (1-2 characters max recommended).initials
loading
{ "text": "'eager' | 'lazy'" }
'eager'Indicates how the browser should load the image.loading
shape
{ "text": "'circle' | 'square' | 'rounded'" }
'circle'The shape of the avatar.shape
CSS Properties
namedescription
--sizeThe size of the avatar.
CSS Parts
namedescription
baseThe component's base wrapper.
iconThe container that wraps the avatar's icon.
initialsThe container that wraps the avatar's initials.
imageThe avatar image. Only shown when the `image` attribute is set.
Slots
namedescription
iconThe default icon to use when no image or initials are present. Works best with `<sl-icon>`.
Methods
name
handleImageChange

sl-breadcrumb

Breadcrumbs provide a group of links so users can easily navigate a website's hierarchy.

Properties
nametypedefaultstaticdescriptionattribute
dependencies
{ "text": "object" }
{ 'sl-icon': SlIcon }true - -
defaultSlot
{ "text": "HTMLSlotElement" }
- - - -
separatorSlot
{ "text": "HTMLSlotElement" }
- - - -
label
{ "text": "string" }
'' - The label to use for the breadcrumb control. This will not be shown on the screen, but it will be announced by screen readers and other assistive devices to provide more context for users.label
Attributes
nametypedefaultdescriptionfieldName
label
{ "text": "string" }
''The label to use for the breadcrumb control. This will not be shown on the screen, but it will be announced by screen readers and other assistive devices to provide more context for users.label
CSS Parts
namedescription
baseThe component's base wrapper.
Slots
namedescription
One or more breadcrumb items to display.
separatorThe separator to use between breadcrumb items. Works best with `<sl-icon>`.