--- title: TimeSlider frameworkTitle: html: time-slider description: A slider component for seeking through media content --- import { TimeSliderDemo } from '@/examples/react/TimeSlider/TimeSliderDemo'; import componentModuleStr from '@/examples/react/TimeSlider/BasicTimeSlider.tsx?raw'; import cssModuleStr from '@/examples/react/TimeSlider/TimeSlider.module.css?raw'; import htmlHorizontalStr from '@/examples/html/time-slider/snippet-horizontal.html?raw'; import htmlVerticalStr from '@/examples/html/time-slider/snippet-vertical.html?raw'; import htmlCssStr from '@/examples/html/time-slider/time-slider.css?raw'; import FrameworkCase from '@/components/docs/FrameworkCase.astro'; import Container from '@/components/docs/Container.astro'; import ServerCode from '@/components/Code/ServerCode.astro'; import { TabsRoot, TabsPanel } from '@/components/Tabs'; ## Features - Supports both horizontal and vertical orientations - Displays current playback position - Shows preview position on hover - Keyboard accessible (Arrow keys for seeking) - Touch-friendly drag interaction ## Example ## Compound Components TimeSlider is composed of multiple sub-components: ### TimeSlider.Root The container component that manages state and interactions. **Props:** - `orientation?: 'horizontal' | 'vertical'` - Slider orientation (default: 'horizontal') - All standard div props ### TimeSlider.Track The background track element that contains progress and pointer indicators. ### TimeSlider.Progress Visual indicator showing how much of the media has been played. ### TimeSlider.Pointer Shows the hover/preview position when user moves cursor over the slider. ### TimeSlider.Thumb The draggable handle that indicates and controls the current playback position. ## Data Attributes The TimeSlider automatically sets data attributes: - `data-orientation` - Current orientation ('horizontal' or 'vertical') - `data-current-time` - Current playback time in seconds - `data-duration` - Total media duration in seconds Use these attributes for state-based styling in your CSS. ## CSS Variables The component exposes CSS variables for positioning: - `--slider-fill` - Percentage of progress (0-100%) - `--slider-pointer` - Percentage of pointer position (0-100%) ## Accessibility - Includes proper ARIA role (`slider`) - Keyboard accessible (Arrow keys, Home, End) - Screen reader announcements for time values - Proper aria-valuemin, aria-valuemax, aria-valuenow attributes