Skip to main content
GitHub

Ant Design look

An Ant Design-style admin page, built from nxds parts with your own colors.

Built with nxds

Acme admin

Order 20418

Paid
Customer
Ada Lovelace
Email
ada@example.com
Placed
12 March 2026
Total
$1,280.00

Express, two business days. Sent to 12 Analytical Row, London.

Built with Ant Design

The first page is built with nxds parts. The second is the same page built with Ant Design, to compare.

Set your own colors

Create the colors file:

npx nxds-cli@latest init --own-colors

Replace its values with Ant Design's palette:

/* app/nxds-colors.css */
@layer theme {
  :root {
    --nx-color-background: #f5f5f5;
    --nx-color-container: #fff;
    --nx-color-foreground: rgb(0 0 0 / 0.88);
    --nx-color-border-default: #d9d9d9;
    --nx-color-border-hairline: rgb(5 5 5 / 0.06);
    --nx-color-primary-background: #1677ff;
    --nx-color-primary-background-hover: #4096ff;
    --nx-color-primary-background-active: #0958d9;

    /* The dark sider */
    --nx-color-nav-background: #001529;
    --nx-color-nav-foreground: #fff;
    --nx-color-nav-muted-foreground: rgb(255 255 255 / 0.65);
    --nx-color-nav-item-active: #1677ff;
    /* The other colors */
  }
}

The nav-* colors belong to the Sidebar alone, so the sider is navy while the page is light.

The full palette has every color for light and dark. It sets them on a wrapper, so they reach only the preview on this page. Your app sets them on :root and .dark.

Your own colors covers the colors file.

Set Ant's corners

Ant rounds a control by 6px and a container by 8px. No corners value gives 6px, so redefine subtle in the colors file:

/* app/nxds-colors.css */
@layer theme {
  [data-radius='subtle'] {
    --nx-radius-sm: 4px;
    --nx-radius-base: 6px;
    --nx-radius-md: 6px;
    --nx-radius-lg: 8px;
  }
}

These corners apply at the Default UI scale.

Set Ant's line height

Ant sets 14px text on a 22px line, and 12px text on a 20px line. Set the two line heights in the colors file:

/* app/nxds-colors.css */
@layer theme {
  :root {
    --nx-typography-line-height-xs: 20px;
    --nx-typography-line-height-sm: 22px;
  }
}

The text size setting then stops changing these two line heights.

Add the parts

npx nxds-cli@latest add sidebar button badge label description-list accordion slider

Each part needs a different amount of work:

PartChange
Sidebar, Button, Badge, LabelAnt's sizes, as classes where you use them
DescriptionListA bordered grid, two pairs to a row, and filled label cells
AccordionOne bordered box, tinted headers, the arrow before the label
SliderA new class recipe: a thin rail and a round handle

Use the stock parts

Four Ant parts are the stock nxds parts in Ant's colors. Pass Ant's sizes as classes where you use them:

Ant Design partnxds partClasses
Dark Menu in a SiderSidebar, which reads the nav-* colorsnx:h-10 nx:rounded-lg nx:px-6 on each SidebarMenuButton
Primary Button, 32px<Button size="sm">nx:px-[15px] nx:font-normal
Tag<Badge fill="outline">nx:min-h-[22px] nx:rounded-sm nx:px-[7px] nx:typography-body-small nx:normal-case
Form labelLabelnx:font-normal
// components/order-header.tsx
import { Badge } from '@/components/nxds/components/badge/badge';
import { Button } from '@/components/nxds/components/button/button';

export function OrderHeader() {
  return (
    <div className="nx:flex nx:items-center nx:gap-3">
      <p className="nx:m-0 nx:typography-heading-xxsmall nx:tracking-normal">
        Order 20418
      </p>
      <Badge
        variant="success"
        fill="outline"
        className="nx:min-h-[22px] nx:rounded-sm nx:px-[7px] nx:typography-body-small nx:normal-case"
      >
        Paid
      </Badge>
      <Button size="sm" className="nx:ms-auto nx:px-[15px] nx:font-normal">
        Edit order
      </Button>
    </div>
  );
}

Edit the DescriptionList

Ant's bordered Descriptions is a grid with filled label cells, two pairs to a row. Change the DescriptionList's classes, and add a wrapper:

components/nxds/components/description-list/description-list.tsx
import * as React from 'react';

import { cn } from '../../lib/utils';

const cellClassName =
  'nx:min-w-0 nx:border-e-default nx:border-b-default nx:border-border-hairline nx:px-6 nx:py-4 nx:wrap-anywhere nx:typography-body-default';

/**
 * Shows metadata as a bordered grid of term and value cells, two pairs to a row when the list has room. Put actions inside the description.
 *
 * The wrapper draws the outer border and clips the last row's and the last column's lines.
 */
function DescriptionList({ className, ...props }: React.ComponentProps<'dl'>) {
  return (
    <div className="nx:@container/description-list nx:w-full nx:overflow-hidden nx:rounded-lg nx:border-default nx:border-border-hairline">
      <dl
        data-slot="description-list"
        className={cn(
          'nx:m-0 nx:-me-(--nx-borderwidth-default) nx:-mb-(--nx-borderwidth-default) nx:grid nx:grid-cols-1 nx:@md/description-list:grid-cols-[repeat(4,auto)]',
          className
        )}
        {...props}
      />
    </div>
  );
}

/** Groups one term and its description. Its two cells sit in the list's grid. */
function DescriptionListItem({
  className,
  ...props
}: React.ComponentProps<'div'>) {
  return (
    <div
      data-slot="description-list-item"
      className={cn('nx:contents', className)}
      {...props}
    />
  );
}

function DescriptionListTerm({
  className,
  ...props
}: React.ComponentProps<'dt'>) {
  return (
    <dt
      data-slot="description-list-term"
      className={cn(
        cellClassName,
        'nx:bg-muted nx:text-muted-foreground',
        className
      )}
      {...props}
    />
  );
}

function DescriptionListDescription({
  className,
  ...props
}: React.ComponentProps<'dd'>) {
  return (
    <dd
      data-slot="description-list-description"
      className={cn(
        cellClassName,
        'nx:m-0 nx:bg-container nx:text-foreground',
        className
      )}
      {...props}
    />
  );
}

export {
  DescriptionList,
  DescriptionListDescription,
  DescriptionListItem,
  DescriptionListTerm,
};
Ant Design needsChange
A bordered gridA wrapper with the border and corners, and two lines on each cell
Two pairs to a rowA four-column grid on the list, once the wrapper is 28rem wide
Filled label cellsnx:bg-muted on the term
Padded cellsnx:px-6 nx:py-4 on the term and the description

A narrow list stacks each label over its value, as the stock part does.

Edit the Accordion

Ant's Collapse is one bordered box, with the arrow before each label. Change the Accordion's classes, and move its icon:

components/nxds/components/accordion/accordion.tsx
import * as React from 'react';

import * as AccordionPrimitive from '@radix-ui/react-accordion';
import { cva, type VariantProps } from 'class-variance-authority';

import { IconChevronRight } from '../../lib/icons';
import { cn } from '../../lib/utils';

const accordionVariants = cva(
  'nx:group/accordion nx:flex nx:w-full nx:flex-col',
  {
    variants: {
      variant: {
        stacked:
          'nx:overflow-hidden nx:rounded-lg nx:border-default nx:border-border-default',
        floating: 'nx:gap-2',
      },
    },
    defaultVariants: {
      variant: 'stacked',
    },
  }
);

type AccordionProps = React.ComponentProps<typeof AccordionPrimitive.Root> &
  VariantProps<typeof accordionVariants>;

/**
 * Stacks sections that expand and collapse. `type` sets whether one or several open at once.
 */
function Accordion({
  className,
  variant = 'stacked',
  ...props
}: AccordionProps) {
  return (
    <AccordionPrimitive.Root
      data-slot="accordion"
      data-variant={variant}
      className={cn(accordionVariants({ variant }), className)}
      {...props}
    />
  );
}

/**
 * One section, holding an AccordionTrigger and an AccordionContent.
 */
type AccordionItemProps = React.ComponentProps<typeof AccordionPrimitive.Item>;

function AccordionItem({ className, ...props }: AccordionItemProps) {
  return (
    <AccordionPrimitive.Item
      data-slot="accordion-item"
      className={cn(
        'nx:border-color-default nx:bg-muted nx:data-disabled:border-color-disabled nx:data-disabled:text-disabled-foreground',
        'nx:group-data-[variant=stacked]/accordion:border-b-default nx:group-data-[variant=stacked]/accordion:last:border-b-0',
        'nx:group-data-[variant=floating]/accordion:overflow-hidden nx:group-data-[variant=floating]/accordion:rounded-lg nx:group-data-[variant=floating]/accordion:border-width-default',
        className
      )}
      {...props}
    />
  );
}

/**
 * Button that opens and closes its item. Its arrow sits before the label, and turns down when the item is open.
 */
type AccordionTriggerProps = React.ComponentProps<
  typeof AccordionPrimitive.Trigger
>;

function AccordionTrigger({
  className,
  children,
  ...props
}: AccordionTriggerProps) {
  return (
    <AccordionPrimitive.Header className="nx:m-0 nx:flex">
      <AccordionPrimitive.Trigger
        data-slot="accordion-trigger"
        className={cn(
          'nx:flex nx:w-full nx:flex-1 nx:items-center nx:gap-3 nx:border-0 nx:bg-transparent nx:px-4 nx:py-3 nx:typography-body-default nx:text-foreground nx:transition-control nx:duration-fast nx:focus-visible:outline-2 nx:focus-visible:-outline-offset-2 nx:focus-visible:outline-focus-default nx:disabled:pointer-events-none nx:disabled:text-disabled-foreground nx:disabled:[&>svg]:text-disabled-foreground nx:[&[data-state=open]>svg]:rotate-90 nx:icon-stroke',
          className
        )}
        {...props}
      >
        <IconChevronRight
          className="nx:size-3 nx:shrink-0 nx:transition-transform nx:duration-default"
          aria-hidden="true"
        />
        <span
          data-slot="accordion-trigger-label"
          className="nx:min-w-0 nx:flex-1 nx:truncate nx:text-left"
        >
          {children}
        </span>
      </AccordionPrimitive.Trigger>
    </AccordionPrimitive.Header>
  );
}

/**
 * Content of an item. Its height animates as the item opens and closes.
 */
type AccordionContentProps = React.ComponentProps<
  typeof AccordionPrimitive.Content
>;

function AccordionContent({
  className,
  children,
  ...props
}: AccordionContentProps) {
  return (
    <AccordionPrimitive.Content
      data-slot="accordion-content"
      className="nx:overflow-hidden nx:typography-body-default nx:text-foreground nx:duration-default nx:data-[state=closed]:animate-accordion-up nx:data-[state=open]:animate-accordion-down"
      {...props}
    >
      <div
        className={cn(
          'nx:border-t-default nx:border-border-default nx:bg-container nx:p-4',
          className
        )}
      >
        {children}
      </div>
    </AccordionPrimitive.Content>
  );
}

export {
  Accordion,
  AccordionContent,
  type AccordionContentProps,
  AccordionItem,
  type AccordionItemProps,
  type AccordionProps,
  AccordionTrigger,
  type AccordionTriggerProps,
};
Ant Design needsChange
One bordered boxA border and corners on the root
Tinted headersnx:bg-muted on each item
The arrow before the labelIconChevronRight ahead of the label, turning by 90°
Plain content under a dividernx:bg-container and a top border on the content

Rewrite the Slider

Ant's Slider is a thin rail with a round handle. Replace the Slider's class recipes, and remove the code that rounds the range at each end of the rail. The props and behavior stay as they are:

components/nxds/components/slider/slider.tsx
'use client';

import * as React from 'react';

import * as SliderPrimitive from '@radix-ui/react-slider';
import { cva, type VariantProps } from 'class-variance-authority';

import { cn } from '../../lib/utils';

const sliderVariants =
  'nx:group/slider nx:relative nx:flex nx:w-full nx:touch-none nx:select-none nx:data-disabled:pointer-events-none nx:data-[orientation=horizontal]:h-3 nx:data-[orientation=horizontal]:items-center nx:data-[orientation=vertical]:h-full nx:data-[orientation=vertical]:min-h-44 nx:data-[orientation=vertical]:w-8 nx:data-[orientation=vertical]:flex-col nx:data-[orientation=vertical]:justify-center';

const sliderTrackVariants = cva(
  'nx:relative nx:grow nx:rounded-[2px] nx:bg-control-background nx:transition-colors nx:duration-fast nx:group-hover/slider:bg-control-background-hover nx:data-disabled:bg-disabled',
  {
    variants: {
      size: {
        standard:
          'nx:data-[orientation=horizontal]:h-1 nx:data-[orientation=horizontal]:w-full nx:data-[orientation=vertical]:h-full nx:data-[orientation=vertical]:w-1',
        comfortable:
          'nx:data-[orientation=horizontal]:h-1.5 nx:data-[orientation=horizontal]:w-full nx:data-[orientation=vertical]:h-full nx:data-[orientation=vertical]:w-1.5',
      },
    },
    defaultVariants: {
      size: 'standard',
    },
  }
);

const sliderRangeVariants =
  'nx:absolute nx:rounded-[2px] nx:bg-primary-border nx:transition-colors nx:duration-fast nx:group-hover/slider:bg-primary-border-active nx:data-disabled:bg-disabled-foreground nx:data-[orientation=horizontal]:top-0 nx:data-[orientation=horizontal]:h-full nx:data-[orientation=vertical]:left-0 nx:data-[orientation=vertical]:w-full';

// A white dot with a ring. The ring thickens and takes the full primary color
// on hover and focus.
const sliderThumbVariants =
  'nx:relative nx:target-24 nx:block nx:size-2.5 nx:shrink-0 nx:cursor-pointer nx:rounded-full nx:bg-popover nx:ring-2 nx:ring-primary-border nx:transition-[box-shadow] nx:duration-fast nx:hover:ring-4 nx:hover:ring-primary-background nx:focus-visible:ring-4 nx:focus-visible:ring-primary-background nx:focus-visible:outline-2 nx:focus-visible:outline-offset-4 nx:focus-visible:outline-focus-default nx:aria-invalid:focus-visible:outline-focus-error nx:data-disabled:ring-disabled-foreground';

const sliderMarkerClassName =
  'nx:pointer-events-none nx:absolute nx:z-10 nx:box-border nx:size-2 nx:rounded-full nx:border-thick nx:border-border-hairline nx:bg-popover nx:transition-colors nx:duration-fast nx:data-[orientation=horizontal]:top-1/2 nx:data-[orientation=horizontal]:-translate-x-1/2 nx:data-[orientation=horizontal]:-translate-y-1/2 nx:data-[orientation=vertical]:left-1/2 nx:data-[orientation=vertical]:-translate-x-1/2 nx:data-[orientation=vertical]:translate-y-1/2';

const sliderFloatTolerance = 0.000001;
type SliderSize = NonNullable<VariantProps<typeof sliderTrackVariants>['size']>;
type SliderMarkers = number[] | 'steps';

function getStepMarkerValues(min: number, max: number, step: number) {
  if (!Number.isFinite(min) || !Number.isFinite(max)) return [];
  if (!Number.isFinite(step) || step <= 0) return [];
  if (max <= min) return [];

  return Array.from(
    { length: Math.floor((max - min) / step) },
    (_, index) => min + step * (index + 1)
  );
}

function isMarkerCovered(marker: number, sortedValues: number[]) {
  const firstValue = sortedValues[0];

  if (firstValue === undefined) return false;

  if (sortedValues.length === 1) {
    return marker <= firstValue + sliderFloatTolerance;
  }

  const lastValue = sortedValues[sortedValues.length - 1];

  if (lastValue === undefined) return false;

  return (
    marker >= firstValue - sliderFloatTolerance &&
    marker <= lastValue + sliderFloatTolerance
  );
}

/**
 * Props for Slider.
 */
interface SliderProps extends React.ComponentProps<
  typeof SliderPrimitive.Root
> {
  /**
   * Height of the rail.
   */
  size?: SliderSize;

  /**
   * Marks along the track. Pass values for custom positions, or `"steps"` for one
   * mark per step.
   */
  markers?: SliderMarkers;
}

/**
 * Picks a value or a range. Renders one thumb per value, so `[50]` gives one
 * thumb and `[25, 75]` gives a range.
 */
