
Security News
NIST Officially Stops Enriching Most CVEs as Vulnerability Volume Skyrockets
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.
sx-machine
Advanced tools
First class Sx property for React.
https://user-images.githubusercontent.com/3781663/199988034-7f4b5e8e-2217-4634-9ab4-9de8740d93c2.mov
npm install sx-machine
---
yarn add sx-machine
const theme = {
...defaultTheme,
colors: {
$primary: '#234234',
},
};
const Exemple = () => {
return (
<ThemeProvider theme={theme}>
<Box sx={{ bg: '$primary', m: 10 }}>Content</Box>
</ThemeProvider>
);
};
Sx-machine provides a powerful theming feature.
The default theme includes spaces and breakpoints.
$ prefix
It's recommanded to use $ prefixed theme keys to help differenciate theme values from native CSS values
import { defaultTheme } from 'sx-machine';
const theme = {
...defaultTheme,
colors: {
$primary: '#234234',
$secondary: '#456456',
},
shadows: {
$1: '0 2px 6px 0 rgba(0, 0, 0, 0.15)',
$2: '0 2px 8px 0px rgba(0, 0, 0, 0.13)',
$3: '0 2px 12px 1px rgba(0, 0, 0, 0.10)',
},
};
const App = () => {
return <ThemeProvider theme={theme}>...</ThemeProvider>;
};
as attributeThe Box Component is the primitive component that allows you to access the sx property. By default it renders a div html element.
It accepts a as attribute to choose the needed tag.
<Box as="a" href="#" sx={{ color: '$primary' }}>
My link
</Box>
Of course, the href attribute type is well inferred from the "
a" tag.
And it works for all tags and Components !
Components often need to be reusable and easily customisable with the sx property overriding.
Let's create a reusable Button !
// Button.tsx
import { createSxComponent } from 'sx-machine';
const Button: Button = createSxComponent<'div',
{
children?: React.ReactNode,
}>(({ children, sx, ...props }) => {
return (
<Box sx={[{ bg: 'green', px: 4, py: 2 }, sx]} {...props}>
{children}
</Box>
);
});
// Page.tsx
import Button from './Button.tsx';
const Page = () => {
return (
<div>
<Button onClick=() => {console.log('hey!')}>Button</Button>
// Reusable components allows additional style with the sx prop
<Button sx={{mt: 4}}>Custom Button</Button>
</div>
);
};
FAQs
Sx-machine First class Sx property for React.
The npm package sx-machine receives a total of 8 weekly downloads. As such, sx-machine popularity was classified as not popular.
We found that sx-machine demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.

Security News
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.