Progress
neobrutal-ui/progressFreeComponent
neobrutal-ui publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by neobrutal-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://neobrutal-ui.andongmin.com/r/progress.jsonSource
1"use client";23import { Progress as ProgressPrimitive } from "@base-ui/react/progress";4import { mergeProps } from "@base-ui/react/merge-props";5import * as React from "react";67import { cn } from "@/lib/utils";89type RenderProps = React.HTMLAttributes<HTMLElement> & { ref?: React.Ref<HTMLElement> };1011function mergeRefs(...refs: (React.Ref<HTMLElement> | undefined)[]) {12 return (element: HTMLElement | null) => {13 refs.forEach((ref) => {14 if (typeof ref === "function") {15 ref(element);16 } else if (ref) {17 ref.current = element;18 }19 });20 };21}2223function preserveRadixEventCancellation(24 child: React.ReactElement<{ [key: string]: unknown; children?: React.ReactNode }>,25) {26 const eventProps: Record<string, unknown> = {};2728 for (const [name, handler] of Object.entries(child.props)) {29 if (/^on[A-Z]/.test(name) && typeof handler === "function") {30 eventProps[name] = (...args: unknown[]) => {31 (handler as (...handlerArgs: unknown[]) => void)(...args);32 const event = args[0] as33 | { defaultPrevented?: boolean; preventBaseUIHandler?: () => void }34 | undefined;35 if (event?.defaultPrevented) event.preventBaseUIHandler?.();36 };37 }38 }3940 return React.cloneElement(child, eventProps);41}4243function renderWithAliases<State>(44 render:45 | React.ReactElement46 | ((props: RenderProps, state: State) => React.ReactElement)47 | undefined,48 fallback: React.ReactElement,49 getAliases: (state: State) => Record<string, string | undefined>,50) {51 return (elementProps: RenderProps, state: State) => {52 const aliasedProps = mergeProps(53 elementProps as React.ComponentPropsWithRef<"div">,54 getAliases(state) as React.ComponentPropsWithRef<"div">,55 ) as RenderProps;5657 if (typeof render === "function") {58 return render(aliasedProps, state);59 }6061 const element = (render ?? fallback) as React.ReactElement<RenderProps>;62 const mergedProps = mergeProps(63 aliasedProps as React.ComponentPropsWithRef<"div">,64 element.props as React.ComponentPropsWithRef<"div">,65 ) as RenderProps;66 mergedProps.ref = mergeRefs(aliasedProps.ref, element.props.ref);67 return React.cloneElement(element, mergedProps);68 };69}7071function getChildElement(children: React.ReactNode, componentName: string) {72 const child = React.Children.toArray(children).find(React.isValidElement);73 if (child === undefined) {74// … truncated
What it pulls in
npm packages
Files it writes
More from neobrutal-ui
All 100 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | neobrutal-ui | Components | Free | 1 dep | |
| Alertalert | neobrutal-ui | Components | Free | no deps | |
| Alert dialogalert-dialog | neobrutal-ui | Components | Free | 1 dep | |
| Avataravatar | neobrutal-ui | Components | Free | 1 dep | |
| Badgebadge | neobrutal-ui | Components | Free | no deps | |
| Breadcrumbbreadcrumb | neobrutal-ui | Components | Free | 1 dep | |
| Buttonbutton | neobrutal-ui | Components | Free | 1 dep | |
| Calendarcalendar | neobrutal-ui | Components | Free | 1 dep |
