A spinner is an animated indicator that lets users know content or action is being loaded.
Use a spinner to indicate a short, indeterminate loading state. It can appear on its own or paired with a loading message. For longer processes with measurable progress, use the progress bar component.
To use spinner, import DAFF_SPINNER_COMPONENTS directly into your custom component:
import { DAFF_SPINNER_COMPONENTS } from '@daffodil/design/spinner';
@Component({
selector: 'custom-component',
templateUrl: './custom-component.component.html',
imports: [
DAFF_SPINNER_COMPONENTS,
],
})
export class CustomComponent {}
Labels are used to describe the loading state and provide context for users. They are optional.
<daff-spinner>
<daff-spinner-label>Loading products...</daff-spinner-label>
</daff-spinner>
Use the color property to change the color of a spinner.
Note:
dark,light, andthemeshould be used on appropriate backgrounds for sufficient contrast.
Use the size proeprty to change the size of a spinner. The default size is md.
The spinner has role="status" which announces content changes to assistive technologies.
When using <daff-spinner-label>, the visible text serves as the accessible name. When no label is provided, the spinner defaults to aria-label="loading". You can customize this with the aria-label input:
<daff-spinner aria-label="Saving changes"></daff-spinner>