CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-nextui-org--react

Beautiful and modern React UI library with comprehensive components, theming, and accessibility support.

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

core-system.mddocs/

Core System and Theme

NextUI's core system provides the foundational infrastructure for theming, provider configuration, and styling utilities that power all components in the library.

Capabilities

NextUI Provider

The root provider component that wraps your application and provides global configuration for themes, localization, animations, and routing.

interface NextUIProviderProps {
  /** Application content */
  children: React.ReactNode;
  /** Locale for internationalization (e.g., "en-US", "fr-FR") */
  locale?: string;
  /** Default theme to apply ("light" or "dark") */
  theme?: DefaultThemeType;
  /** Custom theme configurations */
  themes?: ConfigThemes;
  /** Default theme key when using custom themes */
  defaultTheme?: string;
  /** Disable all animations globally */
  disableAnimation?: boolean;
  /** Disable ripple effects globally */
  disableRipple?: boolean;
  /** Skip Framer Motion animations for better performance */
  skipFramerMotionAnimations?: boolean;
  /** Form validation behavior */
  validationBehavior?: "aria" | "native";
  /** Router navigation function for client-side routing */
  navigate?: (path: string) => void;
  /** Whether to create a portal container */
  createPortalContainer?: boolean;
  /** Calendar systems to support */
  calendars?: SupportedCalendars[];
}

function NextUIProvider(props: NextUIProviderProps): JSX.Element;

type DefaultThemeType = "light" | "dark";

type SupportedCalendars = 
  | "buddhist" | "ethiopic" | "ethioaa" | "coptic" 
  | "hebrew" | "indian" | "islamic-civil" | "islamic-tbla" 
  | "islamic-umalqura" | "japanese" | "persian" | "roc" | "gregory";

Usage Examples:

import React from "react";
import { NextUIProvider } from "@nextui-org/react";
import { useNavigate } from "react-router-dom";

function App() {
  const navigate = useNavigate();

  return (
    <NextUIProvider navigate={navigate} theme="light" locale="en-US">
      {/* Your app content */}
    </NextUIProvider>
  );
}

For CommonJS:

const React = require("react");
const { NextUIProvider } = require("@nextui-org/react");

function App() {
  return (
    <NextUIProvider theme="light" locale="en-US">
      {/* Your app content */}
    </NextUIProvider>
  );
}

Provider Context

Access NextUI provider state and configuration throughout your component tree.

interface ProviderContextProps {
  theme?: DefaultThemeType;
  themes?: ConfigThemes;
  defaultTheme?: string;
  disableAnimation?: boolean;
  disableRipple?: boolean;
  validationBehavior?: "aria" | "native";
  locale?: string;
  navigate?: (path: string) => void;
  createPortalContainer?: boolean;
}

const ProviderContext: React.Context<ProviderContextProps>;

/**
 * Hook to access NextUI provider context
 * @returns Provider context props or undefined if outside provider
 */
function useProviderContext(): ProviderContextProps | undefined;

Theme Configuration

Advanced theme configuration system supporting multiple themes, custom colors, and responsive design tokens.

interface BaseThemeUnit {
  small?: string;
  medium?: string;
  large?: string;
}

interface FontThemeUnit extends BaseThemeUnit {
  tiny?: string;
}

interface LayoutTheme {
  /** Spacing scale values */
  spacingUnit?: number;
  /** Disable default theme styles */
  disableAnimation?: boolean;
  /** Disable ripple effects */
  disableRipple?: boolean;
  /** Hover opacity for interactive elements */
  hoverOpacity?: number;
  /** Active opacity for pressed elements */
  activeOpacity?: number;
  /** Disabled opacity for disabled elements */
  disabledOpacity?: number;
  /** Divider weight/thickness */
  dividerWeight?: string;
  /** Font size configuration */
  fontSize?: FontThemeUnit;
  /** Line height configuration */
  lineHeight?: FontThemeUnit;
  /** Border radius configuration */
  radius?: BaseThemeUnit;
  /** Border width configuration */
  borderWidth?: BaseThemeUnit;
  /** Box shadow configuration */
  boxShadow?: BaseThemeUnit;
}

interface ConfigTheme extends LayoutTheme {
  /** Color palette for the theme */
  colors?: Record<string, any>;
}

interface ConfigThemes {
  /** Light theme configuration */
  light?: ConfigTheme;
  /** Dark theme configuration */
  dark?: ConfigTheme;
  /** Custom theme configurations */
  [key: string]: ConfigTheme | undefined;
}

