Delta Bar
solid-ui/delta-barFreeComponent
A delta bar component
Live preview
live · rendered by the registry
Rendered by solid-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://www.solid-ui.com/r/delta-bar.jsonSource
1import { mergeProps, Show, splitProps, type Component, type ComponentProps } from "solid-js"23import { cn } from "~/lib/utils"45type DeltaBarProps = ComponentProps<"div"> & {6 value: number7 isIncreasePositive?: boolean8}910const DeltaBar: Component<DeltaBarProps> = (rawProps) => {11 const props = mergeProps(12 {13 isIncreasePositive: true14 },15 rawProps16 )17 const [local, others] = splitProps(props, ["value", "isIncreasePositive", "class"])1819 const barColor = () =>20 (local.value > 0 && local.isIncreasePositive) || (local.value < 0 && !local.isIncreasePositive)21 ? "bg-success-foreground"22 : "bg-error-foreground"2324 return (25 <div26 class={cn("relative flex h-2 w-full items-center rounded-full bg-secondary", local.class)}27 {...others}28 >29 <div class="flex h-full w-1/2 justify-end">30 <Show when={local.value < 0}>31 <div32 class={cn("rounded-l-full", barColor())}33 style={{ width: `${Math.abs(local.value)}%` }}34 />35 </Show>36 </div>37 <div class={cn("z-10 h-4 w-1 rounded-full ring-2 ring-background", barColor())} />38 <div class="flex h-full w-1/2 justify-start">39 <Show when={local.value > 0}>40 <div41 class={cn("rounded-r-full", barColor())}42 style={{ width: `${Math.abs(local.value)}%` }}43 />44 </Show>45 </div>46 </div>47 )48}4950export { DeltaBar }51export type { DeltaBarProps }52
What it pulls in
npm packages
Files it writes
More from solid-ui
All 55 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | solid-ui | Components | Free | 2 deps | |
| Alertalert | solid-ui | Components | Free | 3 deps | |
| Alert Dialogalert-dialog | solid-ui | Components | Free | 2 deps | |
| Aspect Ratioaspect-ratio | solid-ui | Components | Free | 1 dep | |
| Avataravatar | solid-ui | Components | Free | 2 deps | |
| Badgebadge | solid-ui | Components | Free | 2 deps | |
| Badge Deltabadge-delta | solid-ui | Components | Free | 2 deps | |
| Bar Listbar-list | solid-ui | Components | Free | 1 dep |
