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

@rulab/adminjs-components

v0.4.2

Published

Prebuilt AdminJS features for common UI needs.

Readme

adminjs-components

Prebuilt AdminJS components and features for common UI needs: colored status badges, slug and UUID generation, Editor.js content, sortable string lists, drag-and-drop list ordering, singleton resources, tabs layout, and record preview.

Install

pnpm add @rulab/adminjs-components
# or
npm install @rulab/adminjs-components

Quick start

import AdminJS from "adminjs";
import { ComponentLoader } from "adminjs";
import { setComponentLoader, ColorStatusFeature } from "@rulab/adminjs-components";

const componentLoader = new ComponentLoader();
setComponentLoader(componentLoader);

const admin = new AdminJS({
  componentLoader,
  resources: [
    {
      resource: YourResource,
      features: [
        ColorStatusFeature({
          key: "status",
          availableValues: [
            { value: "draft", label: "Draft", color: "#64748b" },
            { value: "published", label: "Published", color: "#16a34a" },
          ],
        }),
      ],
    },
  ],
});

You can also pass componentLoader into every feature instead of calling setComponentLoader.

Components and features

Singleton

Makes a resource behave as a singleton: opening the list redirects to new when there are no rows, to edit when there is exactly one row, or shows the normal list with an error notice when more than one row exists.

Feature order: add SingletonFeature() first in the resource features array when you combine it with other features. AdminJS merges list.after hooks in registration order; if another feature has already registered list.after before Singleton applies, singleton behaviour is turned off and you get a notice asking you to move Singleton earlier. That matters especially for @adminjs/upload, which adds a list.after that expects records to exist — Singleton must merge before upload so the hook chain stays correct.

Exception: if another feature defines a custom list handler, register SingletonFeature after that feature so the custom handler still runs as intended (see inline comments in the source for details).

import { SingletonFeature } from "@rulab/adminjs-components";

features: [
  SingletonFeature(),
  // …other features (e.g. EditorFeature with @adminjs/upload, TabsFeature)
];

Back to top

ColorStatus

Renders a colored badge in edit/list/show based on a list of available values. By default (nullable: false) the first option is auto-selected in new records. Set nullable: true to allow an empty value.

import { ColorStatusFeature } from "@rulab/adminjs-components";

features: [
  ColorStatusFeature({
    key: "status",
    nullable: false, // optional, default false
    availableValues: [
      { value: "draft", label: "Draft", color: "#64748b" },
      { value: "review", label: "In review", color: "#f59e0b" },
      { value: "published", label: "Published", color: "#16a34a" },
    ],
  }),
]

Back to top

Slug

Generates a slug from another field and stores it in the target property. Use button to override the generate button label in edit view.

import { SlugFeature } from "@rulab/adminjs-components";

features: [
  SlugFeature({
    key: "slug",
    source: "title",
    button: "Create slug", // optional
  }),
]

Back to top

UUID

Adds a UUID field with a "Generate UUID" button in edit view. Use button to override the generate button label.

import { UuidFeature } from "@rulab/adminjs-components";

features: [
  UuidFeature({
    key: "uuid",
    button: "Generate ID", // optional
  }),
]

Back to top

Editor

Editor.js field for rich content. Supports optional image upload via @adminjs/upload provider, plus built-in audio and video blocks.

import { EditorFeature } from "@rulab/adminjs-components";
import { BaseProvider } from "@adminjs/upload";

const uploadProvider = new BaseProvider({
  bucket: "my-bucket",
  baseUrl: "https://cdn.example.com",
});

features: [
  EditorFeature({
    key: "content",
    uploadProvider, // optional
  }),
]

Back to top

StringList

Sortable list stored as a single string (comma-separated by default). Use separator to override the delimiter used for storing and rendering values.

import { StringListFeature } from "@rulab/adminjs-components";

features: [
  StringListFeature({
    key: "facts",
    separator: "|", // optional, default "|"
  }),
]

Back to top

SortableList

Replaces the default list view with a drag-and-drop table so you can reorder records. New positions are saved to a numeric property on each record (default sort) via a hidden resource action. The resource is sorted by that field by default unless you already set sort in resource options.

import { SortableListFeature } from "@rulab/adminjs-components";

features: [
  SortableListFeature({
    sortField: "sort", // optional, default "sort" — must exist on your model
    reorderActionName: "sortableListReorder", // optional, default shown
    direction: "ASC", // optional: "ASC" | "DESC" — how order maps to numbers per page
  }),
];

Back to top

Tabs

Groups edit/show fields into tabs based on property props.tab or custom.tab. Fields without a tab go to a common group. commonTabLabel is optional and defaults to "Common".

import { TabsFeature } from "@rulab/adminjs-components";

features: [
  TabsFeature({
    commonTabLabel: "General", // optional, default "Common"
  }),
]

// resource options example
properties: {
  title: { props: { tab: "Main" } },
  description: { props: { tab: "Main" } },
  seoTitle: { props: { tab: "SEO" } },
  seoDescription: { props: { tab: "SEO" } },
},

Back to top

Preview

Adds a record action that renders an iframe preview. The url can include template variables like $id or $slug.

import { PreviewFeature } from "@rulab/adminjs-components";

features: [
  PreviewFeature({
    url: "https://example.com/posts/$id",
    actionName: "preview", // optional
  }),
]

Back to top

Utilities

  • setComponentLoader(loader) and getComponentLoader() to reuse a single AdminJS ComponentLoader.
  • parseHtml(html) helper to transform stored Editor.js output into HTML.