# SeekButton

Accessible seek button for skipping forward or backward by a configurable number of seconds

## Import

```tsx
import { SeekButton } from '@videojs/react';
```

## Anatomy

```tsx
<SeekButton />
```

## Behavior

Seeks media by a configurable number of `seconds` (default 30). Positive values seek forward, negative values seek backward. The seek is clamped to media bounds (0 to duration).

## Accessibility

Renders a `<button>` with an automatic `aria-label` describing the action, e.g. “Seek forward 30 seconds” or “Seek backward 10 seconds”. Override with the `label` prop. Keyboard activation: Enter / Space.

## Examples

### Basic Usage

**App.tsx**

```tsx
import { Container, createPlayer, SeekButton } from '@videojs/react';
import { Video, videoFeatures } from '@videojs/react/video';

const { Player } = createPlayer({ features: videoFeatures });

export default function BasicUsage() {
  return (
    <Player>
      <Container className="media-container">
        <Video src="https://stream.mux.com/BV3YZtogl89mg9VcNBhhnHm02Y34zI1nlMuMQfAbl3dM/highest.mp4" autoPlay muted playsInline loop />
        <div className="buttons">
          <SeekButton
            seconds={-5}
            className="media-seek-button"
            render={(props, state) => (
              <button {...props}>
                {state.direction === 'backward' ? '\u23EA' : '\u23E9'} {5}s
              </button>
            )}
          />
          <SeekButton
            seconds={10}
            className="media-seek-button"
            render={(props, state) => (
              <button {...props}>
                {10}s {state.direction === 'forward' ? '\u23E9' : '\u23EA'}
              </button>
            )}
          />
        </div>
      </Container>
    </Player>
  );
}
```

**App.css**

```css
.media-container {
  position: relative;
}

.media-container video {
  width: 100%;
}

.buttons {
  position: absolute;
  bottom: 10px;
  left: 10px;
  display: flex;
  gap: 8px;
}

.media-seek-button {
  padding-block: 8px;
  padding-inline: 20px;
  color: black;
  white-space: nowrap;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 9999px;
  backdrop-filter: blur(10px);
}
```

## API Reference

### Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `disabled` | `boolean` | `false` | Whether the button is disabled. |
| `label` | `{ key: string; text: string } \| string \| ((state: SeekButtonState) => Text \| string)` | `''` | Custom label for the button. |
| `seconds` | `number` | `30` | Seconds to seek. Positive = forward, negative = backward. Default `30`. |

### State

State is accessible via the `render`, `className`, and `style` props.

| Property | Type | Description |
| --- | --- | --- |
| `label` | `{ key: string; text: string } \| string` | |
| `seeking` | `boolean` | Whether a seek is in progress. |
| `direction` | `'forward' \| 'backward'` | Whether the button seeks forward or backward. |

### Data attributes

| Attribute | Type | Description |
| --- | --- | --- |
| `data-seeking` | — | Present when a seek is in progress. |
| `data-direction` | `'forward' \| 'backward'` | Indicates the seek direction: `"forward"` or `"backward"`. |

---

React documentation: https://videojs.org/docs/framework/react/llms.txt
All documentation: https://videojs.org/llms.txt
