npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

web3-display-components

v0.2.5

Published

React display components for token amounts, token values, and percentages with robust warning/error rendering.

Downloads

503

Readme

web3-display-components

React UI components for rendering web3/finance values with consistent loading, empty, truncation, and error states.

  • Display primitives: DisplayValue, DisplayTokenAmount, DisplayTokenValue, DisplayPercentage
  • Robust wrappers: DisplayValueRobust, DisplayTokenAmountRobust, DisplayTokenValueRobust, DisplayPercentRobust
  • Strongly recommended companion formatter: web3-robust-formatting
  • Runtime diagnostics support: warnings/errors from robust formatting pipelines are surfaced out of the box
  • Tailwind-ready default primitives with override points for tooltip, loader, truncate, skeleton, and icons

See It In Action

  • Mock vaults page: https://react-clean-code-tutorials.vercel.app/mock-vaults
  • Storybook docs: https://react-clean-code-tutorials.vercel.app/storybook/index.html?path=/docs/display-components-token-value-field--docs

Installation

npm install web3-display-components

Recommended (component + formatting pair):

npm install web3-display-components web3-robust-formatting

Peer dependencies:

{
  "react": "^17.0.0 || ^18.0.0 || ^19.0.0",
  "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0",
  "clsx": "^2.0.0",
  "tailwind-merge": "^3.0.0"
}

Codex Skills (Optional)

Install the packaged Codex skills with npx:

npx web3-display-components-codex-skill install
npx web3-robust-formatting-codex-skill install

Overwrite existing installed skill versions:

npx web3-display-components-codex-skill install --force
npx web3-robust-formatting-codex-skill install --force

Restart Codex after installing skills.

Add recommended auto-routing instructions into your project AGENTS.md:

npx web3-display-components-codex-skill init-agents

That command appends a routing block so you do not need to explicitly say "use this skill" in every prompt. Codex can select it automatically when the task matches.

Scaffold local wrapper fields folder from a prompt:

  • Example prompt: Initialize web3-display-components wrapper components in src/app/components/display-fields.
  • The skill will generate DisplayValue.tsx, DisplayText.tsx, DisplayPercentage.tsx, DisplayTokenAmount.tsx, DisplayTokenValue.tsx, and index.ts.
  • Generated wrappers use web3-robust-formatting types, so keep both packages installed.

Direct command (optional):

node ~/.codex/skills/web3-display-components/scripts/init-display-fields.mjs --target src/app/components/display-fields

Use --force to overwrite existing files.

Recommended formatting package

This package is display-focused. For formatting/parsing/normalization, use:

npm install web3-robust-formatting

Links:

  • npm: https://www.npmjs.com/package/web3-robust-formatting

Use web3-robust-formatting to produce robust values/warnings/errors, then pass them into robust wrappers from this package.

Recommended Stack

web3-display-components intentionally focuses on rendering.
For production usage, strongly pair it with web3-robust-formatting for all formatting and runtime-safe normalization.

Tailwind Setup

Tailwind v4:

@source "../node_modules/web3-display-components/**/*.{js,ts,jsx,tsx}";

Tailwind v3:

module.exports = {
  content: [
    "./src/**/*.{js,ts,jsx,tsx}",
    "./node_modules/web3-display-components/**/*.{js,ts,jsx,tsx}",
  ],
}

Quick Start

import { DisplayPercentRobust } from "web3-display-components"
import { robustFormatPercentToViewPercent } from "web3-robust-formatting"

export function PnlCell({ ratio }: { ratio: unknown }) {
  const property = robustFormatPercentToViewPercent({
    input: { value: ratio },
  })

  return <DisplayPercentRobust property={property} />
}

Component Overview

Display primitives

  • DisplayValue: base renderer
  • DisplayTokenAmount: defaults symbol position to after
  • DisplayTokenValue: defaults symbol to $, position before
  • DisplayPercentage: defaults symbol to %, position after

Robust wrappers

  • DisplayValueRobust
  • DisplayTokenAmountRobust
  • DisplayTokenValueRobust
  • DisplayPercentRobust
  • DisplayPercentageRobust

Convenience *Value aliases are also exported:

  • DisplayTokenAmountValue
  • DisplayTokenValueValue
  • DisplayPercentValue
  • DisplayPercentageValue

Each wrapper:

  • accepts queryState?: QueryResponse
  • accepts property?: RobustDisplayValue<unknown>
  • resolves severity (none | warning | error)
  • injects DisplayValue error props (isError, displayErrorAndValue, error, errorMessage)
  • leaves warning/error icon selection to consumer-level component injection

resolveDisplayErrorState

Use this utility directly when you need full control:

import {
  DisplayPercentage,
  resolveDisplayErrorState,
  resolvePropertyDisplayProps,
} from "web3-display-components"

function CustomPercent({ queryState, property }: { queryState?: any; property?: any }) {
  const { severity, ...resolvedErrorState } = resolveDisplayErrorState(queryState, property)
  const ErrorIconComponent = severity === "warning" ? MyWarningIcon : MyErrorIcon

  return (
    <DisplayPercentage
      {...queryState}
      ErrorIconComponent={ErrorIconComponent}
      {...resolvedErrorState}
      {...resolvePropertyDisplayProps(property?.value)}
    />
  )
}

API Exports

// Root package exports
export * from "./components/DisplayValue.js"
export * from "./components/DisplayTokenAmount.js"
export * from "./components/DisplayTokenValue.js"
export * from "./components/DisplayPercentage.js"
export * from "./components/robust/index.js"

// Defaults
export * from "./components/defaults/DefaultComponents.js"
export * from "./components/defaults/Truncate.js"

// Types + utils
export * from "./types/QueryResponse.js"
export * from "./types/RobustDisplayValue.js"
export * from "./utils/tailwind.js"

components/robust/index also exports robust wrappers explicitly:

export { DisplayValueRobust } from "./DisplayValueRobust.js"
export { DisplayTokenAmountRobust } from "./DisplayTokenAmountRobust.js"
export { DisplayTokenValueRobust } from "./DisplayTokenValueRobust.js"
export { DisplayPercentRobust, DisplayPercentageRobust } from "./DisplayPercentRobust.js"

License

MIT