Skip to main content
Yoummday Light Light Dark System

Feedback

<sl-feedback> | SlFeedback
Since 2.62.0 stable

Feedback allows users to quickly provide positive/negative feedback with optional reasoning.

<sl-feedback></sl-feedback>

Examples

Display Modes

Use the mode attribute to choose between icon-only or button display.



<sl-feedback mode="icon"></sl-feedback>
<br><br>
<sl-feedback mode="button"></sl-feedback>

Button mode uses the same default/primary variants as sl-button, so hover and selected states match the design system.

Labels

Use the labels property to provide custom text for the thumbs up/down buttons.



<sl-feedback id="feedback-icon-with-labels" mode="icon" ></sl-feedback>
<br><br>
<sl-feedback id="feedback-with-labels" mode="button" ></sl-feedback>


<script>
  const feedback = document.querySelector('#feedback-with-labels');
  const feedbackIcon = document.querySelector('#feedback-icon-with-labels');

  feedback.labels = ['Yes', 'No'];
  feedbackIcon.labels = ['Yes', 'No'];
</script>

Sizes

Use the size attribute to set the size of all feedback buttons.

Icon sizes





<sl-feedback size="small" mode="icon"></sl-feedback>
<br><br>
<sl-feedback size="medium" mode="icon"></sl-feedback>
<br><br>
<sl-feedback size="large" mode="icon"></sl-feedback>

Button sizes





<sl-feedback size="small" mode="button"></sl-feedback>
<br><br>
<sl-feedback size="medium" mode="button"></sl-feedback>
<br><br>
<sl-feedback size="large" mode="button"></sl-feedback>

With options

Use the options property to show a 3-dots menu with reasoning choices.

<sl-feedback id="feedback-with-options"></sl-feedback>

<script>
  const feedback = document.querySelector('#feedback-with-options');
  feedback.options = ["Don't show today", "Don't show for 7 days", "I'm not interested, turn it off"];
</script>

Listen to feedback

Listen for the sl-feedback event to receive { rating, reasoning? }. Ratings are 1 (thumbs up), 0 (thumbs down), and -1 when no selection has been made yet.

<sl-feedback id="feedback-example"></sl-feedback>

<script>
  const feedback = document.querySelector('#feedback-example');
  feedback.options = ["Don't show today", "Don't show for 7 days", "I'm not interested, turn it off"];

  feedback.addEventListener('sl-feedback', event => {
    console.log(event.detail);
    // { rating: 1 } or { rating: 0, reasoning: "Don't show today" }
  });
</script>

Importing

If you’re using the autoloader or the traditional loader, you can ignore this section. Otherwise, feel free to use any of the following snippets to cherry pick this component.

Script Import Bundler React

To import this component from the CDN using a script tag:

<script type="module" src="https://v3-4-0.yoummday-theme.pages.dev/components/feedback/feedback.js"></script>

To import this component from the CDN using a JavaScript import:

import 'https://v3-4-0.yoummday-theme.pages.dev/components/feedback/feedback.js';

To import this component using a bundler:

import '@yoummday/ymmd-shoelace/dist/components/feedback/feedback.js';

To import this component as a React component:

import SlFeedback from '@yoummday/ymmd-shoelace/dist/react/feedback';

Properties

Name Description Reflects Type Default
options Optional reasoning options rendered in a dropdown menu. string[] []
rating The current feedback rating. -1 | 0 | 1 -1
size The size of feedback buttons. 'small' | 'medium' | 'large' 'medium'
labels Optional labels for thumbs up/down. Provide two strings; omit to show icon-only. string[] []
mode The display mode of feedback buttons. 'button' | 'icon' 'icon'
updateComplete A read-only promise that resolves when the component has finished updating.

Learn more about attributes and properties.

Events

Name React Event Description Event Detail
sl-feedback onSlFeedback Emitted when the feedback value changes or a reasoning option is selected. { rating: -1 | 0 | 1, reasoning?: string }

Learn more about events.

Parts

Name Description
base The component’s base wrapper.
thumbs-up-button The thumbs up button.
thumbs-down-button The thumbs down button.
options-button The 3-dots options button.

Learn more about customizing CSS parts.

Dependencies

This component automatically imports the following dependencies.

  • <sl-button>
  • <sl-icon>
  • <sl-spinner>