Skip to content

Commit 639f542

Browse files
committed
Add controlled and uncontrolled documentation for Select
1 parent 38d7249 commit 639f542

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

stories/Select.stories.tsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ const { meta, getStory } = getStoryFactory({
1212
- [See DSFR documentation](https://www.systeme-de-design.gouv.fr/elements-d-interface/composants/bandeau-d-information-importante)
1313
- [See source code](https://github.com/codegouvfr/react-dsfr/blob/main/src/Notice.tsx)
1414
15+
## Controlled
16+
1517
\`\`\`tsx
1618
import { useState } from "react";
1719
import { Select } from "../../dist/Select";
@@ -27,6 +29,34 @@ function MyComponent(){
2729
onChange: event => setValue(event.target.value),
2830
value
2931
}}
32+
>
33+
<option value="" disabled hidden>Selectionnez une option</option>
34+
<option value="1">Option 1</option>
35+
<option value="2">Option 2</option>
36+
<option value="3">Option 3</option>
37+
<option value="4">Option 4</option>
38+
</Select>
39+
);
40+
41+
}
42+
\`\`\`
43+
44+
## Uncontrolled
45+
46+
\`\`\`tsx
47+
import { useState } from "react";
48+
import { Select } from "../../dist/Select";
49+
50+
function MyComponent(){
51+
52+
const [ value, setValue ] = useState("");
53+
54+
return (
55+
<Select
56+
label="Label"
57+
nativeSelectProps={{
58+
name: "my-select"
59+
}}
3060
>
3161
<option value="" selected disabled hidden>Selectionnez une option</option>
3262
<option value="1">Option 1</option>
@@ -38,6 +68,7 @@ function MyComponent(){
3868
3969
}
4070
\`\`\`
71+
4172
`,
4273
"argTypes": {
4374
"nativeSelectProps": {

0 commit comments

Comments
 (0)