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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@f47/variabler

v0.0.6

Published

A React component library for editable content with variable highlighting.

Readme

A React component library for editable content with variable highlighting and Radix UI popovers/tooltips. Perfect for forms, templates, and dynamic content where users can insert predefined variables.

Note: This library uses Shadcn UI conventions and Radix UI under the hood for popovers and tooltips. You need to include Tailwind CSS in your project for proper styling.


Features

  • ContentEditable component with live highlighting of variables
  • Automatically shows a list of available variables
  • Copy variable to clipboard with tooltip feedback
  • Radix UI popovers and tooltips included
  • Fully styled with Tailwind CSS, supports dark mode
  • No automatic CSS injection — you must include Tailwind in your project

Installation

npm install @f47/variabler

or with Yarn:

yarn add @f47/variabler

Usage

import { useState } from "react";
import { Variabler } from "@f47/variabler";
import "@f47/variabler/dist/index.css";

function App() {
  const [text, setText] = useState("");

  return (
    <Variabler
      value={text}
      onChange={setText}
      variables={["firstName", "lastName"]}
      symbol="$" // optional, default is '$'
    />
  );
}

export default App;

⚠️ Styling will only work if Tailwind CSS is configured in your project.

Variabler Usage using RHF, Zod and Shadcn UI

import { Variabler } from "@f47/variabler";
import "@f47/variabler/dist/index.css";
import { zodResolver } from "@hookform/resolvers/zod";
import { useForm } from "react-hook-form";
import { z } from "zod";
import "./App.css";

import {
  Form,
  FormControl,
  FormField,
  FormItem,
  FormMessage,
} from "@/components/ui/form";
import { Button } from "./components/ui/button";

const schema = z.object({
  body: z.string().nonempty({
    message: "Required",
  }),
});
type SchemaType = z.infer<typeof schema>;

function App() {
  const form = useForm<SchemaType>({
    resolver: zodResolver(schema),
    defaultValues: {
      body: "",
    },
  });
  const onSubmit = (data: SchemaType) => {
    console.log(data);
  };
  return (
    <div className="flex flex-col justify-center items-center mx-auto max-w-2xl min-h-svh">
      <h1 className="mb-3 text-2xl text-start">Meet Variabler</h1>
      <Form {...form}>
        <form
          action=""
          onSubmit={form.handleSubmit(onSubmit)}
          className="w-full"
        >
          <FormField
            name="body"
            control={form.control}
            render={({ field }) => (
              <FormItem>
                <FormControl>
                  <Variabler
                    value={field.value}
                    onChange={field.onChange}
                    variables={[
                      "firstName",
                      "lastName",
                      "jobTitle",
                      "companyName",
                      "skills",
                      "industry",
                      "applicantName",
                    ]}
                    wrapperClassName="w-full"
                  />
                </FormControl>
                <FormMessage className="text-red-500" />
              </FormItem>
            )}
          />
          <div className="flex justify-end mt-5">
            <Button className="cursor-pointer">Submit</Button>
          </div>
        </form>
      </Form>
      <div className="p-4 mt-4 w-full bg-gray-50 rounded-lg border border-gray-300 output">
        <h2 className="mb-2 text-lg font-semibold text-gray-800">Output</h2>
        <p className="text-gray-700 whitespace-pre-wrap break-words">
          {form.watch("body")}
        </p>
      </div>
    </div>
  );
}

export default App;

Props

| Prop | Type | Description | | ------------------ | -------------------------------------- | --------------------------------------- | | value | string | Controlled content | | onChange | (value: string) => void | Callback when content changes | | variables | string[] | List of allowed variables | | symbol | string | Symbol before variables (default "$") | | className | string | Extra styling for the editable box | | wrapperClassName | string | Extra styles for the wrapper div | | ...props | React.ComponentProps<HTMLDivElement> | Other standard ContentEditable props |


License

MIT © Fares Galal