Skip to content

Hatched Bar

Distinguish pending, projected or baseline amounts from settled values with hatching.

import { Hatch, HatchedBar } from '@youj/react'

Installation & usage

npm i @youj/react

For an app already set up with npx @youj/cli init, which installs the peers (@youj/core, @youj/motion, motion and Base UI) and wires the provider. New app? Start at Installation.

A hatch says "not settled": a baseline to compare against, an amount that's pending, projected or reserved, a run that missed its gate. HatchedBar is a bar of it that grows to a value, and Hatch is the fill on its own, for legend swatches and for a pending segment inside another bar. Keep solid for the actual amount beside it, so the two read as a pair.

import { Hatch, HatchedBar } from '@youj/react'

<HatchedBar value={0.64} className="h-32 w-6" label="Projected usage" />
<HatchedBar value={0.72} fill="solid" tone="accent" orientation="horizontal" />
<Hatch className="size-3" />

value is out of max (default 1). A bar grows up from the bottom, or from the inline start when orientation="horizontal"; size it with classes. fill="solid" draws the settled amount: in neutral tone that's a quiet fill, so a colored bar beside it stands out. The hatch is diagonal stripes of the tone over a faint wash of it, so it follows the theme in both modes.

Reference

Propsvalue, max, fill… (8)

Props

HatchedBar props
PropType
valueRequirednumber

The bar's length, out of max.

–
maxnumber

default 1

1
fill'hatched' | 'solid'

Hatched for a baseline, pending or projected amount; solid for an actual one.

default 'hatched'

'hatched'
orientation'vertical' | 'horizontal'

Horizontal grows from the inline start.

default 'vertical'

'vertical'
toneHatchTone
'accent''neutral''success''warning''danger''chart-1''chart-2''chart-3''chart-4''chart-5'

default 'neutral'

'neutral'
labelstring

Accessible name. With it the bar is a meter; without, it is hidden from assistive technology.

–
valueTextstring

The value as spoken. Default: the share of max as a percentage, in the provider's locale.

–
Other props pass through: extends ComponentProps<'div'>.
Hatch props
PropType
toneHatchTone
'accent''neutral''success''warning''danger''chart-1''chart-2''chart-3''chart-4''chart-5'

The stripes' color.

default 'neutral'

'neutral'
Other props pass through: extends ComponentProps<'span'>.
MotionGrow, new value · reduced motion

Motion

Motion tokens
MomentTokens
Growfrom its base when a third of it scrolls into view, once; a clip, so the stripes never stretch
spring.smooth

0.36s, bounce 0

0.36s, bounce 0
New valueretargets from where it is
spring.smooth

0.36s, bounce 0

0.36s, bounce 0

Reduced motion

Drawn at its value; a new value jumps.

Reduced motion

Bars are drawn at their value, and changes land at once.

AccessibilityLabels and assistive technology

Accessibility

  • With label the bar is a meter with its orientation, and speaks its share of max as a percentage (or your valueText). Without, it's hidden from assistive technology.
  • Hatch is always decorative: say what it marks in a legend or in the text beside it.
  • A pattern is not a color, so hatched and solid stay apart in grayscale and for color-blind readers.