interface NextUIPluginConfig {
  /** Theme configuration */
  themes?: ConfigThemes;
  /** Default theme */
  defaultTheme?: DefaultThemeType;
  /** Layout configuration */
  layout?: LayoutTheme;
  /** Default extend theme */
  defaultExtendTheme?: DefaultThemeType;
  /** Additional CSS variables prefix */
  prefix?: string;
  /** Add common colors to palette */
  addCommonColors?: boolean;
}

Styling Utilities

Core styling utilities built on Tailwind Variants for consistent component styling.

/**
 * Tailwind Variants function for creating component variants
 */
function tv<S extends Record<string, any>>(
  config: TVConfig<S>
): (...args: any[]) => string;

interface TVConfig<S = {}> {
  /** Base classes applied to all variants */
  base?: string | string[];
  /** Variant configurations */
  variants?: Record<string, Record<string, string | string[]>>;
  /** Slot-based styling for complex components */
  slots?: S;
  /** Default variant selections */
  defaultVariants?: Record<string, any>;
  /** Compound variants for multiple variant combinations */
  compoundVariants?: Array<{
    /** Variant conditions */
    [key: string]: any;
    /** Classes to apply when conditions match */
    class?: string | string[];
    /** Slot classes to apply when conditions match */
    [K in keyof S]?: string | string[];
  }>;
  /** Responsive variants */
  responsiveVariants?: string[] | ResponsiveVariantsConfig;
}

type VariantProps<T> = T extends (...args: any[]) => any
  ? Parameters<T>[0]
  : never;

type TV = typeof tv;

/**
 * Class name utility function (alias for clsx/cn)
 */
function cn(...inputs: ClassValue[]): string;

type ClassValue = 
  | string
  | number
  | boolean
  | undefined
  | null
  | ClassValue[]
  | Record<string, any>;

/**
 * Merge classes utility
 */
function mergeClasses(...classes: string[]): string;

Base CSS Classes

Pre-defined CSS class utilities for common styling patterns.

/** Base component styles */
const baseStyles: (props?: any) => string;

/** Focus ring styles */
const ringClasses: string[];
const focusVisibleClasses: string[];
const dataFocusVisibleClasses: string[];
const groupDataFocusVisibleClasses: string[];

/** Layout utilities */
const translateCenterClasses: string[];
const absoluteFullClasses: string[];

/** Border collapse utility for adjacent elements */
const collapseAdjacentVariantBorders: (...args: any[]) => string;

/** Hidden input styling for form controls */
const hiddenInputClasses: string[];

/** Color variant utilities */
const colorVariants: string[];

/** Common design tokens */
const COMMON_UNITS: {
  sm: string;
  md: string;
  lg: string;
  xl: string;
};

/** Tailwind merge configuration */
const twMergeConfig: Record<string, any>;

Slot-Based Styling

Type utilities for component slot-based styling systems.

/**
 * Utility type for mapping component slots to CSS classes
 */
type SlotsToClasses<S extends string> = {
  [K in S]?: string;
};

/**
 * Extract slot keys from component variants
 */
type SlotProps<T> = T extends Record<infer S, any> ? S : never;

System Types

Core TypeScript utilities for component system integration.

/**
 * Polymorphic component type for 'as' prop support
 */
type As<Props = any> = React.ElementType<Props>;

/**
 * DOM element type utilities
 */
type DOMElement = Element;
type DOMElements = keyof JSX.IntrinsicElements;
type CapitalizedDOMElements = Capitalize<DOMElements>;

/**
 * DOM attributes utility
 */
type DOMAttributes<T = Element> = React.DOMAttributes<T>;

/**
 * Component prop utilities
 */
type OmitCommonProps<T, K extends keyof any = never> = Omit<T, "id" | "children" | K>;

type RightJoinProps<
  SourceProps extends object = {},
  OverrideProps extends object = {}
> = OmitCommonProps<SourceProps, keyof OverrideProps> & OverrideProps;

type MergeWithAs<
  ComponentProps extends object,
  AsProps extends object,
  AdditionalProps extends object = {},
  AsComponent extends As = As
> = RightJoinProps<ComponentProps, AdditionalProps> & 
    RightJoinProps<AsProps, AdditionalProps> & {
      as?: AsComponent;
    };

type PropsOf<T extends As> = React.ComponentPropsWithoutRef<T> & {
  as?: T;
};

/**
 * Prop getter function type
 */
type PropGetter<P = Record<string, unknown>, R = Record<string, unknown>> = (
  props?: P,
  forwardedRef?: React.Ref<any>
) => R;

/**
 * Enhanced forwardRef function
 */
type InternalForwardRefRenderFunction<T, P = {}> = (
  props: P,
  ref: React.ForwardedRef<T>
) => React.ReactElement | null;

