Skip to main content
Clever Ops

Size & Fit Bar

A size selector row with radiogroup keyboard semantics, honest stock states where sold-out sizes stay visible but disabled, a quiet true-to-size fit note, and a size-guide link.

Preview & code

Loading Size & Fit Bar preview

Installation

pnpm dlx shadcn@latest add @cleverui/size-fit-bar

Requires the @cleverui registry in your components.json, a one-off, two-line setup.

Usage

tsx
import { SizeFitBar } from '@/components/ui/size-fit-bar'
Exampletsx
'use client'

import { useState } from 'react'
import { SizeFitBar } from '@/components/ui/size-fit-bar'

const SIZES = [
  { label: 'XS', stock: 'in' as const },
  { label: 'S', stock: 'in' as const },
  { label: 'M', stock: 'low' as const },
  { label: 'L', stock: 'in' as const },
  { label: 'XL', stock: 'out' as const },
  { label: 'XXL', stock: 'in' as const },
]

export default function SizeFitBarDemo() {
  const [size, setSize] = useState('M')

  return (
    <div className="mx-auto flex w-full max-w-md justify-center px-4 py-10 sm:px-6 sm:py-14">
      <SizeFitBar
        label="Size"
        sizes={SIZES}
        value={size}
        onChange={setSize}
        fitNote="True to size, take your usual"
        lowStockLabel="Low stock"
        sizeGuideLabel="Size guide"
        sizeGuideHref="#size-guide"
      />
    </div>
  )
}

API reference

SizeFitBar accepts the following props.

PropTypeDefaultDescription
labelstring'Size'micro-label above the row
sizes*SizeOption[]
valuestringcontrolled selected size, the bar holds no state
onChange(size: string) => voidfired when an in-stock size is chosen
fitNotestring'True to size, take your usual'quiet guidance under the row
lowStockLabelstring'Low stock'shown beside the fit note when the selected size is low
sizeGuideLabelstring'Size guide'
sizeGuideHrefstringrenders the guide affordance as an anchor
onSizeGuide() => voidused when no href, opens your guide dialog

…plus everything from Omit<React.HTMLAttributes<HTMLElement>, 'onChange'>: className, event handlers, aria attributes and the rest pass straight through.

Referenced types

Typestsx
export interface SizeOption {
  label: string
  /** defaults to 'in' */
  stock?: SizeStock
}

export type SizeStock = 'in' | 'low' | 'out'

Frequently asked questions

How do I install the Size & Fit Bar component?

Register the @cleverui registry in your components.json ("@cleverui": "https://cleverops.com.au/r/{name}.json"), then run `npx shadcn@latest add @cleverui/size-fit-bar`. The shadcn CLI copies the source into your project, you own the code from that point. You can also copy the source directly from this page.

What dependencies does Size & Fit Bar require?

Size & Fit Bar uses motion and lucide-react on top of React and Tailwind CSS. You don't need to install them manually, the shadcn CLI resolves and installs npm dependencies automatically when you add the component.

Can I theme Size & Fit Bar to match my brand?

Yes. The component is styled entirely with Tailwind utilities over standard design tokens (primary, background, muted, border), so it inherits your existing shadcn/ui theme automatically. Change your CSS variables and the component follows, no source edits needed for palette, radius, or fonts.

Want this built for you?

CleverUI is built by the Clever Ops web team. If you'd rather ship a hand-coded, fast, custom website than assemble one, we build them for Australian businesses every week.

Explore web development services