{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "progress-bar",
  "type": "registry:item",
  "title": "Progress Bar",
  "description": "A bar that springs to each new amount with a sheen along the fill, a counting percentage and a green finish.",
  "categories": [
    "feedback"
  ],
  "dependencies": [
    "react-native-reanimated",
    "react-native-worklets"
  ],
  "registryDependencies": [
    "https://kinetik-ui.dev/r/kinetik-tokens.json",
    "https://kinetik-ui.dev/r/kinetik-motion.json",
    "https://kinetik-ui.dev/r/kinetik-count.json"
  ],
  "files": [
    {
      "path": "src/components/kinetik/progress-bar.tsx",
      "type": "registry:file",
      "target": "~/components/kinetik/progress-bar.tsx",
      "content": "import { useEffect, useState } from 'react';\nimport { StyleSheet, Text, View, type StyleProp, type ViewStyle } from 'react-native';\nimport Animated, {\n  cancelAnimation,\n  interpolateColor,\n  useAnimatedStyle,\n  useSharedValue,\n  withRepeat,\n  withSequence,\n  withSpring,\n  withTiming,\n} from 'react-native-reanimated';\n\nimport { useCountUp } from '../../lib/kinetik/hooks/use-count-up';\nimport { useReduceMotion } from '../../lib/kinetik/hooks/use-reduce-motion';\nimport { easings, spring, timing } from '../../lib/kinetik/motion/motion';\nimport { gradient } from '../../lib/kinetik/tokens/gradient';\nimport { useKinetikTheme } from '../../lib/kinetik/tokens/theme';\nimport { withAlpha } from '../../lib/kinetik/tokens/tokens';\n\nexport type ProgressBarProps = {\n  /** From 0 to 1, or null while the amount of work is unknown. */\n  value: number | null;\n  /** What is in progress, e.g. \"Uploading 3 photos\". Shown above the bar. */\n  label?: string;\n  /** The percentage on the right. Defaults to true. */\n  showValue?: boolean;\n  /** Bar thickness. Defaults to \"md\". */\n  size?: 'sm' | 'md';\n  /** Replaces the percentage once the bar is full. Defaults to \"Done\". */\n  doneLabel?: string;\n  testID?: string;\n  style?: StyleProp<ViewStyle>;\n};\n\n/**\n * A progress bar that springs to each new amount while a soft sheen travels\n * along the fill. The percentage counts up beside the label; at 100% the fill\n * turns green and \"Done\" takes the number's place. With no value it shows an\n * indeterminate segment that sweeps the track.\n */\nexport function ProgressBar({\n  value,\n  label,\n  showValue = true,\n  size = 'md',\n  doneLabel = 'Done',\n  testID,\n  style,\n}: ProgressBarProps) {\n  const { colors, font, radius, space } = useKinetikTheme();\n  const reduced = useReduceMotion();\n  const known = value !== null;\n  const v = known ? Math.min(1, Math.max(0, value)) : 0;\n  const done = known && v >= 1;\n  const percent = Math.round(v * 100);\n  const shown = useCountUp(percent, { duration: 600, instant: reduced });\n  const h = size === 'sm' ? 6 : 10;\n  const [width, setWidth] = useState(0);\n\n  const fill = useSharedValue(v);\n  const finish = useSharedValue(done ? 1 : 0);\n  const sweep = useSharedValue(0);\n  const pop = useSharedValue(done ? 1 : 0);\n\n  useEffect(() => {\n    fill.set(withSpring(v, spring('smooth', reduced)));\n  }, [v, reduced, fill]);\n  useEffect(() => {\n    finish.set(withTiming(done ? 1 : 0, timing('base', reduced)));\n    pop.set(\n      done\n        ? withSequence(withTiming(0, { duration: 0 }), withSpring(1, spring('bouncy', reduced)))\n        : 0,\n    );\n  }, [done, reduced, finish, pop]);\n\n  // The sheen (or the indeterminate segment) loops only while work is under way.\n  const moving = !done && !reduced && (!known || v > 0);\n  useEffect(() => {\n    if (!moving) {\n      cancelAnimation(sweep);\n      sweep.set(0);\n      return;\n    }\n    sweep.set(0);\n    sweep.set(\n      withRepeat(\n        withTiming(1, {\n          duration: known ? 1600 : 1300,\n          easing: known ? easings.linear : easings.inOut,\n        }),\n        -1,\n      ),\n    );\n    return () => cancelAnimation(sweep);\n  }, [moving, known, sweep]);\n\n  const bar = useAnimatedStyle(() => {\n    if (!known) {\n      const t = sweep.get();\n      const w = 0.28 + Math.sin(t * Math.PI) * 0.14;\n      return {\n        width: width * w,\n        transform: [{ translateX: -width * w + t * (width + width * w) }],\n        backgroundColor: colors.azure,\n      };\n    }\n    return {\n      width: Math.max(0, fill.get()) * width,\n      backgroundColor: interpolateColor(finish.get(), [0, 1], [colors.azure, colors.success]),\n    };\n  });\n  const sheen = useAnimatedStyle(() => ({\n    opacity: known && moving ? 1 : 0,\n    transform: [{ translateX: -80 + sweep.get() * (width + 80) }],\n  }));\n  const check = useAnimatedStyle(() => ({\n    opacity: pop.get(),\n    transform: [{ scale: 0.5 + pop.get() * 0.5 }],\n  }));\n\n  const light = withAlpha(colors.highlight, 0.45);\n  const clear = withAlpha(colors.highlight, 0);\n\n  return (\n    <View\n      testID={testID}\n      accessible\n      accessibilityRole=\"progressbar\"\n      accessibilityLabel={label ?? 'Progress'}\n      accessibilityValue={known ? { min: 0, max: 100, now: percent } : undefined}\n      accessibilityState={{ busy: !done }}\n      style={[{ gap: space[2] }, style]}\n    >\n      {label || showValue ? (\n        <View style={styles.header}>\n          <Text\n            numberOfLines={1}\n            style={[\n              styles.label,\n              { color: colors.text, fontSize: font.size.sm, fontWeight: font.weight.medium },\n            ]}\n          >\n            {label}\n          </Text>\n          {showValue && known ? (\n            done ? (\n              <Animated.View style={[styles.done, check]}>\n                <View style={[styles.tick, { borderColor: colors.success }]} />\n                <Text\n                  style={{\n                    color: colors.success,\n                    fontSize: font.size.sm,\n                    fontWeight: font.weight.semibold,\n                  }}\n                >\n                  {doneLabel}\n                </Text>\n              </Animated.View>\n            ) : (\n              <Text\n                style={{\n                  color: colors.textMuted,\n                  fontSize: font.size.sm,\n                  fontVariant: ['tabular-nums'],\n                }}\n              >\n                {Math.round(shown)}%\n              </Text>\n            )\n          ) : null}\n        </View>\n      ) : null}\n      <View\n        onLayout={(e) => setWidth(e.nativeEvent.layout.width)}\n        style={[\n          styles.track,\n          { height: h, backgroundColor: colors.track, borderRadius: radius.pill },\n        ]}\n      >\n        <Animated.View style={[styles.fill, { borderRadius: radius.pill }, bar]}>\n          <Animated.View\n            style={[\n              styles.sheen,\n              gradient(`linear-gradient(to right, ${clear}, ${light}, ${clear})`),\n              sheen,\n            ]}\n          />\n        </Animated.View>\n      </View>\n    </View>\n  );\n}\n\nconst styles = StyleSheet.create({\n  header: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 12 },\n  label: { flex: 1 },\n  done: { flexDirection: 'row', alignItems: 'center', gap: 6 },\n  tick: {\n    width: 10,\n    height: 6,\n    borderLeftWidth: 2,\n    borderBottomWidth: 2,\n    transform: [{ rotate: '-45deg' }],\n    marginTop: -3,\n  },\n  track: { overflow: 'hidden' },\n  fill: { position: 'absolute', left: 0, top: 0, bottom: 0, overflow: 'hidden' },\n  sheen: { position: 'absolute', top: 0, bottom: 0, width: 80 },\n});\n"
    }
  ],
  "meta": {
    "version": "1.0.0",
    "kind": "component",
    "platforms": [
      "ios",
      "android",
      "web"
    ],
    "category": "feedback",
    "web": "live",
    "perf": {
      "budget": "Plain views and four shared values. The sheen loops on the UI thread only while work is under way; a finished bar is idle.",
      "measurements": [
        {
          "device": "Pixel 9 emulator, API 35",
          "kind": "emulator",
          "date": "2026-10-13",
          "build": "release",
          "frameMs": 21,
          "p90Ms": 23,
          "baselineMs": 18,
          "jankyPercent": 0,
          "atRest": "animating",
          "memoryMb": 146,
          "notes": "The demo advances the bar every 0.9 s, so the sheen was running at rest; a finished bar draws nothing."
        }
      ]
    },
    "a11y": {
      "reducedMotion": "The fill jumps to each value with no sheen; the indeterminate bar holds still.",
      "screenReader": "A progress bar named by its label with a 0 to 100 value, marked busy until it is done.",
      "touchTarget": "Not interactive."
    },
    "requires": "React Native New Architecture (Reanimated 4)",
    "guide": "## Usage\n\n```tsx\nimport { ProgressBar } from '@/components/kinetik/progress-bar';\n\n<ProgressBar label=\"Uploading 12 photos\" value={sent / total} />;\n\n// Unknown length:\n<ProgressBar label=\"Preparing the export\" value={null} />;\n```\n\n## When to use\n\n- Work that takes more than a second or two and whose amount is known: uploads, downloads, installs, imports.\n- With `value={null}` for work whose length is unknown yet, switching to a value once it is.\n\n## When not to use\n\n- Short waits under a second. Show nothing, or a spinner on the button (Status Button).\n- Quotas or limits that are not work in progress. Use Usage Meter.\n\n## Notes\n\n- The fill springs to each new value and the percentage counts up; a sheen travels along the fill while work is under way and stops at rest.\n- At 100% the fill turns green and `doneLabel` replaces the number.\n- It is a `progressbar` with a 0–100 value for screen readers, busy until done; indeterminate bars have no value.\n- With reduced motion the fill jumps, the number changes at once and there is no sheen or sweep.\n"
  },
  "docs": "Prefer `npx kinetik-ui add progress-bar`: it installs dependencies with expo install, so versions match your Expo SDK."
}