function Slider({
  className,
  size = 'standard',
  defaultValue,
  disabled,
  markers,
  value,
  min = 0,
  max = 100,
  orientation = 'horizontal',
  step = 1,
  onValueChange,
  'aria-label': ariaLabel,
  'aria-labelledby': ariaLabelledby,
  'aria-invalid': ariaInvalid,
  ...props
}: SliderProps) {
  const [uncontrolledValue, setUncontrolledValue] = React.useState(
    Array.isArray(defaultValue)
      ? defaultValue
      : Array.isArray(value)
        ? value
        : [min]
  );
  const isControlled = Array.isArray(value);
  const values = isControlled ? value : uncontrolledValue;
  const valueRange = max - min;
  const sortedValues = [...values]
    .filter((nextValue) => Number.isFinite(nextValue))
    .sort((a, b) => a - b);
  const markerValues =
    markers === 'steps' ? getStepMarkerValues(min, max, step) : (markers ?? []);
  const markerPositions =
    valueRange > 0
      ? markerValues
          .filter(
            (marker) =>
              Number.isFinite(marker) &&
              marker > min &&
              marker < max &&
              !isMarkerCovered(marker, sortedValues)
          )
          .map((marker) => ((marker - min) / valueRange) * 100)
      : [];
  function handleValueChange(nextValue: number[]) {
    if (!isControlled) setUncontrolledValue(nextValue);
    onValueChange?.(nextValue);
  }

  return (
    <SliderPrimitive.Root
      data-slot="slider"
      data-size={size}
      disabled={disabled}
      defaultValue={defaultValue}
      value={value}
      min={min}
      max={max}
      orientation={orientation}
      step={step}
      onValueChange={handleValueChange}
      className={cn(sliderVariants, className)}
      {...props}
    >
      <SliderPrimitive.Track
        data-slot="slider-track"
        data-size={size}
        className={sliderTrackVariants({ size })}
      >
        <SliderPrimitive.Range
          data-slot="slider-range"
          data-orientation={orientation}
          data-size={size}
          className={sliderRangeVariants}
        />
        {markerPositions.map((position, index) => (
          <span
            aria-hidden="true"
            className={sliderMarkerClassName}
            data-disabled={disabled ? '' : undefined}
            data-orientation={orientation}
            data-size={size}
            data-slot="slider-marker"
            key={`${position}-${index}`}
            style={
              orientation === 'vertical'
                ? { bottom: `${position}%` }
                : { left: `${position}%` }
            }
          />
        ))}
      </SliderPrimitive.Track>
      {Array.from({ length: values.length }, (_, index) => (
        <SliderPrimitive.Thumb
          data-slot="slider-thumb"
          key={index}
          // Radix puts role="slider" on the thumb, not the role-less Root span:
          // forward the thumb-owned ARIA here (naming + invalid state) so it lands
          // on the right element and stays off the Root, where it'd be prohibited.
          aria-label={ariaLabel}
          aria-labelledby={ariaLabelledby}
          aria-invalid={ariaInvalid}
          data-orientation={orientation}
          data-size={size}
          className={sliderThumbVariants}
        />
      ))}
    </SliderPrimitive.Root>
  );
}

export {
  Slider,
  sliderMarkerClassName,
  type SliderProps,
  sliderRangeVariants,
  sliderThumbVariants,
  sliderTrackVariants,
  sliderVariants,
};
Ant Design needsChange in the recipe
A thin railA 4px rail with 2px corners and no border
A light track that darkens on hovernx:bg-primary-border, then nx:bg-primary-border-active
A round handle with a ringA 10px dot with nx:ring-2, and nx:ring-4 on hover and focus
The same handle in both directionssliderThumbVariants as one string, with no orientation
Ringed marks8px dots with a border

Use the parts

// components/order-details.tsx
import {
  Accordion,
  AccordionContent,
  AccordionItem,
  AccordionTrigger,
} from '@/components/nxds/components/accordion/accordion';
import {
  DescriptionList,
  DescriptionListDescription,
  DescriptionListItem,
  DescriptionListTerm,
} from '@/components/nxds/components/description-list/description-list';
import { Label } from '@/components/nxds/components/label/label';
import { Slider } from '@/components/nxds/components/slider/slider';

export function OrderDetails() {
  return (
    <div className="nx:flex nx:flex-col nx:gap-6">
      <DescriptionList>
        <DescriptionListItem>
          <DescriptionListTerm>Customer</DescriptionListTerm>
          <DescriptionListDescription>Ada Lovelace</DescriptionListDescription>
        </DescriptionListItem>
        <DescriptionListItem>
          <DescriptionListTerm>Total</DescriptionListTerm>
          <DescriptionListDescription>$1,280.00</DescriptionListDescription>
        </DescriptionListItem>
      </DescriptionList>

      <Accordion type="single" collapsible defaultValue="shipping">
        <AccordionItem value="shipping">
          <AccordionTrigger>Shipping</AccordionTrigger>
          <AccordionContent>Express, two business days.</AccordionContent>
        </AccordionItem>
        <AccordionItem value="payment">
          <AccordionTrigger>Payment</AccordionTrigger>
          <AccordionContent>Card ending 4242.</AccordionContent>
        </AccordionItem>
      </Accordion>

      <div className="nx:flex nx:flex-col nx:gap-1">
        <Label id="refund-share" className="nx:font-normal">
          Refund share
        </Label>
        <Slider defaultValue={[30]} aria-labelledby="refund-share" />
      </div>
    </div>
  );
}

What nxds provides

From nxdsIn this example
Light and dark modeThe provider switches .dark, and the colors file has a value for each
DensityEvery part sizes itself from nxds spacing tokens
Color namesEvery class reads an nxds color, so one file recolors every part
BehaviorAccordion and Slider keep their keyboard and screen reader support

The nxds page in the preview follows the page's mode and density. Its colors and corners come from the palette file, so the theme picker doesn't change them. The Ant Design page follows the page's mode only.

Next steps

  • Material look: a settings screen with a rewritten Switch and a new TextField.
  • Your own colors: the colors file, and what keeps working.
  • Sidebar: the stock Sidebar and its parts.