function forwardRef<T, P = {}>(
  render: InternalForwardRefRenderFunction<T, P>
): React.ForwardRefExoticComponent<React.PropsWithoutRef<P> & React.RefAttributes<T>>;

Variant Extension System

Utilities for extending and customizing component variants.

/**
 * Extend component variants with custom styling
 */
function extendVariants<T extends (...args: any[]) => any>(
  component: T,
  variants: ExtendVariantProps<T>,
  defaultVariants?: Record<string, any>
): T;

type ExtendVariantProps<T> = T extends TV
  ? {
      variants?: Record<string, Record<string, any>>;
      defaultVariants?: Record<string, any>;
      compoundVariants?: Array<Record<string, any>>;
    }
  : never;

type ExtendVariantWithSlotsProps<T> = T extends Record<string, any>
  ? {
      base?: Record<keyof T, any>;
      variants?: Record<string, Record<string, Record<keyof T, any>>>;
      defaultVariants?: Record<string, any>;
      compoundVariants?: Array<Record<string, any>>;
    }
  : never;

type ExtendVariants<T> = T extends Record<string, any>
  ? ExtendVariantWithSlotsProps<T>
  : ExtendVariantProps<T>;

/**
 * Prop mapping utilities for variants
 */
function mapPropsVariants<T, K>(
  props: T,
  variantKeys: K[],
  removeVariantProps?: boolean
): [T, Record<string, any>];

function mapPropsVariantsWithCommon<T, K, C>(
  props: T,
  variantKeys: K[],
  commonKeys: C[],
  removeVariantProps?: boolean
): [T, Record<string, any>, Record<string, any>];

Selection System

Shared selection state management for interactive components.

/**
 * Selection state interface for components with selectable items
 */
interface SharedSelection {
  /** Currently selected keys */
  selectedKeys?: Selection;
  /** Default selected keys for uncontrolled mode */
  defaultSelectedKeys?: Selection;
  /** Selection mode */
  selectionMode?: SelectionMode;
  /** Selection behavior on interaction */
  selectionBehavior?: SelectionBehavior;
  /** Whether to prevent empty selection */
  disallowEmptySelection?: boolean;
  /** Selection change callback */
  onSelectionChange?: (keys: Selection) => void;
}

type Selection = "all" | Set<React.Key>;
type SelectionMode = "none" | "single" | "multiple";
type SelectionBehavior = "toggle" | "replace";

Utility Functions

/**
 * Convert value to iterator
 */
function toIterator<T>(value: Iterable<T> | (() => Iterable<T>)): Iterator<T>;

/**
 * Check if element is NextUI component
 */
function isNextUIEl(element: React.ReactElement): boolean;

Usage Examples:

// Custom theme configuration
import { NextUIProvider } from "@nextui-org/react";

const customThemes = {
  light: {
    colors: {
      primary: {
        50: "#f0f9ff",
        500: "#3b82f6",
        900: "#1e3a8a",
        DEFAULT: "#3b82f6",
        foreground: "#ffffff",
      },
    },
  },
  dark: {
    colors: {
      primary: {
        50: "#1e3a8a", 
        500: "#3b82f6",
        900: "#f0f9ff",
        DEFAULT: "#3b82f6",
        foreground: "#000000",
      },
    },
  },
};

function App() {
  return (
    <NextUIProvider themes={customThemes} defaultTheme="light">
      {/* App content */}
    </NextUIProvider>
  );
}

// Using Tailwind Variants
import { tv } from "@nextui-org/react";

const button = tv({
  base: "font-medium bg-blue-500 text-white hover:opacity-80 pressed:scale-95",
  variants: {
    color: {
      primary: "bg-blue-500",
      secondary: "bg-gray-500", 
      danger: "bg-red-500",
    },
    size: {
      sm: "text-sm px-2 py-1",
      md: "text-base px-4 py-2",
      lg: "text-lg px-6 py-3",
    },
    disabled: {
      true: "opacity-50 pointer-events-none",
    },
  },
  defaultVariants: {
    size: "md",
    color: "primary",
  },
});

// Extending component variants
import { Button, extendVariants } from "@nextui-org/react";

const MyButton = extendVariants(Button, {
  variants: {
    color: {
      olive: "text-[#000] bg-[#84cc16]",
      orange: "bg-[#ff8c00] text-[#fff]",
      violet: "bg-[#8b5cf6] text-[#fff]",
    },
    isDisabled: {
      true: "bg-[#eaeaea] text-[#000] opacity-50 cursor-not-allowed",
    },
  },
  defaultVariants: {
    color: "olive",
    size: "md",
  },
});

docs

core-system.md

data-display.md

date-time.md

feedback.md

forms.md

index.md

inputs.md

interactions.md

layout.md

navigation.md

overlays.md

utilities.md

tile.json