New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@gentleduck/primitives

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gentleduck/primitives

Unstyled, accessibility-first UI primitives for React.

latest
Source
npmnpm
Version
0.2.9
Version published
Weekly downloads
361
-22.2%
Maintainers
1
Weekly downloads
 
Created
Source

@gentleduck/primitives

Unstyled, accessibility-first UI primitives for React.

Why primitives

  • 50-92% smaller than Radix - Alert Dialog: 1.6 KB vs 18.6 KB. Popover: 2.4 KB vs 19.6 KB. Dialog: 3.1 KB vs 10.6 KB. Shared internals (Slot, Presence, Popper, focus scope) load once instead of being duplicated per-package.
  • Full keyboard navigation + ARIA compliance out of the box - every component ships with correct roles, states, and keyboard interactions so you don't have to wire them yourself.
  • Compound component pattern - compose Root, Trigger, Content, and friends to build exactly the UI you need without prop drilling.
  • Compatible with Radix API - same naming, same asChild pattern, same data-state attributes. Migration from Radix is a namespace change in your imports.

Components

PrimitiveDescription
alert-dialogModal dialog that requires user acknowledgment
arrowPositioning arrow for floating elements
avatarUser avatar with image and fallback support
calendarDate grid with keyboard navigation and multi-view support
checkersCheckbox and switch toggle primitive
commandCommand palette with search filtering
context-menuRight-click context menu with submenus
dialogModal and non-modal dialog windows
directionRTL/LTR direction provider
dismissable-layerLayer that dismisses on outside interaction
dropdown-menuDropdown menu with submenus, checkboxes, and radio items
focus-scopeTraps and manages focus within a boundary
hover-cardCard triggered by hover with open/close delay
input-otpOne-time password input with slots and separators
menuBase menu primitive used by dropdown, context, and menubar
menubarHorizontal menu bar with keyboard navigation
mountDeferred mounting with lifecycle callbacks
navigation-menuSite navigation with animated indicator and viewport
paginationPage navigation controls
popoverFloating content anchored to a trigger
popperLow-level floating element positioning via Floating UI
portalRenders children into a DOM portal
presenceAnimate mount/unmount transitions
primitive-elementsBase Primitive element factory (asChild support)
progressDeterminate and indeterminate progress indicator
radio-groupRadio button group with roving focus
roving-focusRoving tabindex focus management for groups
selectListbox-style select with typeahead and scroll buttons
sheetSlide-out panel (re-exports dialog internals)
sliderRange slider with single or multiple thumbs
slotMerges props and ref onto a child element (asChild engine)
toggleTwo-state toggle button
toggle-groupSingle or multi-select group of toggles
tooltipAccessible tooltip with provider-level delay
visibility-hiddenVisually hidden element for screen readers

Quick Start

npm install @gentleduck/primitives
import * as Dialog from '@gentleduck/primitives/dialog'

function Demo() {
  return (
    <Dialog.Root>
      <Dialog.Trigger>Open</Dialog.Trigger>
      <Dialog.Portal>
        <Dialog.Overlay />
        <Dialog.Content>
          <Dialog.Title>Heading</Dialog.Title>
          <Dialog.Description>Body text here.</Dialog.Description>
          <Dialog.Close>Close</Dialog.Close>
        </Dialog.Content>
      </Dialog.Portal>
    </Dialog.Root>
  )
}

Features

  • asChild / Slot - render any primitive as your own element via the asChild prop, powered by the Slot utility.
  • createContextScope - scoped React context factory that prevents cross-instance state leaks.
  • forwardRef everywhere - every component forwards refs for imperative access and composition.
  • data-slot attributes - every component root emits a data-slot for style targeting without class names.
  • Presence animations - the Presence primitive lets you animate enter/exit transitions before unmounting.
  • Focus trapping - FocusScope locks focus inside modals, dialogs, and popovers with configurable loop behavior.
  • Dismiss layers - DismissableLayer handles outside clicks, Escape key, and nested layer stacking.

Documentation

gentleduck.org/docs/packages/duck-primitives

License

MIT

Keywords

aria

FAQs

Package last updated on 26 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts