Skip to content

Compound Components

When you pass children, the automatic UI (titlebar, indicator, shadows) is replaced entirely. You compose exactly what you want using the built-in sub-components.

ComponentDescription
FractionalRange.TitlebarFlex container for label and value, rendered above the slider.
FractionalRange.LabelDisplays the label text from context.
FractionalRange.ValueDisplays the current value with a sign prefix (+/-).
FractionalRange.IndicatorDotSmall colored dot indicator below the slider.
FractionalRange.ShadowsGradient shadows on the left and right edges.
import FractionalRange from 'fractionalrange'
function MySlider() {
return (
<FractionalRange
label="Volume"
min={0}
max={100}
step={1}
activeColor="#4ade80"
>
<FractionalRange.Titlebar>
<FractionalRange.Label />
<FractionalRange.Value />
</FractionalRange.Titlebar>
<FractionalRange.IndicatorDot />
<FractionalRange.Shadows />
</FractionalRange>
)
}

You can mix the built-in components with your own:

<FractionalRange label="Brightness" min={0} max={1} step={0.01}>
<FractionalRange.Titlebar>
<FractionalRange.Label />
<div className="flex items-center gap-2">
<ResetButton />
<FractionalRange.Value />
</div>
</FractionalRange.Titlebar>
<FractionalRange.Shadows />
</FractionalRange>

All sub-components accept standard HTML attributes including className and style:

<FractionalRange.Titlebar className="px-4 text-xs">
<FractionalRange.Label className="uppercase tracking-widest" />
<FractionalRange.Value className="font-bold" />
</FractionalRange.Titlebar>