🔥 新プロジェクトのご紹介 t0ggles - 究極のプロジェクト管理ツール! 🔥

レンジスライダー React コンポーネント

レンジスライダー コンポーネント

以下のコンポーネントが含まれています

  • Range (レンジ)

Range Props (レンジのプロパティ)

名前デフォルト説明
colors (カラー)object (オブジェクト)

Tailwind CSSカラースタイルクラスを持つオブジェクト

colors.thumbBgIosstring (文字列)'range-thumb:bg-white'
colors.thumbBgMaterialstring (文字列)'range-thumb:bg-md-light-primary dark:range-thumb:bg-md-dark-primary'
colors.valueBgIosstring (文字列)'bg-primary'
colors.valueBgMaterialstring (文字列)'bg-md-light-primary dark:bg-md-dark-primary'
component (コンポーネント)string (文字列)'div'

コンポーネントのHTML要素

defaultValue (デフォルト値)any (任意)

非制御コンポーネントの場合のレンジ値

disabled (無効)boolean (真偽値)false

レンジ入力が無効かどうかを定義します

inputId (入力ID)string (文字列)

レンジ入力のID属性

max (最大値)number (数値)100

レンジの最大値

min (最小値)number (数値)0

レンジの最小値

name (名前)string (文字列)

レンジ入力の名前

readOnly (読み取り専用)boolean (真偽値)false

レンジ入力が読み取り専用かどうかを定義します

step (ステップ)number (数値)1

レンジのステップ

value (値)any (任意)

レンジの値

onBlurfunction(e)

blur イベントハンドラ

onChangefunction(e)

change イベントハンドラ

onFocusfunction(e)

focus イベントハンドラ

onInputfunction(e)

input イベントハンドラ

RangeSlider.jsx
import React, { useState } from 'react';
import {
Page,
Navbar,
NavbarBackLink,
BlockTitle,
BlockHeader,
List,
ListItem,
Range,
} from 'konsta/react';
export default function RangeSliderPage() {
const [volume, setVolume] = useState(50);
const [price, setPrice] = useState(150);
const [red, setRed] = useState(100);
const [green, setGreen] = useState(50);
const [blue, setBlue] = useState(75);
return (
<Page>
<Navbar
title="Range Slider"
/>
<BlockTitle>Volume: {volume}</BlockTitle>
<BlockHeader>From 0 to 100 with step 10</BlockHeader>
<List strong insetMaterial outlineIos>
<ListItem
innerClassName="flex space-x-4 rtl:space-x-reverse"
innerChildren={
<>
<span>0</span>
<Range
value={volume}
step={10}
onChange={(e) => setVolume(e.target.value)}
/>
<span>100</span>
</>
}
/>
</List>
<BlockTitle>Price: ${price}</BlockTitle>
<BlockHeader>From 0 to 1000 with step 1</BlockHeader>
<List strong insetMaterial outlineIos>
<ListItem
innerClassName="flex space-x-4 rtl:space-x-reverse"
innerChildren={
<>
<span>$0</span>
<Range
value={price}
step={1}
min={0}
max={1000}
onChange={(e) => setPrice(e.target.value)}
/>
<span>$1000</span>
</>
}
/>
</List>
<BlockTitle>
Color: rgb({red}, {green}, {blue})
</BlockTitle>
<List strong insetMaterial outlineIos>
<ListItem
innerChildren={
<Range
className="k-color-brand-red"
value={red}
step={1}
min={0}
max={255}
onChange={(e) => setRed(e.target.value)}
/>
}
/>
<ListItem
innerChildren={
<Range
className="k-color-brand-green"
value={green}
step={1}
min={0}
max={255}
onChange={(e) => setGreen(e.target.value)}
/>
}
/>
<ListItem
innerChildren={
<Range
className="k-color-brand-blue"
value={blue}
step={1}
min={0}
max={255}
onChange={(e) => setBlue(e.target.value)}
/>
}
/>
</List>
</Page>
);
}
コードのライセンス MIT.
2022 © Konsta UI by nolimits4web.