Skip to content

Commit

Permalink
docs(components/radio): make invalid code example controlled and ha…
Browse files Browse the repository at this point in the history
…ve both valid and invalid options (a more realistic example of its use) (heroui-inc#746)
  • Loading branch information
benmneb authored Mar 6, 2023
1 parent bf2d3a1 commit 9ef2663
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions apps/docs/content/components/radio/invalid.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
const App = `import { Radio } from "@nextui-org/react";
const App = `import React from "react";
import { Radio } from "@nextui-org/react";
export default function App() {
const [selected, setSelected] = React.useState('A');
return (
<Radio.Group label="Options" defaultValue="A" validationState="invalid">
<Radio value="A" description="Description for Option A">
<Radio.Group
label="Options"
value={selected}
onChange={setSelected}
validationState={["A", "C"].includes(selected) ? 'valid' : 'invalid'}
>
<Radio value="A" description="A perfectly valid option">
Option A
</Radio>
<Radio value="B" description="Description for Option B">
<Radio value="B" description="Definitely not valid">
Option B
</Radio>
<Radio value="C" description="Description for Option C">
<Radio value="C" description="Another valid option">
Option C
</Radio>
<Radio value="D" description="Description for Option D">
<Radio value="D" description="Uh oh, invalid!">
Option D
</Radio>
</Radio.Group>
Expand Down

0 comments on commit 9ef2663

Please sign in to comment.