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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@darksnow-ui/radio-group

v1.0.0

Published

radio-group component for DarkSnow UI

Readme

Radio Group

A set of checkable buttons—known as radio buttons—where no more than one of the buttons can be checked at a time. Built on top of Radix UI Radio Group primitive.

Installation

npm install @darksnow-ui/radio-group

Peer Dependencies

npm install react react-dom

Usage

import { RadioGroup, RadioGroupItem } from "@darksnow-ui/radio-group"
import { Label } from "@darksnow-ui/label"

export function RadioGroupExample() {
  return (
    <RadioGroup defaultValue="comfortable">
      <div className="flex items-center space-x-2">
        <RadioGroupItem value="default" id="r1" />
        <Label htmlFor="r1">Default</Label>
      </div>
      <div className="flex items-center space-x-2">
        <RadioGroupItem value="comfortable" id="r2" />
        <Label htmlFor="r2">Comfortable</Label>
      </div>
      <div className="flex items-center space-x-2">
        <RadioGroupItem value="compact" id="r3" />
        <Label htmlFor="r3">Compact</Label>
      </div>
    </RadioGroup>
  )
}

Components

RadioGroup

The root container for radio group items.

| Prop | Type | Default | Description | |--------------|-------------------|---------|--------------------------------| | defaultValue | string | - | Default selected value | | value | string | - | Controlled selected value | | onValueChange| function | - | Called when value changes | | name | string | - | Form name attribute | | disabled | boolean | false | Disables all radio items | | orientation | "horizontal" | "vertical" | "vertical" | Layout orientation | | className | string | - | Additional CSS classes |

RadioGroupItem

A single radio item within the group.

| Prop | Type | Default | Description | |-----------|-------------------|---------|--------------------------------| | value | string | - | The value for this radio item | | disabled | boolean | false | Disables this radio item | | id | string | - | HTML id attribute | | className | string | - | Additional CSS classes |

Examples

Basic Radio Group

<RadioGroup defaultValue="option-one">
  <div className="flex items-center space-x-2">
    <RadioGroupItem value="option-one" id="option-one" />
    <Label htmlFor="option-one">Option One</Label>
  </div>
  <div className="flex items-center space-x-2">
    <RadioGroupItem value="option-two" id="option-two" />
    <Label htmlFor="option-two">Option Two</Label>
  </div>
</RadioGroup>

Controlled Radio Group

function ControlledRadioGroup() {
  const [value, setValue] = useState("option-one")

  return (
    <RadioGroup value={value} onValueChange={setValue}>
      <div className="flex items-center space-x-2">
        <RadioGroupItem value="option-one" id="option-one" />
        <Label htmlFor="option-one">Option One</Label>
      </div>
      <div className="flex items-center space-x-2">
        <RadioGroupItem value="option-two" id="option-two" />
        <Label htmlFor="option-two">Option Two</Label>
      </div>
    </RadioGroup>
  )
}

Disabled Radio Group

<RadioGroup disabled defaultValue="option-one">
  <div className="flex items-center space-x-2">
    <RadioGroupItem value="option-one" id="option-one" />
    <Label htmlFor="option-one">Option One</Label>
  </div>
  <div className="flex items-center space-x-2">
    <RadioGroupItem value="option-two" id="option-two" />
    <Label htmlFor="option-two">Option Two</Label>
  </div>
</RadioGroup>

Horizontal Layout

<RadioGroup orientation="horizontal" defaultValue="option-one" className="flex space-x-4">
  <div className="flex items-center space-x-2">
    <RadioGroupItem value="option-one" id="option-one" />
    <Label htmlFor="option-one">Option One</Label>
  </div>
  <div className="flex items-center space-x-2">
    <RadioGroupItem value="option-two" id="option-two" />
    <Label htmlFor="option-two">Option Two</Label>
  </div>
</RadioGroup>

Accessibility

  • Full keyboard navigation support
  • Screen reader accessible with proper ARIA attributes
  • Focus management between radio items
  • Arrow key navigation within groups
  • Space key to select items
  • Proper labeling support

Styling

The Radio Group components use DarkSnow UI design tokens:

  • Container: Grid layout with configurable gap
  • Items: Circular border with accent colors
  • Indicator: Filled circle when selected
  • Focus: Ring outline on focus
  • Disabled: Reduced opacity and disabled cursor

Best Practices

  1. Always use labels: Associate each radio item with a descriptive label
  2. Logical grouping: Group related options together
  3. Default selection: Consider providing a sensible default value
  4. Clear options: Make option text clear and distinct
  5. Appropriate sizing: Use consistent spacing between options

Related Components

  • Checkbox - For multiple selections
  • Select - For dropdown selections
  • Label - For labeling form controls