Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] Add TS demo for FormControlLabelPosition #17964

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions docs/src/pages/components/checkboxes/FormControlLabelPosition.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,11 @@ import FormControlLabel from '@material-ui/core/FormControlLabel';
import FormControl from '@material-ui/core/FormControl';
import FormLabel from '@material-ui/core/FormLabel';

function FormControlLabelPosition() {
const [value, setValue] = React.useState('female');

const handleChange = event => {
setValue(event.target.value);
};

export default function FormControlLabelPosition() {
return (
<FormControl component="fieldset">
<FormLabel component="legend">labelPlacement</FormLabel>
<FormGroup aria-label="position" name="position" value={value} onChange={handleChange} row>
<FormLabel component="legend">Label Placement</FormLabel>
<FormGroup aria-label="position" row>
<FormControlLabel
value="top"
control={<Checkbox color="primary" />}
Expand Down Expand Up @@ -44,5 +38,3 @@ function FormControlLabelPosition() {
</FormControl>
);
}

export default FormControlLabelPosition;
40 changes: 40 additions & 0 deletions docs/src/pages/components/checkboxes/FormControlLabelPosition.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import React from 'react';
import Checkbox from '@material-ui/core/Checkbox';
import FormGroup from '@material-ui/core/FormGroup';
import FormControlLabel from '@material-ui/core/FormControlLabel';
import FormControl from '@material-ui/core/FormControl';
import FormLabel from '@material-ui/core/FormLabel';

export default function FormControlLabelPosition() {
return (
<FormControl component="fieldset">
<FormLabel component="legend">Label Placement</FormLabel>
<FormGroup aria-label="position" row>
<FormControlLabel
value="top"
control={<Checkbox color="primary" />}
label="Top"
labelPlacement="top"
/>
<FormControlLabel
value="start"
control={<Checkbox color="primary" />}
label="Start"
labelPlacement="start"
/>
<FormControlLabel
value="bottom"
control={<Checkbox color="primary" />}
label="Bottom"
labelPlacement="bottom"
/>
<FormControlLabel
value="end"
control={<Checkbox color="primary" />}
label="End"
labelPlacement="end"
/>
</FormGroup>
</FormControl>
);
}