Skip to content

Feedback

Spinner

tsx
import { Spinner } from "@cherry-design-system/react";

export function LoadingResults() {
  return <Spinner label="Loading results" />;
}

Spinner is a spinning loader icon for short waits. The icon is inlined, so no icon import is needed. For work with a measurable length, use Progress; to hold a layout while content loads, use Skeleton.

Examples

Sizes

tsx
import { Spinner } from "@cherry-design-system/react";

export function Sizes() {
  return (
    <>
      <Spinner size="xs" />
      <Spinner size="sm" />
      <Spinner size="md" />
      <Spinner size="lg" />
    </>
  );
}

Next to visible text

When the text next to it already says that something is loading, pass label={null} so the state is not announced twice.

tsx
import { Spinner } from "@cherry-design-system/react";

export function Saving() {
  return (
    <span role="status">
      <Spinner label={null} /> Saving changes
    </span>
  );
}

Properties

size"sm" | "md" | "lg" | "xs"

Icon size. Defaults to "sm".

labelstring | null

Accessible label. Defaults to "Loading". Pass null when a parent already announces the busy state.

Spinner renders a <span>, forwards its ref to it and passes every other <span> attribute through. It has no client JavaScript, so it is safe in Server Components.

Styling

HookValues
.cherry-spinnerRoot element
data-sizexs, sm, md, lg

The icon reads --cherry-fg-muted. Set color on the spinner to change it. The rotation slows down under prefers-reduced-motion.

Accessibility

With a label the spinner is a role="status" announcement. Pass label={null} when visible text nearby already says it is loading.