Lion Logo Lion Guides Components Docs Blog Toggle darkmode

Helpers: Action Logger

A visual element to show action logs in demos sb-action-logger

You need some reference to your logger. Above example shows this by using a unique ID.

const uid = Math.random().toString(36).substr(2, 10);

This connects the logger element to the trigger.

<div>To log: <code>Hello, World!</code></div>
  @click=${e => {'#logger-${uid}').log('Hello, World!')
>Click this button</button>
<sb-action-logger id="logger-${uid}"></sb-action-logger>

This is a demonstrative tool, not a debugging tool (although it may help initially). If you try logging complex values such as arrays, objects or promises, you should expect to get only the string interpretation as the output in this logger.


  • A public method log to log things to the action logger.
  • Overridable title property.
  • Clear button to clear logs
  • A counter to count the total amount of logs
  • Stacks consecutive duplicate logs and shows a counter
  • simple property/attribute to only show a single log


npm i @lion/helpers


Simple mode

Simple mode essentially means there is only ever 1 log. Duplicates are not counted or stacked, but you will still see the visual cue.

<sb-action-logger simple></sb-action-logger>

Custom Title

You can customize the action logger title with the .title property.

<sb-action-logger .title=${'Hello World'}></sb-action-logger>


This component was created due to a need for a nice visual action logger in Storybook Docs mode.

In docs mode, you do not have access to the action logger addon component, and it is nice to be able to show actions inline in your demos and documentation.


I added quite a bit of styling on this component to make it look decent. There are a bunch of styles that you can easily override to make it fit your design system which I believe should be enough in most cases. If you need more control you can always:

  • Override the host styles, there's a few custom CSS props that you can override as well.
  • Extend the component and apply your overrides
  • Open an issue if you believe it would be good to make something more flexible / configurable

Maybe in the future I will abstract this component to a more generic (ugly) one with no styles, so it's more friendly as a shared component.


If you use an action logger inside your Story in Storybook, you will also see it in your canvas, and this may not be your intention.

One idea is to simplify the usage further by making this a Storybook (docs-)plugin or decorator or whatever. It would be cool if someone can simply enable an action logger option on a particular Story inside their .mdx, and then actions are automatically logged to the visual logger below it. Would need to figure out how to catch the action and pass it to the visual logger element.

Isn't investigated yet on the how, but that is the rough idea.


New planned features can be found in the test folder where they are specified as skipped tests. If the feature you'd like is not in the tests, feel free to make an issue so we can add it.

See our for more guidelines on how to contribute.