UNPKG

@mui/material

Version:

Quickly build beautiful React apps. MUI is a simple and customizable component library to build faster, beautiful, and more accessible React applications. Follow your own design system, or start with Material Design.

131 lines (119 loc) 3.79 kB
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose"; import _extends from "@babel/runtime/helpers/esm/extends"; const _excluded = ["className", "component", "disableGutters", "variant"]; import * as React from 'react'; import PropTypes from 'prop-types'; import clsx from 'clsx'; import { unstable_composeClasses as composeClasses } from '@mui/base'; import useThemeProps from '../styles/useThemeProps'; import styled from '../styles/styled'; import { getToolbarUtilityClass } from './toolbarClasses'; import { jsx as _jsx } from "react/jsx-runtime"; const useUtilityClasses = ownerState => { const { classes, disableGutters, variant } = ownerState; const slots = { root: ['root', !disableGutters && 'gutters', variant] }; return composeClasses(slots, getToolbarUtilityClass, classes); }; const ToolbarRoot = styled('div', { name: 'MuiToolbar', slot: 'Root', overridesResolver: (props, styles) => { const { ownerState } = props; return [styles.root, !ownerState.disableGutters && styles.gutters, styles[ownerState.variant]]; } })(({ theme, ownerState }) => _extends({ position: 'relative', display: 'flex', alignItems: 'center' }, !ownerState.disableGutters && { paddingLeft: theme.spacing(2), paddingRight: theme.spacing(2), [theme.breakpoints.up('sm')]: { paddingLeft: theme.spacing(3), paddingRight: theme.spacing(3) } }, ownerState.variant === 'dense' && { minHeight: 48 }), ({ theme, ownerState }) => ownerState.variant === 'regular' && theme.mixins.toolbar); const Toolbar = /*#__PURE__*/React.forwardRef(function Toolbar(inProps, ref) { const props = useThemeProps({ props: inProps, name: 'MuiToolbar' }); const { className, component = 'div', disableGutters = false, variant = 'regular' } = props, other = _objectWithoutPropertiesLoose(props, _excluded); const ownerState = _extends({}, props, { component, disableGutters, variant }); const classes = useUtilityClasses(ownerState); return /*#__PURE__*/_jsx(ToolbarRoot, _extends({ as: component, className: clsx(classes.root, className), ref: ref, ownerState: ownerState }, other)); }); process.env.NODE_ENV !== "production" ? Toolbar.propTypes /* remove-proptypes */ = { // ----------------------------- Warning -------------------------------- // | These PropTypes are generated from the TypeScript type definitions | // | To update them edit the d.ts file and run "yarn proptypes" | // ---------------------------------------------------------------------- /** * The Toolbar children, usually a mixture of `IconButton`, `Button` and `Typography`. * The Toolbar is a flex container, allowing flex item properites to be used to lay out the children. */ children: PropTypes.node, /** * Override or extend the styles applied to the component. */ classes: PropTypes.object, /** * @ignore */ className: PropTypes.string, /** * The component used for the root node. * Either a string to use a HTML element or a component. */ component: PropTypes.elementType, /** * If `true`, disables gutter padding. * @default false */ disableGutters: PropTypes.bool, /** * The system prop that allows defining system overrides as well as additional CSS styles. */ sx: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])), PropTypes.func, PropTypes.object]), /** * The variant to use. * @default 'regular' */ variant: PropTypes /* @typescript-to-proptypes-ignore */ .oneOfType([PropTypes.oneOf(['dense', 'regular']), PropTypes.string]) } : void 0; export default Toolbar;