LiftKit Documentation

repository·main·Indexed 25 days ago

https://github.com/chainlift/liftkit

A UI framework designed to enforce design best practices like optical symmetry and balanced proportions using a platform-agnostic system of formulas for scaling, spacing, and color. It provides a set of components including Badge, Button, Card, Column, Container, and Dropdown, and can be integrated into Next.js projects via a CLI or template.

Tokens
11.3K
Snippets
13
Records
76
Agent score
83%

What's inside LiftKit

  1. Install LiftKit for a new Next.js project using the template

    main

    The fastest way to get started is to clone the pre-configured LiftKit template project, which includes LiftKit Core's config files.

    1. Clone the template:
      git clone https://github.com/Chainlift/liftkit-template.git
    2. Navigate to the directory:
      cd liftkit-template
    3. Install dependencies:
      npm install
    4. Install desired components (see Install LiftKit Components & Styles).
    5. Import LiftKit's CSS into your globals.css:
      @import url("@/lib/css/index.css");
    git clone https://github.com/Chainlift/liftkit-template.git
    cd liftkit-template
    npm install
  2. Add LiftKit to an existing Next.js project

    main

    To integrate LiftKit into an existing Next.js project, follow these steps:

    1. Install the LiftKit CLI as a dev dependency:
      npm install @chainlift/liftkit --save-dev
    2. Initialize LiftKit:
      npx liftkit init
      • When prompted to add an add script to package.json, select yes.
      • When prompted to install shadcn as a devDependency, select yes.
    3. Install desired components (see Install LiftKit Components & Styles).
    4. Import LiftKit's CSS into your globals.css:
      @import url("@/lib/css/index.css");

    Note: npx liftkit init creates components.json and tailwind.config.ts in your project root. You do not need Tailwind itself to use LiftKit, but the tailwind.config.ts file is required by the current registry.

    npm install @chainlift/liftkit --save-dev
    npx liftkit init
  3. Install LiftKit Components & Styles

    main

    LiftKit Core provides the base configuration, while LiftKit Components provide the actual UI components and their associated CSS. Unused CSS is automatically tree-shaken at build time.

    Use the following commands to add components to your project:

    GoalCommand
    Install everything (all components, CSS, and types)npm run add all
    Install a specific component (includes its CSS and types)npm run add <component-name-kebab-case>
    Install base only (CSS and types only)npm run add base

    Troubleshooting: If you encounter React 19 compatibility warnings, append the --force flag to your command.

  4. Use the Dropdown component

    main

    The Dropdown component provides a controlled menu system that uses a portal to render content at the document body level. It consists of three main parts: Dropdown (the provider), DropdownTrigger (the element that toggles the menu), and DropdownMenu (the container for the menu items).

    Key features:

    • Click-outside to close: The menu automatically closes when clicking outside the trigger or the menu content.
    • Smart Positioning: The menu calculates its position based on the trigger's quadrant in the viewport.
    • Singleton Behavior: Only one dropdown can be open at a time; opening a new one will automatically close the previous one via an internal DropdownRegistry.
  5. LiftKit FAQ and Compatibility

    main

    Component Dependencies

    Some components automatically install dependencies. For example, installing Badge will also install Icon.

    CSS Management

    • Unused CSS: LiftKit may install CSS for components you aren't explicitly using to allow for free experimentation. However, unused styles are automatically removed at build time.
    • Tailwind Requirement: LiftKit does not require Tailwind as a dependency. It only requires a tailwind.config.ts file to satisfy the current registry requirements.

    Production Warning

    NOT RECOMMENDED FOR PRODUCTION USE. The current version of LiftKit is undergoing a rewrite to satisfy modern best practices and wrap around Base UI primitives. A more stable version is expected following the current development initiative.

  6. NavBar component API reference

    main

    The NavBar component accepts the following props:

    PropTypeDescription
    materialLkMaterialThe visual style/material of the navbar (e.g., `
  7. Use the Button component

    main

    The Button component is a customizable interactive element that supports various visual styles, sizes, and icon placements. It uses a variant system (fill, outline, text) and a color system to manage themes. Icons can be placed at the start or end of the button using startIcon and endIcon props.

    <Button
      label="Click me"
      variant="outline"
      color="secondary"
      size="lg"
      startIcon={<ChevronIcon />}
    />
  8. Use ThemeController for visual theme management

    main
    The ThemeController component provides a UI drawer that allows users to interactively manage the application's theme. It includes controls for toggling between light and dark modes, adjusting the master seed color (which resets other tokens), and fine-tuning brand, semantic, and layout color groups. It also provides a way to copy the current theme configuration as a code snippet for use in a project's theme file.
  9. Get the corresponding 'on-' token for a color

    main

    The getOnToken(colorToken) function resolves the appropriate text/foreground color token for a given background color token.

    It handles several special mapping cases:

    • Surface variants: surfacecontainerlowest, surfacecontainerlow, surfacecontainer, surfacecontainerhigh, surfacecontainerhighest, surfacedim, and surfacebright all map to onsurface.
    • Inverse surfaces: inversesurface maps to inverseonsurface.
    • Inverse primary: inverseprimary maps to onprimarycontainer.
    • Outlines: outline and outlinevariant map to onsurfacevariant.
    • Shadow/Scrim: shadow and scrim map to white.
    • Fixed/Dim/Variant tokens: Uses specific logic to find the complementary 'on-' token (e.g., primaryfixeddim resolves via getFixedColorComplement).
    • Standard tokens: Most other tokens are prefixed with on (e.g., primary becomes onprimary).
    • Existing 'on-' tokens: If the token already starts with on or inverseon, it returns the base color (e.g., onprimary returns primary).
  10. Section component props and SpacingSize types

    main

    The Section component accepts the following props:

    PropTypeDescription
    paddingSpacingSizeOverall padding
    pxSpacingSizeHorizontal padding (left and right)
    pySpacingSizeVertical padding (top and bottom)
    ptSpacingSizePadding top
    pbSpacingSizePadding bottom
    plSpacingSizePadding left
    prSpacingSizePadding right
    containerReact.ReactNodeContent to be rendered inside the section (overrides children)
    childrenReact.ReactNodeDefault content to be rendered inside the section
    ...restPropsReact.HTMLAttributes<HTMLElement>Standard HTML attributes for the <section> element

    SpacingSize values: "xs", "sm", "md", "lg", "xl", "none"

  11. Configure Button props

    main

    Use the following props to customize the Button component:

    • label: The text content displayed inside the button. Defaults to "Button".
    • variant: The visual style variant. Options: "fill" (default), "outline", or "text".
    • color: The color theme of the button (e.g., "primary", "secondary"). Defaults to "primary".
    • size: The size of the button. Options: "sm", "md" (default), or "lg".
    • startIcon: An optional IconName to display at the start of the button.
    • endIcon: An optional IconName to display at the end of the button.
    • opticIconShift: Boolean to control optical icon alignment on the y-axis. Defaults to true. When true, it pulls icons up slightly.
    • modifiers: Additional CSS class names to append to the button's default class list.
    • stateLayerOverride: An optional LkStateLayerProps object to customize the appearance of the button's state layer overlay.