@material-ui/core APIs
- Typography
- Button
- Grid
- TextField
- IconButton
- Paper
- Card
- MenuItem
- AppBar
- Container
- Toolbar
- makeStyles
- Divider
- ListItem
- Tooltip
- CardContent
- CircularProgress
- Box
- List
- Avatar
- FormControl
- ListItemText
- Dialog
- Select
- DialogContent
- Link
- DialogTitle
- CssBaseline
- FormControlLabel
- InputLabel
- DialogActions
- Checkbox
- TableBody
- Menu
- Table
- TableHead
- TableRow
- Drawer
- TableCell
- createMuiTheme
- Tabs
- Tab
- Hidden
- Switch
- InputAdornment
- ThemeProvider
- CardHeader
- Snackbar
- ListItemIcon
- CardActions
- Chip
- LinearProgress
- Input
- DialogContentText
- Collapse
- useMediaQuery
- CardMedia
- TableContainer
- Badge
- Fab
- withStyles
- ListItemAvatar
- ButtonGroup
- Modal
- CardActionArea
- FormGroup
- Radio
- InputBase
- useTheme
- FormHelperText
- ListSubheader
- RadioGroup
- SvgIcon
- ClickAwayListener
- TablePagination
- Slide
- Fade
- Stepper
- StepLabel
- Popover
- Slider
- Accordion
- AccordionSummary
- colors
- Step
- FormLabel
- AccordionDetails
- ExpansionPanel
- ExpansionPanelSummary
- ExpansionPanelDetails
- Backdrop
- Breadcrumbs
- Icon
- ListItemSecondaryAction
- createTheme
- Zoom
- TableSortLabel
- MuiThemeProvider
- TextareaAutosize
- ButtonBase
- StepContent
- createStyles
- NativeSelect
- Grow
- MenuList
- Popper
- useScrollTrigger
- OutlinedInput
- GridList
- GridListTile
- GridListTileBar
- TableFooter
- BottomNavigation
- BottomNavigationAction
- SnackbarContent
- withWidth
- responsiveFontSizes
- capitalize
- green
- lighten
- MobileStepper
- isWidthUp
- ImageList
- ImageListItem
- ImageListItemBar
- ServerStyleSheets
- SwipeableDrawer
- Stack
- Autocomplete
- Rating
- fade
- withMobileDialog
- RootRef
- createSvgIcon
- ExpansionPanelActions
- styled
- alpha
OtherRelated APIs
@material-ui/core#RootRef JavaScript Examples
The following examples show how to use
@material-ui/core#RootRef.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CheckoutItem.jsx From resilience-app with GNU General Public License v3.0 | 5 votes |
export default function CheckoutItem({ cost, description, name, onChange, quantity }) {
const classes = useStyles();
const [open, setOpen] = useState(false);
const [width, setWidth] = useState(0);
const ref = useCallback((node) => node && setWidth(node.offsetWidth), []);
const crop = width / CHAR_WIDTH;
const formatedDescription =
description.length > crop ? description.slice(0, crop) + "..." : description;
return (
<>
<Divider />
<ListItem className={classes.listItem}>
{onChange ? (
<Select
className={classes.select}
native
variant="outlined"
value={quantity}
onChange={onChange}
inputProps={{
name: "quantity",
id: "quantity",
}}
>
{[...Array(MAX_ORDER + 1)].map((e, i) => (
<option value={i} key={i}>
{i}
</option>
))}
</Select>
) : (
<Typography className={classes.quantity} variant="h4">
{quantity}
</Typography>
)}
<RootRef rootRef={ref}>
<Box onClick={() => setOpen(!open)} flex={1} display="flex" flexDirection="column">
<Typography variant="h4" color="textPrimary">
{name}
</Typography>
{!open && formatedDescription}
<Collapse in={open} timeout={0}>
{description}
</Collapse>
<Expand open={open} />
</Box>
</RootRef>
<ListItemText className={classes.cost}>
<Typography variant={onChange ? "h4" : "body1"} color="textPrimary">
${parseFloat(cost).toFixed(2)}
</Typography>
</ListItemText>
</ListItem>
</>
);
}