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

@prairielearn/ui

v3.0.0

Published

UI components, utilities, and styles shared between PrairieLearn and PrairieTest.

Downloads

763

Readme

@prairielearn/ui

UI components, utilities, and styles shared between PrairieLearn and PrairieTest.

UI Component Examples

TanstackTableCard

You can refer to instructorStudents.html.tsx for an example of how to use this component.

import { TanstackTableCard } from '@prairielearn/ui';

<TanstackTableCard
  table={table}
  title="Students"
  className="h-100"
  singularLabel="student"
  pluralLabel="students"
  downloadButtonOptions={{
    filenameBase: `${courseInstanceFilenamePrefix(courseInstance, course)}students`,
    mapRowToData: (row) => {
      return {
        uid: row.user?.uid ?? row.enrollment.pending_uid,
        name: row.user?.name ?? null,
        email: row.user?.email ?? null,
        status: row.enrollment.status,
        first_joined_at: row.enrollment.first_joined_at
          ? formatDate(row.enrollment.first_joined_at, course.display_timezone, {
              includeTz: false,
            })
          : null,
      };
    },
    hasSelection: false,
  }}
  headerButtons={
    <>
      {enrollmentManagementEnabled && (
        <Button
          variant="light"
          disabled={!authzData.has_course_instance_permission_edit}
          onClick={() => setShowInvite(true)}
        >
          <i class="bi bi-person-plus me-2" aria-hidden="true" />
          Invite student
        </Button>
      )}
    </>
  }
  globalFilter={{
    placeholder: 'Search by UID, name, email...',
  }}
  tableOptions={tableOptions}
/>;

You should also include the CSS file in your page:

@import url('@prairielearn/ui/components/styles.css');

CategoricalColumnFilter

You can refer to instructorStudents.html.tsx for an example of how to use this component.

import { CategoricalColumnFilter } from '@prairielearn/ui';
import { parseAsArrayOf, parseAsString, parseAsStringLiteral, useQueryState } from 'nuqs';
import { EnumEnrollmentStatusSchema } from '../../lib/db-types.js';
import { EnrollmentStatusIcon } from '../../components/EnrollmentStatusIcon.js';

const STATUS_VALUES = Object.values(EnumEnrollmentStatusSchema.Values);
const DEFAULT_ENROLLMENT_STATUS_FILTER: EnumEnrollmentStatus[] = [];

const [enrollmentStatusFilter, setEnrollmentStatusFilter] = useQueryState(
  'status',
  parseAsArrayOf(parseAsStringLiteral(STATUS_VALUES)).withDefault(DEFAULT_ENROLLMENT_STATUS_FILTER),
);

const columnFilters = useMemo(() => {
  return [
    {
      id: 'enrollment_status',
      value: enrollmentStatusFilter,
    },
  ];
}, [enrollmentStatusFilter]);

// Setting up the filters in the table options
const tableOptions = {
  // ... other table options
  filters: {
    enrollment_status: ({ header }) => (
      <CategoricalColumnFilter
        columnId={header.column.id}
        columnLabel="Status"
        allColumnValues={STATUS_VALUES}
        renderValueLabel={({ value }) => <EnrollmentStatusIcon type="text" status={value} />}
        columnValuesFilter={enrollmentStatusFilter}
        setColumnValuesFilter={setEnrollmentStatusFilter}
      />
    ),
  },
};

nuqs Utilities

This package provides utilities for integrating nuqs (type-safe URL query state management) with server-side rendering and TanStack Table.

NuqsAdapter

nuqs needs to be aware of the current state of the URL search parameters during both server-side and client-side rendering. The NuqsAdapter component handles this by using a custom adapter on the server that reads from a provided search prop, while on the client it uses nuqs's built-in React adapter that reads directly from location.search.

import { NuqsAdapter } from '@prairielearn/ui';

// Wrap your component that uses nuqs hooks
<NuqsAdapter search={new URL(req.url).search}>
  <MyTableComponent />
</NuqsAdapter>;

TanStack Table State Parsers

The package provides custom parsers for syncing TanStack Table state with URL query parameters:

  • parseAsSortingState: Syncs table sorting state with the URL. Format: col:asc or col1:asc,col2:desc for multi-column sorting.
  • parseAsColumnVisibilityStateWithColumns(allColumns, defaultValueRef?): Syncs column visibility. Parses comma-separated visible column IDs.
  • parseAsColumnPinningState: Syncs left-pinned columns. Format: col1,col2,col3.
  • parseAsNumericFilter: Syncs numeric filter values. URL format: gte_5, lte_10, gt_3, lt_7, eq_5, empty.
import {
  parseAsSortingState,
  parseAsColumnVisibilityStateWithColumns,
  parseAsColumnPinningState,
  parseAsNumericFilter,
} from '@prairielearn/ui';
import { useQueryState } from 'nuqs';

// Sorting state synced to URL
const [sorting, setSorting] = useQueryState('sort', parseAsSortingState.withDefault([]));

// Column visibility synced to URL
const allColumns = ['name', 'email', 'status'];
const [columnVisibility, setColumnVisibility] = useQueryState(
  'cols',
  parseAsColumnVisibilityStateWithColumns(allColumns).withDefault({}),
);

// Column pinning synced to URL
const [columnPinning, setColumnPinning] = useQueryState(
  'pin',
  parseAsColumnPinningState.withDefault({ left: [], right: [] }),
);

// Numeric filter synced to URL
const [scoreFilter, setScoreFilter] = useQueryState(
  'score',
  parseAsNumericFilter.withDefault({ filterValue: '', emptyOnly: false }),
);