[//]: # (This file is auto-generated by the docs:generate-skills script, do not edit it manually)

# LoadingBar

Import: `import { LoadingBar } from '@neo4j-ndl/react'`

## Props

### LoadingBar

| Prop | Type | Required | Default | Description |
|------|------|----------|---------|-------------|
| `as` | `ElementType<any, keyof IntrinsicElements>` |  |  | An override of the default HTML tag of the root of the component. Can also be another React component. |
| `hasRail` | `boolean` |  | `false` | Whether the loading bar has a background rail |
| `loadingMessage` | `string` |  | `Loading` | Visually hidden message for screen readers, for example "Loading search results". |
| `ref` | `any` |  |  | A ref to apply to the root element. |

## Accessibility

## Implementation guidelines

`LoadingBar` renders an element with `role="status"` that contains visually hidden text.

- The text defaults to "Loading". Use `loadingMessage` to say what is loading, for example "Loading search results".
- Screen readers may not announce the bar when it is added to the page already populated. Announce the loading state yourself, for example by updating a persistent `role="status"` element in your application.

### Related WCAG criteria

- [1.1.1 Non-text Content](https://www.w3.org/WAI/WCAG22/Understanding/non-text-content.html) (A): The bar has a visually hidden text alternative that can be customized
- [2.2.2 Pause, Stop, Hide](https://www.w3.org/WAI/WCAG22/Understanding/pause-stop-hide.html) (A): The indicator animates continuously but loading indicators are generally treated as essential movement.
- [4.1.2 Name, Role, Value](https://www.w3.org/WAI/WCAG22/Understanding/name-role-value.html) (A): The bar exposes the `status` role
- [4.1.3 Status Messages](https://www.w3.org/WAI/WCAG22/Understanding/status-messages.html) (AA): The application is responsible for announcing the loading state, see above

## Examples

### Default

```tsx
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';

import { LoadingBar } from '@neo4j-ndl/react';

const Component = () => {
  return <LoadingBar />;
};

export default Component;
```

### With Rail

```tsx
import '@neo4j-ndl/base/lib/neo4j-ds-styles.css';

import { LoadingBar } from '@neo4j-ndl/react';

const Component = () => {
  return <LoadingBar hasRail />;
};

export default Component;
```
