---
title: "范围"
type: component
version: "2.2.1"
doc_version: "2.5.2"
status: stable
date: 2026-06-30
library: Frutjam
stack: tailwind_css
compatibility: universal
framework_agnostic: true
runtime_requirement: none
description: "Tailwind CSS Range 使用本机 HTML 输入。可访问的滑块具有用于设置面板、过滤器和数字控件的自定义步骤、尺寸和颜色。"
url: https://frutjam.com/zh-hans/components/range
---

# 范围成分

Range components allow users to select a numeric value within a defined range using an interactive slider. Built with native HTML range inputs and smooth styling, range sliders provide intuitive control over continuous values. The Frutjam range system supports multiple sizes, colors, and states—ideal for volume controls, price filters, and timeline scrubbing.

CSS-only, no JavaScript required. WCAG AA accessible and framework-agnostic — works with Django, HTMX, Laravel, React, and any stack.

| Class           | Type  | Description               |
| --------------- | ----- | ------------------------- |
| range           | Base  | Styled range slider input |
| range-xs        | Size  | Extra small               |
| range-sm        | Size  | Small                     |
| range-md        | Size  | Medium (default)          |
| range-lg        | Size  | Large                     |
| range-xl        | Size  | Extra large               |
| range-primary   | Color | Primary theme color       |
| range-secondary | Color | Secondary theme color     |
| range-accent    | Color | Accent theme color        |
| range-neutral   | Color | Neutral theme color       |
| range-info      | Color | Info semantic color       |
| range-success   | Color | Success semantic color    |
| range-warning   | Color | Warning semantic color    |
| range-error     | Color | Error semantic color      |

## Basic Usage

## Range Sizes

```html
<input type="range" min="0" max="100" value="40" class="range range-xs">
<input type="range" min="0" max="100" value="40" class="range range-sm">
<input type="range" min="0" max="100" value="40" class="range range-md">
<input type="range" min="0" max="100" value="40" class="range range-lg">
<input type="range" min="0" max="100" value="40" class="range range-xl">
```

## Range Colors

```html
<input type="range" min="0" max="100" value="40" class="range">
<input type="range" min="0" max="100" value="40" class="range range-primary">
<input type="range" min="0" max="100" value="40" class="range range-secondary">
<input type="range" min="0" max="100" value="40" class="range range-accent">
<input type="range" min="0" max="100" value="40" class="range range-info">
<input type="range" min="0" max="100" value="40" class="range range-success">
<input type="range" min="0" max="100" value="40" class="range range-warning">
<input type="range" min="0" max="100" value="40" class="range range-error">
```

## Range with Steps

```html
<input type="range" min="0" max="100" step="10" value="40" class="range">
<input type="range" min="0" max="100" step="5" value="40" class="range range-primary">
<input type="range" min="0" max="100" step="1" value="40" class="range range-secondary">
```

## Range with Label

```html
<label>
  <span class="block text-sm font-medium mb-2">Volume</span>
  <input type="range" min="0" max="100" value="70" class="range range-primary">
</label>

<label>
  <span class="block text-sm font-medium mb-2">Price Range: $20 - $80</span>
  <input type="range" min="0" max="100" value="50" class="range">
</label>
```

## Disabled Range

```html
<input type="range" min="0" max="100" value="40" class="range" disabled>
```

## Range with Marks

```html
<div>
  <div class="flex justify-between text-xs mb-2">
    <span>0</span>
    <span>25</span>
    <span>50</span>
    <span>75</span>
    <span>100</span>
  </div>
  <input type="range" min="0" max="100" value="50" class="range range-primary w-full">
</div>
```

