Edit Profile

Dark Mode

Copy config

Copy and paste the following code into your global.css file to apply the styles.

WARNING: This component is in
Draft
status. This means that it is still in development and may have bugs or missing features. It is not intended to be used in production. You may use it for testing purposes.

Radio Group

Visually or semantically separates content.


Installation

Run the following cli command or copy/paste the component code into your project

qwik-ui add radio-group
import { PropsOf, Slot, component$ } from '@builder.io/qwik';
import { cn } from '@qwik-ui/utils';
 
export const RadioGroup = component$<PropsOf<'div'>>(({ ...props }) => {
  return (
    <div class={cn('grid gap-2', props.class)} {...props}>
      <Slot />
    </div>
  );
});
 
export const RadioGroupItem = component$<PropsOf<'input'>>(({ ...props }) => {
  return (
    <input
      type="radio"
      {...props}
      class={cn(
        'accent-primary h-4 w-4 disabled:cursor-not-allowed disabled:opacity-50',
        props.class,
      )}
    />
  );
});

Usage

import { Label, RadioGroup, RadioGroupItem } from '@qwik-ui/styled';
<RadioGroup>
  <div class="flex items-center space-x-2">
    <RadioGroupItem name="size" value="default" id="r1" />
    <Label for="r1">Default</Label>
  </div>
  <div class="flex items-center space-x-2">
    <RadioGroupItem name="size" value="comfortable" id="r2" />
    <Label for="r2">Comfortable</Label>
  </div>
  <div class="flex items-center space-x-2">
    <RadioGroupItem name="size" value="compact" id="r3" />
    <Label for="r3">Compact</Label>
  </div>
</RadioGroup>