The Spinner widget provides a visual loading indicator for your Preswald application. It’s useful for indicating that content is being loaded or that an operation is in progress.

Properties

PropertyTypeRequiredDefaultDescription
labelstringNo’Loading…’Text displayed below the spinner
variantstringNo’default’Visual style variant (‘default’ or ‘card’)
classNamestringNoAdditional CSS classes to apply to the spinner
showLabelbooleanNotrueWhether to show the loading text label

Basic Usage

import preswald as pw

def app():
    pw.spinner(label="Loading data...")

pw.run(app)

Examples

Default Spinner

import preswald as pw

def app():
    pw.spinner()  # Uses default "Loading..." text

Custom Label

import preswald as pw

def app():
    pw.spinner(label="Fetching results...")

Card Variant

The card variant wraps the spinner in a card container for better visual hierarchy.

import preswald as pw

def app():
    pw.spinner(
        label="Processing...",
        variant="card"
    )

Hidden Label

import preswald as pw

def app():
    pw.spinner(showLabel=False)  # Shows only the spinning animation

Custom Styling

import preswald as pw

def app():
    pw.spinner(
        label="Please wait",
        className="bg-gray-100 rounded-lg"
    )

Notes

  • The spinner uses a clean, animated border design that’s visually appealing and lightweight
  • The card variant is useful when you want to emphasize the loading state in your layout
  • You can customize the appearance using the className property
  • The spinner is centered by default and works well in both inline and block contexts