Skip to content

An open source design system that's fully customizable and agent ready

TypeScript
726 B
Raw Blame
// Copyright (c) Meta Platforms, Inc. and affiliates.

'use client';

import {useState} from 'react';
import {RadioList, RadioListItem} from '@astryxdesign/core/RadioList';

export default function RadioListWithValidation() {
  const [value, setValue] = useState('');

  return (
    <RadioList
      label="Notification preference"
      isRequired
      status={
        value === ''
          ? {type: 'error', message: 'Please select a notification method'}
          : undefined
      }
      value={value}
      onChange={setValue}>
      <RadioListItem label="Email" value="email" />
      <RadioListItem label="SMS" value="sms" />
      <RadioListItem label="Push notification" value="push" />
    </RadioList>
  );
}