forked from mui/material-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[material-ui][Button] Add demo for file upload (mui#38786)
- Loading branch information
Showing
4 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import * as React from 'react'; | ||
import { styled } from '@mui/material/styles'; | ||
import Button from '@mui/material/Button'; | ||
import CloudUploadIcon from '@mui/icons-material/CloudUpload'; | ||
|
||
const VisuallyHiddenInput = styled('input')` | ||
clip: rect(0 0 0 0); | ||
clip-path: inset(50%); | ||
height: 1px; | ||
overflow: hidden; | ||
position: absolute; | ||
bottom: 0; | ||
left: 0; | ||
white-space: nowrap; | ||
width: 1px; | ||
`; | ||
|
||
export default function InputFileUpload() { | ||
return ( | ||
<Button | ||
component="label" | ||
variant="contained" | ||
startIcon={<CloudUploadIcon />} | ||
href="#file-upload" | ||
> | ||
Upload a file | ||
<VisuallyHiddenInput type="file" /> | ||
</Button> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import * as React from 'react'; | ||
import { styled } from '@mui/material/styles'; | ||
import Button from '@mui/material/Button'; | ||
import CloudUploadIcon from '@mui/icons-material/CloudUpload'; | ||
|
||
const VisuallyHiddenInput = styled('input')` | ||
clip: rect(0 0 0 0); | ||
clip-path: inset(50%); | ||
height: 1px; | ||
overflow: hidden; | ||
position: absolute; | ||
bottom: 0; | ||
left: 0; | ||
white-space: nowrap; | ||
width: 1px; | ||
`; | ||
|
||
export default function InputFileUpload() { | ||
return ( | ||
<Button | ||
component="label" | ||
variant="contained" | ||
startIcon={<CloudUploadIcon />} | ||
href="#file-upload" | ||
> | ||
Upload a file | ||
<VisuallyHiddenInput type="file" /> | ||
</Button> | ||
); | ||
} |
9 changes: 9 additions & 0 deletions
9
docs/data/material/components/buttons/InputFileUpload.tsx.preview
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Button | ||
component="label" | ||
variant="contained" | ||
startIcon={<CloudUploadIcon />} | ||
href="#file-upload" | ||
> | ||
Upload a file | ||
<VisuallyHiddenInput type="file" /> | ||
</Button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters