# Loading States

Show spinners, disable buttons, and provide feedback during server requests.
Loading states appear automatically during method calls and property updates.

## Basic loading

Use `lace:loading` to show an element during any loading state.
Combine with `lace:loading.hidden` to hide elements while loading.

```interlace-demo
LoadingBasic
```

## First load vs refresh

`lace:loading.init` fires only for the initial deferred load (from `lace:init` or a lazy
component); `lace:loading.proceeding` fires for every load after that. A common pattern is a
**skeleton on first load** but a lighter treatment on refresh, since the data is already on
screen. Here the skeleton shows once, and later refreshes just dim the existing rows via
`lace:loading.proceeding.class`. Wait for the first load, then hit Refresh:

```interlace-demo LoadingInit
class LoadingInit(Component):
    rows: list = []

    def load(self):
        self.rows = fetch_activity()

    def inline_template(self):
        return """
        <div lace:init="load">
            <button lace:click="load">Refresh</button>

            {# first load only: a skeleton #}
            <div lace:loading.init class="animate-pulse">
                <div class="skeleton-row"></div>
                <div class="skeleton-row"></div>
            </div>

            {# the data: hidden on first load, dimmed on later refreshes #}
            <div lace:loading.init.hidden lace:loading.proceeding.class="opacity-40">
                {% for row in rows %}<div>{{ row }}</div>{% endfor %}
            </div>
        </div>
        """
```

## Targeted loading

Show different loading states for different actions using `lace:target`.
Each loader appears only when its specific method is called.

```interlace-demo
LoadingTargeted
```

## CSS class modifier

Add CSS classes during loading with `lace:loading.class`.
Useful for disabling buttons or dimming content without hiding it.

```interlace-demo
LoadingClass
```

## Live search loading

Loading states work with live model updates. Show a spinner while debounced searches execute.

```interlace-demo
LoadingSearch
```

## Reference

See [`lace:loading`](/docs/lace-loading/) for every modifier, and
[`lace:target`](/docs/lace-target/) for scoping a loader to specific methods.
