Socket
Socket
Sign inDemoInstall

@mui/styles

Package Overview
Dependencies
19
Maintainers
0
Versions
116
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mui/styles


Version published
Weekly downloads
526K
decreased by-20.07%
Maintainers
0
Created
Weekly downloads
 

Package description

What is @mui/styles?

@mui/styles is a styling solution for React applications that is part of the Material-UI library. It provides a set of utilities to help you style your components using JavaScript, allowing for dynamic and theme-based styling.

What are @mui/styles's main functionalities?

CSS-in-JS

This feature allows you to define styles using JavaScript objects. The `makeStyles` function generates a hook that you can use to apply these styles to your components.

const useStyles = makeStyles({
  root: {
    background: 'linear-gradient(45deg, #FE6B8B 30%, #FF8E53 90%)',
    border: 0,
    borderRadius: 3,
    boxShadow: '0 3px 5px 2px rgba(255, 105, 135, .3)',
    color: 'white',
    height: 48,
    padding: '0 30px',
  },
});

function MyComponent() {
  const classes = useStyles();
  return <button className={classes.root}>Styled Button</button>;
}

Theming

Theming allows you to define a theme object that can be used to provide consistent styling across your application. The `ThemeProvider` component makes the theme available to all components within its subtree.

const theme = createTheme({
  palette: {
    primary: {
      main: '#1976d2',
    },
    secondary: {
      main: '#dc004e',
    },
  },
});

function ThemedComponent() {
  return (
    <ThemeProvider theme={theme}>
      <Button color="primary">Primary Button</Button>
      <Button color="secondary">Secondary Button</Button>
    </ThemeProvider>
  );
}

Styled Components

Styled Components allow you to create custom-styled components using the `styled` function. This approach provides a more component-centric way of applying styles.

const MyButton = styled('button')({
  background: 'linear-gradient(45deg, #FE6B8B 30%, #FF8E53 90%)',
  border: 0,
  borderRadius: 3,
  boxShadow: '0 3px 5px 2px rgba(255, 105, 135, .3)',
  color: 'white',
  height: 48,
  padding: '0 30px',
});

function MyComponent() {
  return <MyButton>Styled Button</MyButton>;
}

Other packages similar to @mui/styles

Readme

Source

@mui/styles

You can leverage our styling solution, even if you are not using our components.

Installation

Install the package in your project directory with:

npm install @mui/styles

Documentation

Visit https://mui.com/system/styles/basics/ to view the full documentation.

Keywords

FAQs

Last updated on 05 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc