Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
@mui/styled-engine-sc
Advanced tools
@mui/styled-engine-sc is a styling solution for Material-UI that leverages styled-components. It allows you to create custom-styled components using the styled-components library while maintaining compatibility with Material-UI's theming and styling system.
Custom Styled Components
This feature allows you to create custom-styled components using the styled-components syntax. The example demonstrates how to style a Material-UI Button component with a gradient background, custom padding, and other CSS properties.
const MyButton = styled(Button)`
background: linear-gradient(45deg, #FE6B8B 30%, #FF8E53 90%);
border: 0;
border-radius: 3px;
box-shadow: 0 3px 5px 2px rgba(255, 105, 135, .3);
color: white;
height: 48px;
padding: 0 30px;
`;
<MyButton>Styled Button</MyButton>;
Theming
This feature allows you to use Material-UI's theming capabilities with styled-components. The example shows how to create a custom theme and apply it to a styled component, utilizing theme properties like palette and spacing.
const theme = createTheme({
palette: {
primary: {
main: '#1976d2',
},
},
});
const MyComponent = styled('div')(({ theme }) => ({
backgroundColor: theme.palette.primary.main,
padding: theme.spacing(2),
borderRadius: theme.shape.borderRadius,
}));
<ThemeProvider theme={theme}>
<MyComponent>Styled with Theme</MyComponent>
</ThemeProvider>;
Responsive Styles
This feature allows you to create responsive styles using media queries within styled-components. The example demonstrates how to change the background color of a div based on different screen widths.
const ResponsiveBox = styled('div')`
width: 100%;
height: 100px;
background-color: lightblue;
@media (min-width: 600px) {
background-color: lightgreen;
}
@media (min-width: 960px) {
background-color: lightcoral;
}
`;
<ResponsiveBox>Responsive Box</ResponsiveBox>;
styled-components is a popular library for styling React applications using tagged template literals. It provides a way to write CSS directly within JavaScript and supports theming, nesting, and more. Compared to @mui/styled-engine-sc, styled-components is more general-purpose and not specifically tied to Material-UI.
@emotion/styled is a library for writing CSS styles with JavaScript, similar to styled-components. It is part of the Emotion library, which offers a flexible and performant way to style applications. @emotion/styled is the default styling solution for Material-UI, whereas @mui/styled-engine-sc is an alternative that uses styled-components.
styled-jsx is a library for scoped CSS in Next.js applications. It allows you to write CSS directly within your JavaScript and ensures that styles are scoped to the component. While styled-jsx is not specifically designed for Material-UI, it offers a similar approach to writing component-scoped styles.
This package is a wrapper around the styled-components
package implementing the interface of @mui/styled-engine
.
It's designed for developers who would like to use styled-components
as the main styled engine instead of @emotion/styled
.
@mui/base@5.0.0-beta.53
Demo
component (#42857) @LukasTyAll contributors of this release in alphabetical order: @bharatkashyap, @brijeshb42, @DiegoAndai, @Janpot, @lhilgert9, @LukasTy, @mbrookes, @oliviertassinari, @omahs, @romgrk, @sai6855, @ZeeshanTamboli
FAQs
styled() API wrapper package for styled-components.
The npm package @mui/styled-engine-sc receives a total of 282,807 weekly downloads. As such, @mui/styled-engine-sc popularity was classified as popular.
We found that @mui/styled-engine-sc demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 11 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.