Skip to content
lab components / Actions and controls

Starred

A Starred button allows users to easily like, save, or prioritize an item. It often pins the item to the top of a list or collection for quick access.

This is a Lab component!

That means it doesn't satisfy our definition of done and may be changed or even deleted. For an exact status, please reach out to the Fancy team through the dev_fancy or ux_fancy channels.

import { Starred } from "@siteimprove/fancylab";

#Examples

Use default starred variant for users to toggle the starred state of an item, and enable starring on most lists to allow customisation.

Composition:

  • Icon only button: the primary interactive element.
  • Star Icon: The primary visual element.
  • Tooltip (Recommended): A brief text label appearing on hover or focus (e.g., "Marked as favorite").

Interaction:

  • Default (Unstarred): An outlined star icon is used to show the item is not starred.
  • Hover: A blue round square border and shadow displayed to indicate that is clickable.
  • Starred: Typically, a filled star icon is used to indicate the item is starred.
  • Disabled: The icon appears in a visually muted state (e.g., grayed out) with no interaction.
const [starred, setStarred] = useState(false); return ( <Starred isStarred={starred} onChange={setStarred} aria-label="Pin/unpin whatever this item is" /> );

Disable the starred button when the user cannot star an item (e.g., due to permissions) or in read-only views.

const [starred, setStarred] = useState(false); return ( <Starred isStarred={starred} onChange={setStarred} aria-label="Pin/unpin whatever this item is" disabled /> );

#Properties

PropertyDescriptionDefinedValue
isStarredRequired
booleanIf true, the element selected is starred
onChangeRequired
functionExecutes once starred button has changed
aria-labelOptional
stringDescribe what happens if the button is clicked
disabledOptional
booleanCan the button be clicked
data-observe-keyOptional
stringUnique string, used by external script e.g. for event tracking
classNameOptional
stringCustom className that's applied to the outermost element (only intended for special cases)
styleOptional
objectStyle object to apply custom inline styles (only intended for special cases)
tabIndexOptional
numberTab index of the outermost HTML element of the component
onKeyDownOptional
functionCallback for onKeyDown event
onMouseDownOptional
functionCallback for onMouseDown event
onMouseEnterOptional
functionCallback for onMouseEnter event
onMouseLeaveOptional
functionCallback for onMouseLeave event
onFocusOptional
functionCallback for onFocus event
onBlurOptional
functionCallback for onBlur event

#Guidelines

#Best practices

#General

Use Starred when

  • Users need to quickly mark or bookmark items of interest.
  • The list or collection of items can benefit from personalization.

#Placement

Starred is typically used in the following places:

#Style

  • Siteimprove Design System: Adhere to Siteimprove's guidelines for color, typography, and spacing. If you are not using a component from Fancy, match the styling of your Starred to existing components for visual consistency.

#Do not use when

  • A more specific action is appropriate (e.g., "Prioritise issue in SEO Insights" ).
  • The star icon might be confused with rating functionality.

#Accessibility

For designers

  • Use adequate color contrast for all states of the button.
  • Ensure the touch/click target is large enough.
  • Provide alternative text for screen readers (e.g., "Star item" or "Unstar item").

For developers

This component comes with built-in accessibility, no extra work required.

Explore detailed guidelines for this component: Accessibility Specifications

#Writing

Tooltip/Label Text

  • Starred: "Starred" (or "Favorited")
  • Unstarred: "Star" (or "Favorite")